Tango Conference 2008 - MiniD talk by by Jarrett Billingsley. [~OT]
bearophile
bearophileHUGS at lycos.com
Sat Oct 11 06:56:07 PDT 2008
ore-sama Wrote:
> > This:
> > global x, y, z = freep() // they are 1, 2, 3
>
> this also seems dangerous to me.
> Some language has syntax
> (x, y, z) = freep()
To answer I have to go partially OT. In Python you can put () around tuples, but 99% of the times they are optional, so this syntax is accepted and Python programmers often add those () to improve clarity:
(x, y, z) = freep()
Or to destructure the result (here freep2 returns a generic iterable pair inside another pair):
((x, y), z) = freep2()
I don't like the syntax Python3 uses for tuples, I'd like them to be compulsively enclosed by symbols, like python lists (arrays) and like all collection literals in Fortress.
For example the bitwise operations may become named AND OR XOR NOT, that in Python code aren't much common (currently and, not, or are the boolean operators), freeing | to to denote tuples (and freeing other symbols):
x, y, z = freep()
((x, y), z) = freep2()
z = (!x & y) | (z & !w)
==>
|x, y, z| = freep()
||x, y|, z| = freep2()
z = (NOT x AND y) OR (z AND NOT w)
(I don't like that synax too much, anyway).
Fortress uses pairs of symbols to encose some of its collections:
{x, y, z}
{x: y, z: w}
{|x: y, z: w|}
(|x, y, x|)
{|x, y, z|}
[|x, y, z|]
... etc
Bye,
bearophile
More information about the Digitalmars-d-announce
mailing list