 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New wrote:
> Not in Python. The cosntructor for a 2-tuple is ,
> No parens needed. Figure *that* one out. :-)
This isn't *quite* correct, since a single comma can construct either a
1-tuple or a 2-tuple depending on how it's used:
"foo", --> 1-tuple
"foo",bar --> 2-tuple
It's probably best to view the tuple constructor as a comma, which can
be used as a binary operator or as a unary postfix operator (ignoring
3-n-tuples of course).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Kevin Wampler wrote:
> This isn't *quite* correct, since a single comma can construct either a
> 1-tuple or a 2-tuple depending on how it's used:
Right. That's the weirdness of it, including the fact that there are other
uses for the comma (like between function arguments) as well.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New wrote:
> Kevin Wampler wrote:
>> This isn't *quite* correct, since a single comma can construct either
>> a 1-tuple or a 2-tuple depending on how it's used:
>
> Right. That's the weirdness of it, including the fact that there are
> other uses for the comma (like between function arguments) as well.
This seems to be (for better or worse) sort of the python philosophy of
language design, and as far as I can tell they at least seem to be
consistent about when they are inconsistent. It reminds me of how they
parse expressions with comparison operators specially so you can type
"if a < b < c:" and have it work. It's simple to understand on a
"human" level, but it's definitely a special case in how the syntax is
parsed.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Kevin Wampler wrote:
> "if a < b < c:" and have it work.
Yeah. I really don't understand why more languages don't support this sort
of thing. I mean, even COBOL got *that* right. :-)
> It's simple to understand on a
> "human" level, but it's definitely a special case in how the syntax is
> parsed.
Yeah, it's just weird to see an expression like
x = y,
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New wrote:
> Kevin Wampler wrote:
>> "if a < b < c:" and have it work.
>
> Yeah. I really don't understand why more languages don't support this
> sort of thing. I mean, even COBOL got *that* right. :-)
BUUUURN!
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> Common in a lot of other languages like SQL and Ada. FWIW.
>> I know Eiffel uses it. But then, Eiffel is weird.
>
> That too. All the "readable" languages tend to use it, because it's how
> you offset comments in English -- that is, if you have a comment to make.
TeX uses "--" to mean an N-dash, and "---" to mean an M-dash [which is
the kind that ought to be used for seperating a comment].
Haskell being what it is, you can *probably* activate Unicode mode and
use the actual Unicode character for an M-dash.
(I don't know if you know this, but Haskell can actually be written with
Unicode symbols like arrays and stuff in place of the cheese ASCII-art
everybody always uses...)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 wrote:
> (I don't know if you know this, but Haskell can actually be written with
> Unicode symbols like arrays and stuff in place of the cheese ASCII-art
> everybody always uses...)
And I'm pretty sure APL has its own block of characters in unicode as well.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |