Re: [q-lang-users] A proposal to adopt Python tuple syntax
Brought to you by:
agraef
From: John.Cowan <jc...@re...> - 2005-06-21 20:08:35
|
Albert Graef scripsit: > Identifying 1-tuples with their single members would certainly be the > most elegant solution, but unfortunately you can't do that in a language > where tuples are defined in a recursive fashion, so that you can > conveniently write generic functions operating on tuples of arbitrary sizes. I agree. > Why would you want to write something like ((A-B)) to mean (A-B) anyway? Speaking as a human programmer, I wouldn't; speaking as someone who writes code that generates code, I have found redundant generation of parens to make my life simpler, secure in the knowledge that the next stage will discard them. > The (-99) is _not_ a 1-tuple simply because -X is not an atomic > expression. I guess that, as someone who knows more programming languages than I can easily enumerate, I don't want to have to remember whether -99 is a primary or an application; different languages take different views of it. (Obviously -X is an always an application.) > But I can't help it, I think that this syntax is just plain ugly. De gustibus. > Actually, I found that the most common problem related to Q's 1-tuple > syntax is that seasoned C or Pascal programmers write something like > foo(99) instead of foo 99, because it's what they are used to. Indeed, and in ML foo(99) works just fine, since there are no 1-tuples and the 0-tuple syntax means something else. > it's possible to relearn this, and if you want to learn a modern-style > FP language, you have to learn the curried function application style > anyway, so I don't see a real problem with this. I think it is a real problem. > Other opinions? I've thought about this problem for quite some time, but > maybe there's another, prettier solution I missed? One approach is to have prefix syntax to mark tuples, like the #(...) of Scheme or Smalltalk (but not implying that the tuple members are literals). This would be mandatory for 1-tuples and optional for all other tuples. -- John Cowan www.ccil.org/~cowan www.reutershealth.com jc...@re... In might the Feanorians / that swore the unforgotten oath brought war into Arvernien / with burning and with broken troth. and Elwing from her fastness dim / then cast her in the waters wide, but like a mew was swiftly borne, / uplifted o'er the roaring tide. --the Earendillinwe |