On Thu, Mar 5, 2009 at 01:10, Axel Liljencrantz <[email protected]>wrote:
>
> As to the original question, I see your point, but allowing variables in
> command names would be impossible to do for many builtins, e.g. those that
> open a block, and I strongly dislike the concept of elevating some/all
> buitins in fish to some magical 'keyword' status where they work differently
> from the rest of all commands. The emphasis on making everything into a
> command and making all commands obey the same rules whenever possible is
> something I feel needs to be protected as far as possible.
>
But they *already have* magic keyword status! Things like "if" parse
differently - they open an "end"-terminated block - which is exactly the
reason why you don't want to parse them after variable expansion.
Least Surprise says you want expanding variables to normal commands like
"ls" to just work.
OTOH, the even deeper No Horrible Surprise principle says you don't want
variables to expand to special commands like "if"!
So I claim that you should allow commands to start with a variable, which is
parsed as any normal command. If it happens to expand to a keyword like
"if", there are two options:
1. Search for it on PATH anyway.
2. Fail with an error. Probably better than 1 because of discoverability.
> To be perfectly honest, I sometimes play with the thought of making a new
> fish syntax, one with closures, macros and other things that no sane person
> would ever put in a command line shell. Would be kind of cool...
>
I wants it !-) The tricky part of making closures work is a syntax sugar
that expands to a command that *can be passed to arbitrary unix commands*.
Something that would allow::
watch {{set x (math $x+1); echo $x}}
to work by expanding to something like:
watch 'fish -c \'set x (math $x+1); echo $x\''
(with extra magic to allow x to survive between invocations via fishd).
But assuming it can be done technically, I don't see any way it which it
could resemble fish syntax. You would end up with a unix-friendly TCL...
--
Beni <[email protected]> (I read email only on weekends)
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users