unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Hans Aberg <haberg-1@telia.com>
To: David Kastrup <dak@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: summary: lilypond, lambda, and local-eval
Date: Thu, 15 Dec 2011 18:52:35 +0100	[thread overview]
Message-ID: <9015E9C4-44FC-4786-83DC-61E90A5F0586@telia.com> (raw)
In-Reply-To: <87bor9694v.fsf@fencepost.gnu.org>

On 15 Dec 2011, at 18:24, David Kastrup wrote:

>>> The "delayed evaluation" thread is a bit long and confusing, so I would
>>> like to try to summarize it.
>>> 
>>> Lilypond has a way to embed Lilypond code in Scheme, and Scheme code in
>>> Lilypond code.  The former uses a reader macro, #{#}.  The latter uses
>>> specially-marked variables and expressions, specifically, those preceded
>>> by $ or #.
>> ...
>>> It took some time for everyone to understand the problem.  In the end,
>>> there were four workable possibilities.
>>> 
>>> 1) Keep using closures.
>> 
>> When doing a parser on top of Guile, I noticed one must first build an
>> unevaluated closure, and only thereafter call the evaluator. Scheme
>> has some restrictions forcing this, for example, the lambda cannot
>> appear as a free symbol, though it is possible in Guile using
>> scm_sym_lambda.
>> 
>> It might be useful with a variation of scm_eval_string() that only
>> parses and builds the closure, but not calls the evaluator.
> 
> I am not sure what you mean with "closure" here, but just "read" parses
> a form.

I build them from scratch, using the scm_x calls, with a parser. This way, it is possible to a more than within the Scheme paradigm itself. For example,
  scm_list_x(scm_sym_lambda, ...)
gives an unevaluated lambda-expression. Some symbols are not available in Guile, so for example, I have in my init():
  SCM list_ = scm_from_locale_symbol("list");

After an expression has been built, the parser calls scm_primitive_eval(). However, suppose one wants to insert some Scheme code in to the expression, then scm_eval_string() will call the evaluator, enforcing that only complete Scheme expressions can be inserted:

Without that restriction it would be possible to have an expression like
  f := x |-> scheme "(+ x 1)"
where only the quote is the actual scheme code and the other handled by the external parser, and where the external "x" binds to the one in the Scheme code string "(+ x 1)". However, when scm_eval_string() calls the evaluator, one gets an error, because "x" is not bound.

Hans





  reply	other threads:[~2011-12-15 17:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15 10:21 summary: lilypond, lambda, and local-eval Andy Wingo
2011-12-15 14:46 ` David Kastrup
2011-12-15 16:52 ` Hans Aberg
2011-12-15 17:24   ` David Kastrup
2011-12-15 17:52     ` Hans Aberg [this message]
2011-12-16  7:35 ` Mark H Weaver
2011-12-16  8:08   ` Mark H Weaver
2011-12-16  8:49   ` Mark H Weaver
2011-12-16  9:16     ` David Kastrup
2011-12-18  7:11     ` Mark H Weaver
2011-12-18 11:27       ` Andy Wingo
2011-12-18 15:32         ` Noah Lavine
2011-12-18 16:19           ` David Kastrup
2011-12-18 21:24             ` Noah Lavine
2011-12-19  9:13         ` Mark H Weaver
2012-01-09 14:44           ` David Kastrup
2011-12-16  9:28   ` Andy Wingo
2011-12-16  9:59     ` David Kastrup
2011-12-16 10:33     ` Mark H Weaver
2011-12-16 12:13       ` Hans Aberg
2011-12-16 12:43         ` David Kastrup
2011-12-16 14:57           ` Hans Aberg
2011-12-21 10:32 ` Ian Hulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9015E9C4-44FC-4786-83DC-61E90A5F0586@telia.com \
    --to=haberg-1@telia.com \
    --cc=dak@gnu.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).