Is there a runtime overhead if I use this sort of decoration?
get_next_state(_SPid=undefined, _NextPort=undefined) ->
stop;
Is there a runtime overhead if I use this sort of decoration?
get_next_state(_SPid=undefined, _NextPort=undefined) ->
stop;
No, there is no overhead. You can check if you make a dummy module with and without the decoration and compile it using the 'S' flag.
It's not a decoration, but an alias. It allows to you both have your cake and eat it. You can both have a pattern which is matched as usual and have a variable which is bound to the corresponding part of the term. So in
foo([a,b,c|_]=List) -> ... .
will match a list with the first 3 elements a
,b
and c
and bind List
to the whole list. It can be used anywhere in a pattern and is useful as it can save you from rebuilding the term. Using it as a form of comment is no problem but I honestly don't see the point of it, it just clutters up the head. I would write your example as
%% get_next_state(SPid, NextPort) -> ... .
get_next_state(undefined, undefined) ->
stop;