Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
Beni Cherniavsky <[EMAIL PROTECTED]> wrote:
> Alex wrote:
> > 'foo[1' '2' '3]'
> >
> > It's not hard to update the code to guess the latter case, but I'd be
> > surprised if there aren't any weird corner cases lurking around.
> >
> Yikes! Forget the implementation, this would be a weird corner case
> in the syntax, which is even worse ;-)
> If you want to go that way, at least tokenize on the brackets:
>
> 'foo[' '1' '2' '3' ']'
>
> or:
>
> 'foo' '[' '1' '2' '3' ']'
The above assumes tokenization on spaces, same as always. Why is that
weird? I guess one could implicitly tokenize arguments around
brackets, but I'm not sure why you'd want to.
The tokenization is not weird, the syntax of 'set' 'foo[1' '2' '3]' is
weird. The syntax of the builtin is important when you generate it,
e.g. "set (print-vars) (print-values)" -- print-vars would have to be
a bogus command/function to generate 'foo[1' '2' '3]'!
> How about this idea: let brackets be like braces but space-separated
> and the brackets remain in the expansion, and let them expand *before*
> brace and command expansion.
> Then 'a[7 (seq 2)]' expands into 'a[7]' 'a[(seq 2)]' which is then
> command-expanded into 'a[7]' 'a[1]' 'a[2]'. Subtle but appears to
> work. Don't know whether it matches the Right order of expansion in
> general.
That would work. Then main disadvantage I see is that the suggested
bracket expansion is really pretty useless for anything other than
variable slicing, which is a shame.
Stupid question: do we need support for ``a[2 3]`` at all? How
frequent is it that the user can't type ``a[2] a[3]`` or ``a[{2,3}]``?
The more important cases are things like ``a[$i]`` or
``a[(print-indexes)]`` which work anyway [*]. I'm starting to get the
feeling that supporting any syntax but 'a[2]' 'a[3]' (after
expansions) leads to problems and is not really needed...
[*] as long as it's expanded inside-out, or right-to-left which is the
current approximation.
P.S. For discussion and documentation, it would nice to agree on a
notation for command examples. 'a' 'b' 'c' is acceptable for a word
list but I want some delimiter that implies it's an example of
command syntax, not a single word after expansion. I've been using
double-backquotes (from reStructuredText) in some mails, since
backquotes are unused in fish. Is there already some notation I
missed or shall we decide on one?
--
Beni Cherniavsky <[EMAIL PROTECTED]>, who can only read email on weekends.
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users