scsh-users
[Top] [All Lists]

Syntax for Scheme and shells

To: scsh@martigny.ai.mit.edu
Subject: Syntax for Scheme and shells
From: shivers@ai.mit.edu (Olin Shivers)
Date: 11 Jan 1996 10:33:44 -0500
Organization: Artificial Intelligence Lab, MIT
Reply-to: shivers@ai.mit.edu
   From: wilson@cs.utexas.edu (Paul Wilson)
   Newsgroups: comp.lang.scheme,alt.lang.scheme.scsh
   Date: 11 Jan 1996 01:15:53 -0600

   I was really more interested in syntactic convenience for a very terse
   interactive-or-trivial-scripting mode.  For typing commands or scripts
   of a few dozen lines at most, I think it's reasonable to default
   to running a UNIX program.  This would just be syntactic sugar for
   a (run ...) form, and it'd be understood---one hopes---that it's *just*
   a terseness hack.

Absolutely!

   I don't think this is horribly ugly, even if it's not something you want
   to have as the default in nontrivial programs.  Normal Scheme already does
   things based on the binding of whatever symbol is in the head position
   of a form.  E.g., if there's a procedural binding, then the argument
   forms are evaluated in the usual way, but if there's a macro binding,
   they're not.  We just add the rule that if there's no Scheme binding,
   it's a run command.

If we are going for an interactive command language, then anything goes --
it doesn't have to be readable, just writable. So punt the parens as well,
and do a simple, real shell syntax. If you want to do anything complex,
escape to Scheme.

I designed a shell syntax along these lines maybe two years ago, but
I never implemented it, and I've have to spend some time looking at
my notes to figure out the details. As I recall, one of the Scheme escapes
was $. So $foo gave you shell variables just like other shells, but you
could also do things like $(string-append x y). 

My syntax was like rc's and es's in that it had a real, parsable grammar,
and a clear read/parse/evaluate split, unlike the gruesome mess you have
with sh and csh (csh has *seven* different expansion/evaluation stages!).

I totally punted any form of conditional or loop -- that was part of the
advantage of having a big gun like Scheme around whenever you wanted it. 

I further feel that the *right* solution for an interactive shell notation
is... emacs. Just port Edwin to S48 and you would have the ultimate shell.
You could put shell commands on control keys, always have a directory listing
in a window, navigate the file system with cursor keys, perhaps a job list
in another window. The shell commands bound to control keys would be defined
with scsh. These would cover 90% of your interactions; for the hairy cases,
you could directly enter Scheme code into an interaction buffer.

I don't have time to get Edwin running in S48. I keep begging volunteers to
port it -- I think the resulting shell would make such a person a Scheme hero.
So far, no hits.
        -Olin

<Prev in Thread] Current Thread [Next in Thread>