Hi,

I'm wondering what sort of code you're trying to write where a receive ... 
after block wouldn't work well in this situation. Furthermore what do we do 
in the error case if the receive times out? For ExUnit this is quite 
simple: the test fails, but in your application code this doesn't mean 
anything. If you get to the point that you're specifying control from with 
this new macro then you've just recreated receive with more steps. Could 
you provide some code samples for what you're trying to achieve?

Best,
Theron
On Thursday, January 20, 2022 at 9:22:43 AM UTC-6 
andrzej.p...@swmansion.com wrote:

> Lastly, I was trying to implement a macro with similar functionality as 
> assert_receive from ExUnit. The purpose of this macro was to allow the user 
> to wait synchronously for a message specified by a pattern. The given 
> pattern may contain variables that the user is interested to extract from 
> the arrived message (exactly as in ExUnit.assert_receive). I've noticed 
> that there is a significant amount of code that expands the given pattern 
> and then collects the variables from it etc. in order to properly extract 
> variables from the pattern. I have a feeling that it is not a valid 
> solution to use an ExUnit.assert_receive in the production code, so maybe 
> it would be possible to add the function of similar functionality to the 
> Process module. Something like Process.await_message(). Another possibly 
> better solution could be adding some functionality to the Macro module that 
> would cover expanding the macro and collecting variables etc. (
> https://github.com/elixir-lang/elixir/blob/a64d42f5d3cb6c32752af9d3312897e8cd5bb7ec/lib/ex_unit/lib/ex_unit/assertions.ex#L467
> )
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/388c594b-46f2-4b13-acfe-5209af180081n%40googlegroups.com.

Reply via email to