Can you use a pin operator on a struct key value?
For example, I’m spawning a Task for which I want to monitor incoming messages:
%Task{owner: #PID<0.493.0>, pid: #PID<0.699.0>, ref: #Reference<0.0.3.6279>}
I want to create a wait function that accepts the Task struct so I can match on messages from the task, like this:
def wait(task) do
receive do
{^task.ref, response} ->
{:ok, response}
{:DOWN, ^task.ref, ^task.pid, _} ->
{:error}
end
end
I get an error when I try to compile this function: invalid argument for unary operator ^, expected an existing variable, got: ^task.ref()
I sense this is an illegal operation and I’m going to need to assign the struct key values to variable prior to matching, I just want to make sure. This would be an awesome feature if it worked.
Thanks!