SV: not quite a bug, but...

Robert Virding <>
Wed Mar 27 09:19:04 CET 2002


----- Ursprungligt meddelande ----- 
Från: "Vlad Dumitrescu" <>
Till: <>
Skickat: den 21 mars 2002 10:55
Ämne: RE: not quite a bug, but...


> >From: Sean Hinde <>
> > > The faulty code was:
> > > case NewTime = 0 of
> > > true -> ...
> > > false ->
> > > end,
> >Some people recommend getting into the habit of putting the constant first
> >so:
> >  case 0 = NewTime of
> >  true -> ...
> >  false ->
> >  end,
> 
> That is a good suggestion, I used it in C but it was a loooong time ago so I 
> did forgot about it. :-)
> 
> However, I am only debugging old code, so it's not very useful then.
> 
> And also using a match as a case expression is not wise in any case, and I 
> think erl_lint should be able to warn about that, the way C-lint does.

I don't want to be difficult here (:-), but it is useful. You may actually want to keep
the value of the expression for later use and not just within the case where
you can use aliases. It is, alas, a property of Erlang's variable scoping that you
can bind a variable anywhere.

Robert





More information about the erlang-questions mailing list