On 21/06/2013, at 3:41 PM, Jonathan Leivent wrote:Well, for one thing, it might be an idea to rip the branching structureout of the receive.Yeah, sure. But, I'm forced to do that, instead of deciding to do it if and when it's a good way to modularize the code.
Someone has a blog where they looked at how to write Erlang code
so that it's _obviously_ right, and ripping things into smaller
pieces was part of it. If you can't name it, you don't understand it.
I do repeat that more than 40 years after meeting formal logic,
I love logic, but am extremely suspicious of Boolean expressions in
functional languages. Most Boolean-valued functions that have been
discussed in this mailing list turned out to be things that would be
better conceived some other way (like a Haskell Maybe or Either or
something with more than two possibilities).
In my implementation I decided to annotate the Core Erlang cases to which a cond is compiled with the atom "cond_case".
--
Anthony Ramine
Just an historical curiosity. Before we had 'if' and we needed something if-ish this is exactly what we would do. We would use a case with a trivial expression and clause patterns which would always match and all the work was done in the guards. It looked so horrific that we added 'if'.
Robert
I added this to LFE and it is quite useful.
Something like this was discussed a while back as a general extension to guards but I can't remember the syntax. It would only allow approved guard expressions.
Robert
----- Original Message -----
> From: "Anthony Ramine" <n.o...@gmail.com>
> To: "Richard A. O'Keefe" <o...@cs.otago.ac.nz>
> Cc: erlang-q...@erlang.org
> Sent: Monday, 8 July, 2013 10:35:25 AM
> Subject: Re: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially
>
case false of
X -> X;
_ ->
case true of
X -> true
end
end
In this case there would be no badmatch and X would be exported. If the match fails the next clause tried.
If users explicitly use '=' deep in their expressions then they are on their own, cond only handles at the top-level. Even with this limitation cond would be useful.
Robert
----- Original Message -----
> From: "Anthony Ramine" <n.o...@gmail.com>
> To: "Richard Carlsson" <carlsson...@gmail.com>
> Cc: "Jonathan Leivent" <jlei...@comcast.net>, erlang-q...@erlang.org
> Sent: Monday, 16 December, 2013 12:00:35 PM
> Subject: Re: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially
>