[erlang-questions] Warning: the call to node/0 has no effect

Monk Boy boyofmonk@REDACTED
Fri May 10 13:23:16 CEST 2019


thanks,I got it!!!

On Fri, May 10, 2019 at 7:20 PM Björn Gustavsson <bjorn@REDACTED> wrote:

> On Fri, May 10, 2019 at 12:00 PM Monk Boy <boyofmonk@REDACTED> wrote:
> >
> > Hi
> >
> > When compile the code , I got a message:
> >
> > ```
> > src/http_qmonitor.erl:58: Warning: the call to node/0 has no effect
> > ```
> >
> > the code is
> >
> > ```
> >     N = length([node()|nodes()]),
> > ```
> >
>
> Internally, the compiler does a series rewrites. First we have:
>
> V1 = node(),
> V2 = nodes(),
> N = length([V1|V2])
>
> Then the compiler rewrites the code like so:
>
> V1 = node(),
> V2 = nodes(),
> N = length(V2) + 1
>
> since the length of the list does not depend on the value value of V1.
>
> It then notices that V1 is no longer used, issues a warning and
> rewrites the code like so:
>
> V2 = nodes(),
> N = length(V2) + 1
>
> /Björn
>
> --
> Björn Gustavsson, Erlang/OTP, Ericsson AB
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190510/93dcef64/attachment.htm>


More information about the erlang-questions mailing list