Matching elements of records

Bengt Kleberg bengt.kleberg@REDACTED
Thu Oct 28 10:51:54 CEST 2004


Ulf Wiger (AL/EAB) wrote:
...deleted
> 
> ALWAYS WRITE PATTERN ALIASES AS <PATTERN>=<VAR>!!

i have lived under the assumption that

-record( rec, {a, b=b_default}).


func1( #rec{a=a} = Arg ) ->
	Arg.

func2( Arg = #rec{a=a} ) ->
	Arg.

would return different Arg. like this:

func1( #rec{a=a, b=b} ) => #rec{a=a, b=b}

func2( #rec{a=a, b=b} ) => #rec{a=a, b=b_default}

this is not the case, it was all a mistake on my part.
however, perhaps the possiblity of misunderstanding is a good reason to 
avoid func2() style pattern aliases?


bengt



More information about the erlang-questions mailing list