Contribution to the record- and write-your-own-guards debates
Fredrik Linder
fredrik.linder@REDACTED
Thu Jul 10 16:01:24 CEST 2003
> From: Luke Gorrie [mailto:luke@REDACTED]
>
> "Fredrik Linder" <fredrik.linder@REDACTED> writes:
>
> > I often find myself forced to unnecessary nesting in my code
> due to the fact
> > that I am disallowed to write my own guards.
> >
> > I usually write ADTs to conceil my data bearers, which is a
> practis I find
> > very good since it nicely divides my code into good working bricks. But
> > since I am disallowed to write my own guard-functions I cannot match
> > directly on those ADTs, but have to explicitly extract the
> information and
> > then match on these values instead.
>
> This particular problem could be helped by the rumoured "cond"
> construct. It's like 'if', but uses arbitrary expressions for the
> tests instead of more restricted guard expressions.
>
> I reckon 'cond' would/will be very nice :-)
The 'cond' construct would indeed be very nice to have. And to some extent
it would lessen the nesting. However, I would still not be able to select on
a function-clause level which I sometimes find desireable.
A 'cond' construct would definitely be a step in the right direction though.
:-)
Sincerely
/Fredrik
More information about the erlang-questions
mailing list