unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: David Kastrup <dak@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: Anything better for delayed lexical evaluation than (lambda () ...)?
Date: Wed, 14 Dec 2011 16:55:45 +0100	[thread overview]
Message-ID: <87mxav4072.fsf@pobox.com> (raw)
In-Reply-To: <87mxav89he.fsf@fencepost.gnu.org> (David Kastrup's message of "Wed, 14 Dec 2011 16:21:33 +0100")

On Wed 14 Dec 2011 16:21, David Kastrup <dak@gnu.org> writes:

> Andy Wingo <wingo@pobox.com> writes:
>
>> It is my opinion -- and I could be wrong here, either by
>> misunderstanding (again!) the issues, or for whatever reason -- that
>> closures are the best solution to the #{#} problem.
>>
>> Reasons:
>>
>>   * Lambda is standard, well-understood, and general.
>
> Well, if they are standard, what benefits does using GUILE give us?

I'm not sure if this is a rhetorical question or not :), but:

  1) Guile has a C library, with C interfaces to its functionality..

  2) Guile is a GNU project.

  3) You're already using Guile features (modules, among them).

But TBH I don't understand this argument.  Lambda is fantastic, and even
if Guile provided other facilities, I would still use it.  It is the
right tool for the job, IMO.

>>   * Using `lambda' does not preclude compilation.
>>
>>   * Using closures does not require any additional work on the part of
>>     Guile.  (This is only partly selfish; it also decreases the amount
>>     of coupling of lilypond to any particular Guile version.)
>
> Any particular Scheme version.

This is a great thing.  We share the knowledge and in some times the
implementations from other Schemes.  And there are quite a number of
fine Scheme implementations; if you had to switch, for whatever reason,
you could.

>>   * Allows for integration with the debugger, in 2.0.  (Currently,
>>     interpreted code does not debug well.)
>
> Sounds like putting the cart before the horse.  After all,
> interpretative environments offer a lot of potential to be _better_ for
> debugging than compiled code.

I am saying this as the person who wrote the current debugger.

>  One should not lightly waste this.  In
> particular since macro expansion is basically an interpretative
> operation and macros are among the nastiest things to debug.

Very few languages have proper macros.  Very few Scheme implementations
have macro debuggers.  Racket is the only one I know.  It has a separate
debugger for use at syntax expansion time.

I am saying this as the person who maintains the current macro
expander.

:)

>>   * Potentially more efficient, and will benefit from future speed
>>     improvements in Guile.
>
> Well, take a look at the following:
>
> dak@lola:/usr/local/tmp/lilypond$ out/bin/lilypond scheme-sandbox
> GNU LilyPond 2.15.22
> Processing `/usr/local/tmp/lilypond/out/share/lilypond/current/ly/scheme-sandbox.ly'
> Parsing...
> guile> '#{ ##{ \displayLilyMusic $p #} #}
> (#<procedure embedded-lilypond (parser lily-string filename line closures)> parser " ##{ \\displayLilyMusic $p #} " #f 0 (list (cons 2 (lambda () (#<procedure embedded-lilypond (parser lily-string filename line closures)> parser " \\displayLilyMusic $p " #f 0 (list (cons 20 (lambda () p))))))))

It's not what you see, it's what you don't see :)

In Guile 1.8, you don't see:

 * (Lazy) memoization.  (A 1.8 implementation technique.)
 * Consing up procedure arguments.
 * Consing up lexicals.
 * Looking up lexicals.
 * The evaluator dispatch loop.
 * Out-of-line calls to primitives.

Etc.

You are right in saying that it will be slower on 1.8.  Oh well.  On 2.0
it will probably be faster, and potentially could be much faster -- if
it matters.

I am sympathetic to your argument.  Using closures is more code on your
part than using first-class environments.  If Guile only provided an
interpreter, that would certainly be the way to go.  But using closures
is not without its advantages as well, as I listed, and it works also
with a compiler.

Regards,

Andy
-- 
http://wingolog.org/



  reply	other threads:[~2011-12-14 15:55 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
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 [this message]
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=87mxav4072.fsf@pobox.com \
    --to=wingo@pobox.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).