Re: [q-lang-users] A proposal to adopt Python tuple syntax
Brought to you by:
agraef
From: Tim H. <q...@st...> - 2005-06-24 09:31:11
|
Albert Graef <Dr....@t-...> writes: [snip] > > I think it is a real problem. > > Ok, point taken. To summarize: So far the most problematic usability issues > related to Q's 1-tuples seem to be the following: > > - You have to remember to write foo X, not foo(X), unless you really want > the argument to be a 1-tuple. > > - You have to remember that -X is not a primary, so (-X) is not a 1-tuple, > but ((-X)) is. > > - Superflous extra parentheses around non-primaries can sometimes be > useful, especially in code generation. > > OTOH, I'm arguing that Q's way to write 1-tuples avoids the ugliness of a > special notation like (X,). But I see the point that the current notation > is a possible source of confusion. > > How does everyone else here feel about this? If you have any anecdotal > evidence where you have been bitten by Q's 1-tuples, please speak up! I'm > not going to make a change like this light-heartedly, as it might be a > big inconvenience for some (it'll be one for me ;-). But if everyone > agrees that this must be changed, then it ought to change asap, before > everybody and his brother starts using Q. ;-) TBH I don't have a major problem with the status quo, but then I'm only a small-time allegedly-human not-much-of-a-programmer... :) I've not really been bitten by it except as a result of programmer error - I might get temporarily confused whether I want to write map (lambda (N) (N+1)) [1..10] ^ ^ or not (and in this case, not), but that's it. > > 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. > > No, then I'd favour the (X,) solution. Having thought about this a little > more, trailing commas could be allowed in all tuples and lists (that's > sometimes useful, anyway), and it would just be the 1-tuple case where > it's mandatory. Does that sound like a reasonable solution? Not awake yet: would (-1,) be well-defined this way? What about ((-1),) and ((-1,),) ? Would I want to remember all these permutations? At first blush, I don't mind (and might even favour) having a different syntax for forcing something to be a tuple - say use [] for lists, () for parenthetical purposes *only*, which leaves <> or {} for tuples? ~Tim -- <http://spodzone.org.uk/> |