forget

C.Reinke C.Reinke@REDACTED
Wed May 29 18:10:30 CEST 2002


> foo(Value) ->
> 	Value2 = bar(Value),
> 	Value3 = baz(Value2),
> 	Value4 = zab(Value3),
> 	{ok, Value4}.

DCGs and other preprocessing have been suggested, but
in contrast to Prolog, Erlang is higher order, so why not:

do (Value,[])    -> {ok,Value};
do (Value,[F|Fs]) -> V = F(Value), do(V,Fs).

foo(Value) ->
  do (Value,[
     fun bar/1,
     fun baz/1,
     fun zab/1
  ]).

A more lightweight syntax for funs would make that a lot nicer, of
course, and "do" might not be the most suggestive name, but it
avoids names for intermediates as well as language extensions..

Btw, why can't variables be passed unbound to functions (that
would make more complex utilities easy)?

Claus




More information about the erlang-questions mailing list