[q-lang-users] A proposal to adopt Python tuple syntax
Brought to you by:
agraef
From: John.Cowan <jc...@re...> - 2005-06-13 21:47:33
|
Representing tuples as parenthesized expressions separated by commas is a Good Thing, but 1-tuples (in languages where they are not the same as non-tuples) are always a syntactic wart. (wart: n. A small, crocky feature that sticks out of an otherwise clean design. Something conspicuous for localized ugliness, especially a special-case exception to a general rule.) The current Q solution to this wart is to interpret a parenthesized expression as a 1-tuple only in certain circumstances: as noted in the manual, "(99)" is a tuple but "(-99)" is not. I propose that the Python syntax be adopted instead. A Python tuple is expressed in the same way as a Q one, except that there may be a terminating comma after the last expression. In particular, "(expr,)" is unambiguously a 1-tuple, allowing "(expr)" and "((expr))" to be merely parenthesized expressions. The Python printer prints a terminating comma only for 1-tuples. This syntax could be permitted in an early release, and then the old interpretation of excess parentheses deprecated later on. -- John Cowan www.ccil.org/~cowan www.reutershealth.com jc...@re... All "isms" should be "wasms". --Abbie |