[Python-ideas] Where did we go wrong with negative stride?
Nick Coghlan
ncoghlan at gmail.com
Wed Oct 30 22:58:28 CET 2013
On 31 Oct 2013 07:45, "Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote:
>
> Nick Coghlan wrote:
>
>> That means that until people have fully explored exactly the semantics
>> they want in terms of the existing object model ... then there are *zero*
>
> > grounds to be discussing syntax changes that provide those new
semantics.
>
> I don't think it's possible to decouple the syntactic and
> semantic issues that easily.
>
> Consider the problem of how to specify from-the-end indexes
> without zero behaving incorrectly. There are a couple of
> ways this could be tackled.
>
> One would be to introduce a new type representing an
> index from the end. This wouldn't require any new syntax,
> but it would be verbose to spell out, so later we would
> probably want to consider a new syntax for constructing
> this type inside a slice expression.
>
> But if we're willing to consider new syntax, we don't
> need a new type -- we can just invent a syntax for
> specifying from-the-end indexing directly, and end
> up with a simpler design overall.
It isn't simpler though - since, as you note below, anything we can express
in the syntax *must* be expressible in the slice() API. Slice notation is
currently pure syntactic sugar and it should stay that way.
>
> There would obviously have to be some way of specifying
> the same thing that the new syntax specifies using
> arguments to slice(), but that would be mostly an
> implementation detail. It shouldn't be the driving
> force behind the design.
Who said it was? But defining an object API first lets us define and test
proposed semantics in pure Python, avoiding any reliance on abstract
handwaving.
Cheers,
Nick.
>
>
> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131031/82336bca/attachment.html>
More information about the Python-ideas
mailing list