erl_id_trans.erl

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

erl_id_trans.erl

Thomas Lange

Bumped into the following:

in erl_id_trans.erl
the function record_updates

record_updates([{record_field,Lf,{atom,La,F},Val0}|Us]) ->
    Val1 = expr(Val0),
    [{record_field,Lf,{atom,La,F},Val0}|record_updates(Us)];
record_updates([]) -> [].

should read Val1 instead of Val0 in the third line, i.e:

record_updates([{record_field,Lf,{atom,La,F},Val0}|Us]) ->
    Val1 = expr(Val0),
    [{record_field,Lf,{atom,La,F},Val1}|record_updates(Us)];
record_updates([]) -> [].



Regards
Thomas


---
Thomas Arts
Computer Science Lab


Reply | Threaded
Open this post in threaded view
|

erl_id_trans.erl

Chris Pressey
Thomas Arts wrote:
> Bumped into the following:
> in erl_id_trans.erl
> the function record_updates
> record_updates([{record_field,Lf,{atom,La,F},Val0}|Us]) ->
>     Val1 = expr(Val0),
>     [{record_field,Lf,{atom,La,F},Val0}|record_updates(Us)];
> record_updates([]) -> [].
> should read Val1 instead of Val0 in the third line, i.e:

Perhaps some future version of the compiler could warn against unused
variable bindings?  This is a feature that is in Perl, but I find it
somewhat annoying to me there (as it does not match my
imperative/procedural programming style, where mutable variables can be
updated arbitrarily anyway.)

But in Erlang is would actually make a lot more sense and I think I
would like it a lot.

_chris

--
"Ten short days ago all I could look forward to was a dead-end job as a
engineer.  Now I have a promising future and make really big Zorkmids."
Chris Pressey, Cat's Eye Technologies, http://www.catseye.mb.ca/
Esoteric Topics Mailing List: http://www.catseye.mb.ca/list.html


Reply | Threaded
Open this post in threaded view
|

erl_id_trans.erl

Robert Virding-4
Chris Pressey <cpressey> writes:
>
>Perhaps some future version of the compiler could warn against unused
>variable bindings?  This is a feature that is in Perl, but I find it
>somewhat annoying to me there (as it does not match my
>imperative/procedural programming style, where mutable variables can be
>updated arbitrarily anyway.)
>
>But in Erlang is would actually make a lot more sense and I think I
>would like it a lot.

This already exists.  If you give the option 'warn_unused_vars' to the
compiler it will list all variables that are never used EXCEPT those
whose name starts with "_", e.g. _Foo or _bar.  The rationale behind
this is that it gives you a way of using meaningful names instead of
"_" for variables you neve use.

I personally don't like this option as it does not suit my style of
using variable names.  For an example of what can happen with code not
tuned to this option recompile erl_lint.erl.

Some other useful checking options are 'warn_unused_imports' and
'warn_format' for checking imports and calls to io:fwrite/format.  The
last can also take different values {warn_format,0-3} where 3 checks
the most.

        Robert
--
Robert Virding                          Tel: +46 (0)8 692 22 12
Bluetail AB                             Email: rv
Hantverkargatan 78                      WWW: http://www.bluetail.com/~rv
SE-112 38 Stockholm, SWEDEN
"Folk s?ger att jag inte bryr mig om n?gonting, men det skiter jag i".