unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* ghil repl
@ 2008-11-11 23:29 Andy Wingo
  0 siblings, 0 replies; only message in thread
From: Andy Wingo @ 2008-11-11 23:29 UTC (permalink / raw)
  To: guile-devel

A brief note:

Piqued by the need to document GHIL, I noticed a lack of Replage (noun,
"in the state of repl") in the GHIL language. No more!

    scheme@(guile-user)> ,language ghil
    Guile High Intermediate Language (GHIL) interpreter 0.3 on Guile 1.9.0
    Copyright (C) 2001-2008 Free Software Foundation, Inc.

    Enter `,help' for help.
    ghil@(guile-user)> "foo"
    $1 = "foo"

Ooooh! ghil@ means that the input language is GHIL, or rather, the
external representation of GHIL in S-expressions. Self-quoting values
translate into <ghil-quote> instances, which, when compiled and
executed, evaluate to results: above, "foo".

    ghil@(guile-user)> (values 1 2 '(3 4))
    $2 = 1
    $3 = 2
    $4 = (3 4)

But self-quoting values are a degenerate case. Besides bare symbols,
which translate into <ghil-ref> instances, the external representation
of GHIL is a tagged list, whose interpretation depends on the tag. In
this case, `values' corresponds to <ghil-values>, which ends up
returning multiple values.

    ghil@(guile-user)> (values* 1 2 '(3 4))
    $5 = 1
    $6 = 2
    $7 = 3
    $8 = 4

Here we see values* -- used by the scheme compiler in the (apply values
...) idiom.

    ghil@(guile-user)> (lambda (x) #f () (call * x x))
    $9 = #<program #(3 18 #f) (x)>

The form of the `lambda' GHIL construct is not the same as scheme's
lambda, though they are functionally equivalent. Its form goes like this:

   (lambda ARGS REST? META . BODY)

Here the args are (), there are no rest arguments, and no
meta-information. The body is a call expression:

   (call PROC . ARGS)

Here we call `*' with x and x.

    ghil@(guile-user)> (call $9 5)
    $10 = 25

Incidentally, $9 is a <ghil-ref> instance.

    ghil@(guile-user)> (call (lambda (a b) #f () (inline add a b)) 10 20)
    $11 = 30

An illustration of procedural values and <ghil-inline>.

The whole range of forms understood as external representations of GHIL
will be documented, but for now it may be seen in parse-ghil in
module/system/il/ghil.scm. The tags are:

    quote void lambda begin bind bindrec set! define if and or mv-bind
    call mv-call inline values values* compile-time-environment
    quasiquote

Happy hacking!

Andy
-- 
http://wingolog.org/




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-11 23:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-11 23:29 ghil repl Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).