[erlang-questions] The compiler "eats" structures which are not separated by commas

Jan Burse janburse@REDACTED
Mon Apr 23 04:28:58 CEST 2012


Richard O'Keefe schrieb:
> 	Expr#Name{Field1 := Expr1, ..., Fieldn := Exprn}
> 	                 ^                     ^
You still have the clutter of the Name (= RecordType),
which a language with type inference doesn't need.

How to deal with the reflective #Name.Field I have no
clue yet. If there is not enough context where these
expressions are used, then no type inference is possible
and the name must be qualified.

> After all, there is nothing that stops someone using a
> record whose name begins with 'set' or 'get'.

This shouldn't pose any problems. You can use the same
logic that currently distinguishes in Erlang a "#name"
from a "Expr #name" to choose between record creation
and setter (better call it updater I guess, although updater
also suggest a side effect, but a setter here has signature
RecordType x Type -> RecordType, so it is functional).

I guess it is a prefix '#' versus infix '#' thing to
detect creation versus setter, but  I don't know enough
about the Erlang parser to be sure.

Bye



More information about the erlang-questions mailing list