Ben Booth <benwbo...@gmail.com> wrote:

> I read on the guile user mailing list that version 0.2 of scsh for guile has 
> been released. This got me thinking what a real lisp-powered interactive 
> shell would need in order to be useful:

We've actually previously discussed using sweet-expressions to implement a 
Lisp-powered interactive shell.  It's quite doable.

In fact, you can experience it right now. Just install scsh and run:
  ./unsweeten | scsh

You can then type in stuff like:
run $ grep "Wheeler" "README"

As with all sweet-expressions, be sure to press ENTER ENTER to execute it.

> 1. A modified version of sweet-expressions, where barewords are treated as 
> string literals instead of symbols. Bareword string literals could be used 
> along with normal quoted string literals

I think a better approach is scsh's, which defines special lists called 
"extended process forms".  Since they are special forms, they can deal with 
string literals and symbols.  It actually meshes nicely with Scheme.

Basically, you can use symbols as always... but if the context demands that 
they be sent outside as strings, off they go.

> 2. Some way to designate what is a symbol. Bash uses $var or "$var" for 
> variable substitution. A scheme shell could use , and ,@ (the unquote and 
> unquote-splicing operators) for this purpose. The REPL would then need to 
> convert barewords to strings, and then quasiquote the parsed S-expr before 
> evaluating it

Yes, that's exactly what scsh does.

http://www.scsh.net/docu/html/man.html
Section 2.1 says: "The subforms of a redirection are implicitly backquoted, and 
symbols stand for their print-names. So (> ,x) means ``output to the file named 
by Scheme variable x,'' and (< /usr/shivers/.login) means ``read from 
/usr/shivers/.login.''"


> 3. If a bareword or a string literal is at the head of a list, it should 
> automatically be interpreted as a function name

No need for this.  Just use symbols as always.

> 4. If a function is called that does not exist in the current scope, the 
> *runtime* needs to call a dispatch function to search for a command in $PATH 
> that matches the function name and execute it. Any arguments would be coerced 
> into strings, and the command would return either an exit code, or 
> stdout/stderr filehandles, or maybe both. If no matching command is found in 
> $PATH, throw an exception. This kind of runtime missing method dispatch can 
> be done in perl and ruby, but I'm not sure about guile

In scsh, "run" etc. indicate a search.  That may not be what you want, of 
course, but that's what it does.

> 5. Requiring the user to hit enter twice after each command is too onerous 
> for an interactive shell. One-line commands could be typed without any 
> indentation, and thus only require hitting enter once. Multi-line commands 
> would then require indentation, and pressing enter twice to execute the 
> command. By distinguishing between one-line commands and multi-line 
> commmands, you can easily enter one-line commands quickly, but still use 
> multi-line commands when necessary

But how does the system know, after you've entered the first line, that another 
one is coming?

> 6. It would be great if such a "sweet shell" (swsh) could be packaged in a 
> repository for easy access. Does anyone know the current status of the 
> guildhall?

It has been discussed, but "unsweeten | scsh" isn't too bad...!

> I'm not sure how much work it would take to tweak sweet-expressions to do 
> this, but it would make for a killer app. I've always wanted an interactive 
> shell that could use macros, and guile seems like the perfect fit.

Obviously scsh works today with sweet-expressions.

If you want to implement your own, there are a few points you might want to 
consider:
* Scheme doesn't define what "-" and "+" followed by other stuff mean if they 
aren't a number.  The obvious extension is to consider them symbols, and doing 
so is important for a Scheme shell (it makes it easy).  One gotcha: "-i" is 
negative sqrt(-1), but that's also a valid flag (in particular, it's grep's 
case-insensitive flag).
* The latest Scheme now defines |...|.  Which is nice, but that means that 
scsh's mappings for | and || probably need tweaking.

Anyway, before charging off, I suggest playing around with scsh.  You might not 
agree with their every design choice, but it'll certainly give you some ideas 
even if you choose to make some different choices.

--- David A. Wheeler

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to