commabominations
- Posted by George Henry <ghenryca at hotmail.com> Jan 20, 2001
- 433 views
This came out in a recent personal message. Thought I'd air it to the list as well. In natural language, commas are used to separate items in a list. Fine and dandy. In natural language we do not frequently modify lists that look like this: { A, B, C } to look like this: { A, B, C, D } or this: { A, B }. Not as frequently as we do in programming, anyway. Now suppose we did. We might be tempted, in order to avoid juggling commas, to end all our lists with ", etc." The point is this: The way Euphoria and most other languages treat/use/handle commas leads to syntactic abominations, such as I have seen in the latest win32lib, and (I report unhappily) have even adopted myself: <excerpt from win32lib_full.ew> integer riCleanUp -- the "clean up" routine , ri_getClientRect -- routine_id for getClientRect() , riPause -- routine_id for Pause Key processing , riBreak -- routine_id for Break Key processing </excerpt> This should not happen, should not be necessary. Commas are not used that way in natural language. It's ugly. Okay, then what's a reasonable solution? I have actually seen a C compiler that let you do this, in initializers: { A, B, C, } which is using the comma more as a terminator than as a separator, or it is blurring the terminator/separator distinction. Either way, I'd like to see something of the sort allowed by Euphoria (or any language I use on a regular basis). Pascal used the semicolon as a separator between statements, but did not complain of "syntax error" if you used one just prior to an "end." Same idea. How about just a generic keyword "end" that means nothing, but lets you end a list with ", end" - as in: constant alpha=120, beta=26, gamma=1382, end integer riCleanUp, -- the "clean up" routine ri_getClientRect, -- routine_id for getClientRect() riPause, -- routine_id for Pause Key processing riBreak, -- routine_id for Break Key processing end so you can add to or subtract from the list without adding and deleting commas, and without sticking the commas in front of the identifiers - thus reducing readability (similarity to natural language)? You don't have to break any existing code to implement this. ", end" would be strictly optional at the end of a list of constants or variable names. (I'd also like to see a trailing comma before the closing curly brace tolerated in a sequence.) This may seem a small thing, but "the devil's in the details," and that little comma has horns and a tail, as far as I'm concerned. What do y'all think? George _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com