[erlang-questions] Reassigning variables

Camille Troillard <>
Thu Mar 19 13:54:39 CET 2009


Hi everyone,

On Thu, Mar 19, 2009 at 1:22 PM, mats cronqvist <> wrote:

> my_lc_tq(Line, E, [{generate,Lg,P,G}|Qs], Mc, St) ->
>  all(s(qs,st,{Qs,St}),
>       [fun(X)->s(X,gs,qs1,       splitwith(fun is_guard_test/1,f(X,qs)))end
>       ,fun(X)->s(X,name,st,      new_fun_name("lc", f(X,St)))end
>       ,fun(X)->s(X,head,st,      new_var(f(X,st)))end
>       ,fun(X)->s(X,tname,st,     new_var_name(f(X,st)))end
>       ,fun(X)->s(X,la,lanno,tail,my_lanno(Line,f(X,tname),f(X,st)))end
>       ,fun(X)->s(X,arg,st,       new_var(f(X,st)))end
>       ,fun(X)->s(X,nc,'',st,
> my_expr(Lg,f(X,name),f(X,tname),f(X,st)))end
>       ,fun(X)->s(X,guardc,st,    lc_guard_tests(f(X,gs),f(X,st)))end
>       ,fun(X)->s(X,lc,lps,st,    lc_tq(Line,E,f(X,qs),f(X,nc),f(X,st)))end
>       ,fun(X)->s(X,pc,st,        list_gen_pattern(P,Line,f(X,st)))end
>       ,fun(X)->s(X,gc,gps,st,    safe(G,f(X,st)))end
>
> ,fun(X)->s(X,fc,function_clause([f(X,arg)],f(X,la),{f(X,name),1}))end]).


[...]

> -define(S(X,Ts,Xp), fun(X)->s(X,Ts,Xp)end).
>
> my_lc_tq(Line, E, [{generate,Lg,P,G}|Qs], Mc, St) ->
>  all(s(qs,st,{Qs,St}),
>       [?S(X,{gs,qs1},     splitwith(fun is_guard_test/1,f(X,qs)))
>       ,?S(X,{name,st},    new_fun_name("lc", f(X,St)))
>       ,?S(X,{head,st},    new_var(f(X,st)))
>       ,?S(X,{tname,st},   new_var_name(f(X,st)))
>       ,?S(X,{la,lan,tail},my_lanno(Line,f(X,tname),f(X,st)))
>       ,?S(X,{arg,st},     new_var(f(X,st)))
>       ,?S(X,{nc,'',st},   my_expr(Lg,f(X,name),f(X,tname),f(X,st)))
>       ,?S(X,{guardc,st},  lc_guard_tests(f(X,gs),f(X,st)))
>       ,?S(X,{lc,lps,st},  lc_tq(Line,E,f(X,qs),f(X,nc),f(X,st)))
>       ,?S(X,{pc,st},      list_gen_pattern(P,Line,f(X,st)))
>       ,?S(X,{gc,gps,st},  safe(G,f(X,st)))
>       ,?S(X,{fc},
> function_clause([f(X,arg)],f(X,la),{f(X,name),1}))]).



I find interesting (or curious) how people want to reach aesthetically
pleasant code to read.  No offense, really, it's just that I don't think it
leads anywhere useful.
We saw from Richard O'Keefe at the beginning of the discussion that
assignments were not that common in Erlang, and that destructive ones were
even less common.  In my opinion, while this is interesting in a "code
beauty" aspect, it serves no useful purpose to overload the code with
macros, helper functions, and other language candies that just try to solve
a specific problem.

Just my two cents …

Best,
Cam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090319/d729d322/attachment.html>


More information about the erlang-questions mailing list