[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Neat hacks for a birthday

From: Nala Ginrut
Subject: Re: Neat hacks for a birthday
Date: Fri, 10 Feb 2012 21:36:21 +0800

On Thu, Feb 9, 2012 at 9:38 AM, Ian Price <address@hidden> wrote:
address@hidden (Ludovic Courtès) writes:

> So, here’s a suggestion: let’s write neat hacks that integrate Guile
> with some other piece of software, preferably GNU packages.  Examples
> include extending GCC or GDB extension in Guile, work on Mike’s
> Zile-on-Guile, enhanced Guile support in GNU Make, and Hurd file systems
> written in Guile.
As I said on #guile, I'd like to see someone (i.e not me :) hack scheme
evaluation into bash.

Hack scheme evaluation into bash huh?
I love that idea so much!

And I spend some time to read Bash code, then I think there're two ways do go:

The easy way is to write a loadable builtin command for Bash which can do the simple Scheme evaluation work with Guile core. And I finished it: git://
PS: 'BIG' for Bash Inner Guile 

If you want to load it, type:
# enable -f ./big big

then you may use big in bash:
# big "(+ 1 1)"

or run a REPL
# big  
Bash inner Guile interpreter!
(define func
(lambda (x) (+ 1)))
==> #<unspecified>
(func 1)
==> 1

type Ctrl+D to quit.

It's so easy that almost useless, one may use Guile REPL rather than BIG or 'guile -c' to eval expressions. But as Ludo said "a proof of concept". ;-)

All I expected is the harder way. But I'm not quite familiar with Bash architecture, so I just provide some suggestions and wishes here:
We may modify "parser.y" to add S-exp parsing, and eval it with Guile core.
In the original way, if subshell failed to lookup function name, it return EXECUTION_FAILURE directly. I think there's a way to pass it to Guile core and evaluate it:
# (+ 1 1) --> '+' is an invalid function --> pass "(+ 1 1)" to scm_eval_string

If we can use S-exp in Bash, I think these would be interesting:
echo "$((+ 1 ${x}))" ==> 6
echo "$((expt 2 ${x}))" ==> 32

Moreover, maybe modify the evaluator of Bash and transform "define" to define a variable in Bash? Then the namespace is unified in Bash, when Bash code passes exp into Guile, all variables within will be evaluated to the actual value and Guile will eval the exp. But I think that would bereave lexical scope of Scheme code. 

Anyone comment?

> If you’re up to the challenge, you’re welcome to announce your intent
> here.  On Feb. 16th, we’ll collect the list of neat hacks and let the
> world know!
As I also said on #guile, I picked gdbm for the gnu package I'm going to
integrate. I've already hacked somewhat useful bindings, but still more
to do. if anyone is interested

> PS: I personally intend to come up with a simple GCC plug-in interface
>     for Guile.  Let’s see how it goes…
I look forward to that.

Come on guilers, that's two of us stepped up to the plate so far. What
are you, chicken? ;-)

Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]