guile-devel
[Top][All Lists]
Advanced

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

Re: non-scheme scripts: proposed solutions and their pros/cons


From: Ian Price
Subject: Re: non-scheme scripts: proposed solutions and their pros/cons
Date: Sun, 25 Nov 2012 16:06:16 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Ian Price <address@hidden> writes:

> First, I'm going to try and write a proof-of-concept guile-elisp
> executable. This shouldn't be too hard, I think, and may shed some light
> on expected difficulties.

I was distracted by the pfds release so it's taken me longer than it
should have, but as expected, it wasn't difficult _once I knew where to
look_. The general template is

#!/usr/local/bin/guile -s
!#

(use-modules (system base compile)
             (system repl repl))

(let* ((args (command-line))
       (argv0 (car args))
       (files (cdr args))
       (load-file (lambda (file)
                    (compile-file file #:from 'elisp #:to 'value))))
  ;; ^^ Imagine sophisticated command-line parsing :)
  (if (null? files)
      (start-repl 'elisp)
      (for-each load-file files)))

Be aware you get lots of warnings if you actually run this, since elisp
overrides a bunch of bindings.
      
Extending it to handle different argv0s seems obvious. Handling -c would
involve loading the relevant reader, and using compile (maybe write that
as a compile-from-string function). -e is a little tricker.

-- 
Ian Price -- shift-reset.com

"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]