Universal variables gave me a crazy idea.  I don't know yet what to do
about it, so I decided to toss it here rather than think alone.

Builtins and functions are evil from the user's perspective, because
they are invisible to other programs.  E.g. last week I tried ``env
BROWSER=links help ...`` which of course didn't work because `help` is
a function.  Which means that `env` can't fully replace the requested
set-for-one-command feature.

Why do we have builtins at all?
(1) Things like ``set`` are builtin because a subprocess can't modify
the shell's state.
(2) Things like ``while ... end`` are builtins to have special syntax
recognized by the parser.
Functions are essentially builtin scripts, existing for reason (1).

But (1) is not a reason, as fishd proves: if the shell becomes a
server, things like ``set`` and ``cd`` can be implemented as external
commands!
This is perhaps an immediately good idea.

As for (2), it is possible to turn control structures into external
commands, but it requires going a long way toward TCL.  Consider
`xargs`: it's essentially a for loop (at least in -1 mode).  And
`watch` is a ``while true`` loop with some output wrapping.  The trick
is to supply the body as an argument, quite like in TCL.  It means you
need to quote multiple, perhaps nested commands in some way.  More
importantly, it means parsing of command boudaries can't depend on the
command being used (because it's external).  Both lead almost
inevitably to TCL-style quoting with symentric delimiters, e.g.
``while COMMAND [CMD; CMD]`` instead of ``while COMMAND; CMD; CMD;
end``.
I have a growing feeling that TCL got this aspect right but it's
obviously a very major change.

-- 
Beni Cherniavsky <[EMAIL PROTECTED]>, who can only read email on weekends.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to