[erlang-questions] The compiler "eats" structures which are not separated by commas
ok@REDACTED
ok@REDACTED
Mon Apr 23 05:38:33 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.
Indeed. But Erlang is not a language with type inference.
If I want Haskell, Clean, F#, O'CAML, ML, or Mercury,
I know where to find them.
> 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.
But a prefix # being unintentionally taken as an infix #
is precisely what this thread is about.
We could have a rule that says "take all the
-record(name, { ..., field ... })
declarations that are visible in the current module,
and for each field name, construct a function
field(#rec1{...,field=X,...}) -> X;
...
field(#recn(...,field=X,...}) -> X.
"
so that instead of Foo#rec.bar we could use a plain
bar(Foo), which is much better syntax for a functional
language than 'get' prefixes. And the type language
used by dialyzer could handle this.
It's best not to tinker any more with records.
More information about the erlang-questions
mailing list