Re: [q-lang-users] RFC: Conditional syntax
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-06-01 08:11:46
|
Patrick Albuquerque wrote: > abs X = choose (X<0, -X; true, X); Keith Trenton wrote: > abs X = branch (X<0, -X; true, X); I like those. "choose" seems to be a bit too generic, though, and thus it might collide with user definitions (I actually have a few programs where I use that for nondeterministic choice). That also rules out "test", I guess. But "branch" seems to be ok. Keith and Brian, thanks for your other suggestions, too. But those abbreviations sound an awful lot like assembler opcodes... ;-) Ok, here is what we got so far: 1. cop, coop, co_op 2. mbr 3. choose 4. branch Here are some more I "invented" myself: 5. pick 6. check 7. test 8. query 9. guard BTW, in the library of the Icon language, Dijkstra-style guarded statements are named if_fi, but this also looks a bit clumsy. Or how about: 10. ifcond This is sufficiently similar to cond, not likely to collide with user definitions, and we already have ifelse for the two-way conditional. Of course, the question is whether we actually need this construct at all, since one could always use an if-then-else if-... chain like in other programming languages: sign X = if X<0 then -X else if X>0 then X else X; Hmm ... actually, that looks quite messy when compared to: sign X = ifcond (X<0, -X; X>0, X; true, 0); I can understand now why Lisp programmers love their cond. ;-) Comments? Other suggestions? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |