Alexander Schmolck <firstname.lastname@example.org> wrote:
| email@example.com (Rob Warnock) writes:
| > Note that for a real "CLsh", you'd probably want to run with
| > readtable-case :INVERT to avoid upcasing the Unix commands. ;-} ;-}
| Oh, I'd want that anyway (given the current absence of sane case
| handling in most CLs. Well at least it has warded off CamelCase).
Well, except, readtable-case :INVERT *preserves* CamelCase, you know... ;-}
| > Unfortunately, having usurped backquote/comma/comma-at from READ,
| > one is now stuck needing to do one's own full backquote expansion,
| > which includes all the gore of handling lexical environments as well.
| I can't really follow you...
Brian Downing later showed that I was incorrect about that point.
Please excuse the confusion.
| > Anyway, like I said before (too many posts ago), doing a "CLsh" that
| > used "pure" Scsh syntax would be quite hard.
| I'm not sure why scsh's syntax would be that desirable anyway, see below.
Because my original question was *NOT* what a "better" syntax would be,
but whether CL *could* duplicate Scsh's exact macro syntax [at least the
basics, where the Scheme/Common Lisp differences don't show up much].
| > +---------------
| > | (you don't need backquote to accept additional commas, right?)?
| > +---------------
| > What do you mean by "additional commas"? Nesting? Of course!
| > It needs to work *just* like normal CL backquote, otherwise
| > your "shell" syntax won't be "CL".
| What I meant is: is `,,foo supposed to work (i.e. return an unquote form)?
| If so, why?
As to "why", I'd say that it has to only if Scsh's syntax needs it,
so CLsh can copy it (see below).
As to *what* it's supposed to return, that would be the same as what
Scheme's READ returns, namely (QUASIQUOTE (UNQUOTE (UNQUOTE FOO))),
which if evaluated *by itself* might produce an error, but inside
a macro which provides "implicit backquoting" [see below] would
produce the value of FOO, as you'd expect.
| > It might be better to just give up on trying to achieve the "pure"
| > syntax and accept that we would type the extra backquote character
| > in all of the run-process convenience forms. Then it "just works",
| > right out of the box:
| > > (defun run (form)
| > (format t "RUN saw this form: ~s~%" form))
| > > (let ((file "some.file")
| > (flags '(-lm -lbsd)))
| > (run `(cc ,file ,@flags)))
| > RUN saw this form: (CC "some.file" -LM -LBSD)
| > NIL
| > >
| Personally I compleltely fail to see the point of
| (run (ls ,@flags ,dir))
| as opposed to
| (run `(ls ,@flags ,dir))
Yes, well, in the occasional hacks I've taken at doing a "CLsh" from
time to time, I *have* used the latter form. But as I said earlier,
I was just curious whether the former, which is what Scsh accepts
[what it *requires*, actually!], would be possible in CL. I now
believe it would be possible, provided that one replaces the built-in
backquote processing with your own readmacros.
Or said another way: This is not an issue of deciding from scratch
what would be a "good" syntax for a Lisp-based shell; it's the case
that there already *is* a "Scheme Shell" a.k.a. "Scsh", based on
Scheme-48, that has a long history of use and publication and idiom
[see <http://www.scsh.net/> for more details]. If one were to try
to create a "CLsh" and wished to benefit from the experience of the
Scsh community, it would behoove one to attempt to match the "process
notation for running programs and setting up pipelines and redirections"
as closely as possible. And the "implicit backquoting" within process
macros that allows the (run (ls ,@flags ,dir)) form is an explicit part
of that notation, see <http://www.scsh.net/docu/html/man-Z-H-3.html>.
I hope that answers the "why" part...
Rob Warnock <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607