On Sat, Jun 16, 2018 at 4:44 AM, Cameron Simpson <c...@cskk.id.au> wrote:
> On 16Jun2018 02:42, Mikhail V <mikhail...@gmail.com> wrote:
>>

> Some things _should_ be syntax errors. Particularly things which may be
> typing errors. Suppose I'd meant to type:
>
>  L[0] = item
>
> Silent breakage, requiring runtime debugging.

Not sure that it's different from any other situation:
e.g. if by mistake I will write:

    L[i+1]   instead of
    L[i+2]

Visual difference between

    L[] =
    L[1] =

is big enough to reduce the typing error. But maybe I did not
understand your example case.
FWIW in general, claims about possible typing errors by
introducing this or that syntax are speculative.
Main source of typos usually is high similarity of spellings and
characters, or initial obscurity of spelling - e.g. excessive
punctuation. Does it apply here?


>> I understand this is totally different approach than operator
>> overloading and maybe
>> hard to implement, but I feel like it looks really appealing.
>> And it is quite intuitive imo. For me the syntax reads like:
>> "add new empty element and this element will be "item".
>
>
> The term "new empty element" is a nonsense term to me.
>
> If you mean "replace an empty slice at the end of the list with a new
> element", that can already be written:

I just say that I find this syntax is more intuitive than the idea
with operator. Not sure that we need to start semantics nitpicking.

For example, such code:

    L = []
    L[] = x
    L[] = y

imo has more chance to be understood correctly than e.g.:

    L = []
    L ^= x
    L ^= y

By L[] there is some mnemonical hint because [] is used to create
new empty list. Plus it does not introduce overloading of the operator.

And overloading has weakness in this - e.g. " var1 += var2 " does not
have mnemonics, other than + character (it could be two integers as well).

So if L[] is found somwhere far from initialisation - it may be a good aid.
It makes it more clear what is happening, compared to augmented operator.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to