Re: Is subscripting a slice useful

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 11 Oct 2004 11:56:47 +0200, Christian Cuvier
<christian.cuvier at agriculture.gouv.fr> wrote:
> 
> 
> >>Right now subscripting a slice is not allowed.
> >>>
> >>>}}}
<eucode>
> >>>constant asdf={"asdf","asdf","asdf","asdf"}
> >>>? asdf[1..2][1]
> >>></eucode>
{{{

> >>>I think that this code should print out {97,97,97,97}.
> >
> >
> > I think you just shot yourself in the foot blink)
> >
> 
> I disagree with this statement completely. You are using a typo from the
> original message to make your point about your personal dislike of this
> construct.
> 
> > There is *no* way that asdf[1..2] should return anything other than a
> > sequence of length 2,
> 
> True
> 
> > and hence a nested subscript of that could not
> > possibly yield a sequence of length 4.
> 
> False, if the intermediate sequence is made of sequences itself. Of course the
> original message didn't mean that, or I misunderstood something in ir.
> 
> > What, in contrast, would you
> > expect asdf[1..4][1] to print? (Surely something else!)
> >
> > This whole idea (which has been extensively discussed before) is so
> > open to misinterpretation it should definitely NOT be "standard".
> > Every application needs something different.
> 
> Really? Most of them need vertical slicing anyway, so it is desirable for it
> to become a standard. Could you give some examples of different schemes that
> might be concurrently needed?
> 
> [snipped remainder]
> 
> Consider a sequence with at least two levels, and look at how you access it.
> Each index specification (like [3]) just selects one element. Each slice
> specification (like [1..3]) selects a *range* of elements.
> Vertical slicing is not ambiguous if you consider that [3] and [3..3] are
> unambiguously referring to different objects. Slices operate on matrices
> (well, tensors in dimensions >2), and slices selectt individual elements as
> probably expected.
> 
> To come back to the original example above:
> 
> -asdf[1..2][1] would print {97,97}: select element #1 in all subsequences of
> asdf[1..2].
> -asdf[1..2][3..4] would print {{100,102},{100,102}}: slice [3..4] of all
> elements of asdf[1..2].
> -asdf[1][1..2] would print {97,115}, as usual.
> 
> Could you elaborate an example where this extended slicing, compatible with
> the current EU syntax, could lead to two different interpretations?
I don't think that it could have two different interpretations because
the current interpreter stops the value after slicing and looks for
more statements, so this would be an unambiguous feature.
I also think it would nest very well, like
myseq[1][1..2][3..4][5][6..7]+=1, would save tons of time in a very
big sequence.
Daniel

> 
> YIA
> CChris
> 
> 
> 
> 
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu