forget

Joe Armstrong joe@REDACTED
Mon Jun 3 16:22:07 CEST 2002


On Wed, 29 May 2002, C.Reinke wrote:

> > 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)?

I think you have invented monads AND dataflow variables  :-)

This is *very* difficult to implement :-)

suppose  foo(£X) means create an unbound variable and call foo

then we say

	foo(X) ->
	   abc ! X,
	   def ! X.

Then we send the unbound variable to two *different* processes - imagine
they are on different machines (just to make it more fun).

They now both try to bind X at the same time :-) - one should succeed
the other should fail - and it should work in the presence of errors ...

<< this is what Oz does (see http://www.mozart-oz.org/) >>

/Joe






> 
> Claus
> 
> 




More information about the erlang-questions mailing list