[erlang-questions] if-elseif-else trick
Richard O'Keefe
raoknz@REDACTED
Thu Feb 21 08:28:09 CET 2019
Everyone wants to be a language designer.
If we're lucky, we get Elixir or LFE.
Usually we get a bit of fiddling around
the edges, which is a good thing if it
lets us express something more clearly and
with fewer mistakes than before. Things
like el/=se just increase the burden on
the reader. I for one would rather read
for (;;) { ... }
than
#define FOREVER for (;;) in some header
...
FOREVER { ... }
This whole thing with 'if' has simmered along
for years. There was a proposal for 'cond'.
Perhaps it's time to dust it off and make it
an official part of the language. Or perhaps
not: there's a message in my mailbox from a
software engineering list with the title "Try programming without 'if'
statements" which I
have not read yet...
Seriously, though, when you find yourself
struggling with syntax in Erlang, you probably
need to break your code up into smaller
functions.
On Thu, 21 Feb 2019 at 18:43, <zxq9@REDACTED> wrote:
> On 2019年2月20日水曜日 8時16分41秒 JST Donald Steven wrote:
> > I don't think:
> >
> > -define(true,else).
> >
> > yielding ?else ->
> >
> > is much of an improvement.
> >
> > Why not just allow the keyword else as a synonym for true when its usage
> > would improve the readability? (At times, "true" reminds me of trying to
> > read (SAT-like) sentences like: "Whenever he couldn't think of whether
> > or not he might have forgotten to turn the light on or off, or not.")
>
> Why not just use `if` where it fits semantically?
>
> These periodic discussions of how to use silly cheats to avoid proper
> code layout always puzzle me.
>
> -Craig
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190221/e9af8dca/attachment.htm>
More information about the erlang-questions
mailing list