unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: David Kastrup <dak@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: Anything better for delayed lexical evaluation than (lambda () ...)?
Date: Mon, 12 Dec 2011 13:29:07 -0500	[thread overview]
Message-ID: <87wra1hcek.fsf@netris.org> (raw)
In-Reply-To: <87mxaycmlx.fsf@fencepost.gnu.org> (David Kastrup's message of "Mon, 12 Dec 2011 07:47:38 +0100")

David Kastrup <dak@gnu.org> writes:
>> In general, the _right_ way to build a custom extension language using
>> Guile 2 is to write a compiler that converts your language into one of
>> the other languages that Guile 2 supports.
>
> Lilypond is not Scheme.  It has syntax ambiguities that are resolved by
> lexical tie-ins and thus depend on the context.  You can't easily
> compile it in advance.

Lexical tie-ins require the use of a context-sensitive parser, but how
does it prevent compilation in advance?  Guile 2 places no constraints
whatsoever on the parser used to compile your language to Guile.  You
could use the exact same Bison parser you are currently using, but with
different actions.

>> If there's something about Lilypond's language that you believe would
>> make compilation impractical, let's talk about it.
>
> Its syntax and semantics.
>
> <URL:http://git.savannah.gnu.org/cgit/lilypond.git/tree/lily/parser.yy>
>
> If I call a function with an optional argument of type integer? before
> an argument of type ly:music? and I encounter #x, then the value of x
> decides whether this argument will be used as the optional argument or
> as the following argument.  The rest of the parsing has to follow.

I don't see a serious problem here.  In general, anything that can't be
done at compile time can be postponed to runtime easily enough.  To
address the specific example you give above, the compiled Lilypond
procedure could look something like this:

(define (myproc . args)
  (extract-lyargs args `((#:optional ,integer?) (#:required ,ly:music?))
    (lambda (x music)
      body ...)))

where `extract-lyargs' is a procedure (part of the runtime environment)
that takes the list of arguments and a formal-parameter specification,
and does the runtime tests needed to decide how the arguments should be
put into `x' and `music'.

> And you are _totally_ putting the cart before the horse here.  Lilypond
> is not supposed to be an extension language for Guile, but Guile is
> supposed to be an extension language for Lilypond.  The acronym Guile
> stands for "GNU's Ubiquitous Intelligent Language for Extension".  You
> are losing sight of what Guile is supposed to be.

I don't know about that.  You seem to imply that Lilypond's use of Guile
is very typical, and that other programs that use Guile for extension
will run into similar difficulties, but as far as I can tell Lilypond is
quite unique here.

Typically, an application using libguile (or any other language library)
allows the library to handle all aspects of parsing and running the
supported extension language(s).  In Guile's case, the idea is that
whenever a new language is added to Guile, applications using libguile
can automatically make use of those new languages.

You are using Guile in a very unusual way.  You have constructed a
hybrid language of both Scheme and Lilypond, where each can be nested
within the other (so far so good), but -- and here's the kicker -- you
apparently want to implement this hybrid language using two separate
interpreters maintained by two separate groups that are each able to run
code within lexical environments established by the other one.

This is a fundamentally bad idea, because this structure makes it
impossible for either of these language implementations to evolve in any
significant way.  It forces them both to remain simple interpreters.

> You are working from the premise that Guile should govern the
> architecture of the system it is supposed to be extending.

I can understand why it appears that way to you, but this is only
because you have built a system on Guile that places unreasonable
constraints upon the internal workings of Guile.

Please try to look at it from our perspective, and also from the
perspective of other programs that use Guile in a more typical way.
Most users of Guile 2 benefit from the architectural and efficiency
improvements, and are not harmed by them.

We are not trying to impose any particular architecture on your system,
only on the way the language implementation itself works.  Is it really
so unreasonable that the language implementation should be under Guile's
control?  Is this really a betrayal of the original vision of what Guile
is "supposed to be", as you wrote above?  If you think so, can you
please back this up with some references?

     Mark



  reply	other threads:[~2011-12-12 18:29 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-03 15:45 Anything better for delayed lexical evaluation than (lambda () ...)? David Kastrup
2011-12-03 16:44 ` Andy Wingo
2011-12-06 14:55 ` Thien-Thi Nguyen
2011-12-06 15:45   ` David Kastrup
2011-12-06 19:50 ` Marco Maggi
2011-12-11  9:33   ` David Kastrup
2011-12-11  9:51     ` David Kastrup
2011-12-12  5:21     ` Mark H Weaver
2011-12-12  6:47       ` David Kastrup
2011-12-12 18:29         ` Mark H Weaver [this message]
2011-12-12 19:56           ` David Kastrup
2011-12-12 20:39             ` rixed
2011-12-12 21:02               ` David Kastrup
2011-12-12 21:58                 ` Mark H Weaver
2011-12-12 21:40             ` Mark H Weaver
2011-12-12 21:50           ` Andy Wingo
2011-12-13  9:02             ` David Kastrup
2011-12-13 13:05               ` Andy Wingo
2011-12-13 13:56                 ` David Kastrup
2011-12-13 14:34                   ` Andy Wingo
2011-12-13 15:27                     ` David Kastrup
2011-12-13 15:48                       ` Andy Wingo
2011-12-13 16:08                         ` David Kastrup
2011-12-13 16:27                           ` Andy Wingo
2011-12-13 16:54                             ` David Kastrup
2011-12-13 18:58                               ` Andy Wingo
2011-12-13 22:23                                 ` David Kastrup
2011-12-13 17:28                             ` Mark H Weaver
2011-12-13 18:49                               ` Andy Wingo
2011-12-13 19:15                                 ` Mark H Weaver
2011-12-13 23:00                                   ` Noah Lavine
2011-12-13 23:16                                     ` David Kastrup
2011-12-13 23:44                                       ` Andy Wingo
2011-12-13 23:39                                     ` Andy Wingo
2011-12-13 23:45                                       ` David Kastrup
2011-12-14 10:15                                         ` Andy Wingo
2011-12-14 10:32                                           ` David Kastrup
2011-12-14  0:30                                       ` Mark H Weaver
2011-12-14  8:16                                         ` David Kastrup
2011-12-14  0:42                                       ` Noah Lavine
2011-12-14  0:47                                       ` Noah Lavine
2011-12-14  1:30                                     ` Mark H Weaver
2011-12-14  7:50                                       ` Mark H Weaver
2011-12-14  8:48                                         ` [PATCH] Implement `capture-lexical-environment' in evaluator Mark H Weaver
2011-12-14  9:08                                           ` David Kastrup
2011-12-14  9:36                                           ` Mark H Weaver
2011-12-16  9:21                                           ` [PATCH] Implement `the-environment' and `local-eval' " Mark H Weaver
2011-12-16  9:32                                             ` David Kastrup
2011-12-16 14:00                                               ` Peter TB Brett
2011-12-16 14:26                                                 ` David Kastrup
2011-12-16 15:27                                                 ` Mark H Weaver
2011-12-16 16:01                                                   ` Andy Wingo
2011-12-16 17:44                                                     ` Mark H Weaver
2011-12-16 19:12                                                       ` Mark H Weaver
2012-01-07  1:26                                                         ` Andy Wingo
2012-01-07 17:30                                                           ` Mark H Weaver
2012-01-07  1:18                                                       ` Andy Wingo
2011-12-16 16:59                                                   ` Hans Aberg
2011-12-14 10:08                                         ` Anything better for delayed lexical evaluation than (lambda () ...)? Andy Wingo
2011-12-14 10:27                                           ` David Kastrup
2011-12-14 13:35                                             ` Andy Wingo
2011-12-14 15:21                                               ` David Kastrup
2011-12-14 15:55                                                 ` Andy Wingo
2011-12-14 17:26                                               ` Mark H Weaver
2011-12-14 18:23                                                 ` David Kastrup
2011-12-14 18:38                                                 ` Mark H Weaver
2011-12-14 19:14                                                   ` David Kastrup
2011-12-14 19:44                                                     ` David Kastrup
2011-12-14 22:56                                                 ` Andy Wingo
2011-12-14 11:03                                           ` Mark H Weaver
2011-12-14 11:18                                             ` David Kastrup
2011-12-14 13:31                                             ` Noah Lavine
2011-12-14 21:03                                               ` Mark H Weaver
2011-12-14 22:12                                                 ` David Kastrup
2011-12-14 22:24                                                   ` David Kastrup
2011-12-14 22:55                                                 ` Andy Wingo
2011-12-13 16:24                         ` David Kastrup
2011-12-13 15:52                       ` David Kastrup
2011-12-13 11:14             ` David Kastrup
2011-12-14 13:52             ` Ludovic Courtès
2011-12-14 14:27               ` David Kastrup
2011-12-14 21:30                 ` Ludovic Courtès

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=87wra1hcek.fsf@netris.org \
    --to=mhw@netris.org \
    --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).