News for hackers. Stuff that matters.
Re:Go 1.18 by sriram_malhar on Wednesday March 16, 2022 @12:07AM (#30695211)
Erlang doesn't have priorities natively, does it? As far as I am aware, there is a standard pattern to do it, like this:

    receive
        {high_p, Message} ->
            process_high(Message)
    after 0 ->
            receive
                {high_p, Message} ->
                    process_high(Message);
                {low_p, Message} ->
                    process_low(Message)
            end
    end 
The Go equivalent can be done with different channels for priorities and similarly nested selects, as I am sure you are aware.
Re:Go 1.18 by ergl on Wednesday March 16, 2022 @10:32AM (#30699304)
Erlang has selective receive, meaning it will go through all your receive branches in order, until one matches.

With this code:

    receive
        {high_p, Message} ->
            process_high(Message);
        {low_p, Message} ->
            process_low(Message)
    end
if the process has one high_p message and a low_p message, the high_p message will be processed first.
Re:Go 1.18 by fpoling on Wednesday March 16, 2022 @02:29AM (#30695916)
Hm, is this pattern the best Erlang has and VM does not optimize it to avoid the need to lock the queue twice? If so then you are right double-select is equivalent even if it is rather messier in Go then in Erlang with the need to provide 2 channels.