[Python-ideas] Syntax idea for 2D lists\arrays

Mikhail V mikhailwas at gmail.com
Thu Mar 15 12:55:05 EDT 2018


On Thu, Mar 15, 2018 at 6:15 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Thu, Mar 15, 2018 at 01:32:35AM +0100, Mikhail V wrote:
>

> Using spaces to separate items has the fatal flaw that it cannot
> distinguish
>
>     x - y 0  # two items, the expression `x - y` and the integer 0
>
> from:
>
>    x - y 0  # three items, `x`, `-y`, and 0
>

When you say "it cannot distinguish" what is "it"?
you mean current parser can't separate items due to the
allowed unary negation operator?
Well then it is not like I would parse the table,
for this case my parsing rule would be:

x - y 0 -> [x - y, 0]
x-y     -> [x - y, 0]
x -y  0 -> [x, -y, 0]

That's in case I use same char for unary negation and minus operator
(which I find rather inconvinient for parsing).


Mikhail


More information about the Python-ideas mailing list