|
|
| Author |
Message |
|
| Guest |
Posted: Sat Mar 06, 2010 9:26 am |
|
|
|
Guest
|
In most languages, one is typically allowed to use parentheses in most
places.
Indeed, in Erlang one can write all these below:
1> lists:last([1,2,3]).
3
2> lists:last(([1,2,3])).
3
3> lists:(last)([1,2,3]).
3
4> (lists):last([1,2,3]).
3
5> (lists):(last)(([1,2,3])).
3
The same is not allowed in the constituents of fun expressions.
One is not allowed to put parentheses in any component of:
fun M:F/A
For example, fun (lists):last/1 results in a syntax error.
I think this is inconsistent.
Why do I want to add parentheses around fun constituents you may ask?
A tidier user complained that tidier's suggestion to transform
spawn_link(?MODULE, rec, [])
to
spawn_link(fun (?MODULE):rec/0)
resulted in a syntax error. Arguably, (?MODULE) expresses the grouping
of ? with MODULE in ?MODULE:rec/0 better than without parentheses.
Moreover, apparently the parser insists that M and F are *statically*
atoms (and A integer) so one cannot write:
M = lists,
F = fun M:last/1
I can possibly understand why A has to be statically known, but why
should M and F also be? I thought, perhaps wrongly, that the sequence
above is anyway transformed to its equivalent one:
M = lists,
F = fun (_L) -> M:last(_L) end.
Kostis
________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Sun Mar 07, 2010 11:32 am |
|
|
|
Guest
|
2010/3/6 Kostis Sagonas <kostis@cs.ntua.gr>:
> A tidier user complained that tidier's suggestion to transform
>
> spawn_link(?MODULE, rec, [])
> to
> spawn_link(fun (?MODULE):rec/0)
>
> resulted in a syntax error. Arguably, (?MODULE) expresses the grouping of ?
> with MODULE in ?MODULE:rec/0 better than without parentheses.
>
>
> Moreover, apparently the parser insists that M and F are *statically* atoms
> (and A integer) so one cannot write:
>
> M = lists,
> F = fun M:last/1
>
There is an EEP that propose that variables should be allowed
in external funs:
http://www.erlang.org/eeps/eep-0023.html
As far as I can remember, we have approved that EEP. We have
not implemented it because of lack of time (not that it is very
difficult, just that other things had higher priority).
To also allow arbitrary expressions would be fine for me,
unless they would cause some ambiguity or other
problem in erl_parse.
--
Björn Gustavsson, Erlang/OTP, Ericsson AB
________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org
Post received from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|