Choking on Syntactic Sugar

Chris Pressey <>
Wed Mar 14 04:28:57 CET 2001


Robert Virding wrote:
> Klacke <> writes:
> >Yeah, if you feel the ++ operator is weird, take a look at the
> >-- operator which is also described in the same doc, it's really
> >weird. Not useless though.
> -- is a joke.

I did laugh the first time I saw it, but I've since found it
unexpectedly convenient!  :-)

> I had planned to do something with ** and // as well but never
> got around to it.  Any suggestions? :-)

** could do lists:duplicate/2 (perhaps with argument order reversed)
akin to Perl's 'x' operator.  e.g: io:fwrite("~s", ["-" ** 72]).

// could do lists:nth/2 (again, perhaps with reversed arguments)
somewhat akin to array-indexing other languages.  e.g: [foo,bar,baz] //
2.

It might be nice if all of these (++, --, **, //) worked the same on
tuples.

Also, it would be (IMO) very cool to make <- meaningful outside of a
list-comprehension (in a guard and/or expression).  X <- [1,2,3] would
evaluate to true if X == 1 or X == 2 or X == 3.  It would also be great
if this could be expanded at compile-time for constant lists (although I
realize that might get a little hairy.)

_chris

-- 
"Ten short days ago all I could look forward to was a dead-end job as a
engineer.  Now I have a promising future and make really big Zorkmids."
Chris Pressey, Cat's Eye Technologies, http://www.catseye.mb.ca/
Esoteric Topics Mailing List: http://www.catseye.mb.ca/list.html



More information about the erlang-questions mailing list