On 5/10/06, Philip Ganchev <[EMAIL PROTECTED]> wrote:
On 5/9/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
> On 5/9/06, Philip Ganchev <[EMAIL PROTECTED]> wrote:
> > On 5/9/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
> >
> > > set foo[(seq 3 5)] foo bar baz
> > >
> > > [...] Parameter expansion will make sure that the
> > > former example gets expanded into
> > >
> > > set foo[3] foo[4] foo[5] foo bar baz
> >
> > Is it not possible to instead make parameter expansion convert it to
> > "set foo[3 4 5] foo bar baz"?  This is the more intuitive behavior to
> > me.  The other one seems a bit magical and surprising.
> >
>
> How would you note the difference? In either case, you write 'set
> foo[(seq 3 5)] foo bar baz' and you get the same results.

The kludge is apparent in that, as you mentioned,

Absolutely. I have no idea what I was thinking when I wrote that. Moving on...


    set foo[1 (seq 4 6)] a b c d

refers to the indexes 1 4 1 5 1 6, rather than 1 4 5 6 as one would
expect.  It's surprising; I would much prefer the latter.  Instead of
creating an illusion, why not change make expansion more intuitive?

> But this
> way, we don't make parameter expansion behave in a different, magical
> way when operating on the set builtin, instead the same rules as
> always apply.

Sorry, I was not clear.  I did not mean anything about the "set"
builtin.  I was suggesting that

    foo[(seq 1 2)]

should expand to

    foo[1 2]

not to

    foo[1] foo[2]

One way to achieve this is to make expansion work differently with
brackets than with other strings.  Currently,

I am uncomfortable with making command substitution tokenize
differently depending on whether we are in brackets or not. Introduces
far too much modality.


    foo(seq 1 2)

Expands to

    foo1 foo2

Another way is to make the above behave instead as a concatenation of
the strings "foo" and "1 2", namely

    foo1 2

Then "foo1 foo2" can be achieved as

    foo{"",(seq 1 2)}


Wouldn't that result in the elements foo' and 'foo1 2'. I see many
problems with the second suggestion:

* Posix-incompatible
* Rarely what you want. Array separating on newline if often useful,
at least in my experience.

At a glance, I agree that it would be nicer to make 'set foo[ 1 (seq 4
7)] a b c d' do what you'd expect, but firstly I don't see how that is
possible without breaking something more fundamental, and secondly
once you get used to the idea that array slicing piggybacks on regular
parameter expansion - no special treatment - then it seems pretty
intuitive. At least to me. It comes back to having a small
multipurpose syntax.

--
Axel


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to