unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Maciek Godek" <pstrychuj@gmail.com>
To: guile-user@gnu.org
Subject: Re: Me no understand scoping
Date: Sat, 2 Aug 2008 00:00:10 +0200	[thread overview]
Message-ID: <e2ceda030808011500ua612e89yb02148dde0a2fd5a@mail.gmail.com> (raw)
In-Reply-To: <874p657gyo.fsf@unknownlamer.org>

2008/8/1 Clinton Ebadi <clinton@unknownlamer.org>:
>
> module-define! MODULE NAME VALUE
>
> e.g.
> (let ((foo 'bar))
>  (module-define! (current-module) foo 5)
>  bar)
> => 5
>
> Issue: this will be a top level binding, but a solution using `eval'
> would also produce a top level binding (as it executes there to allow
> lexical environments to be optimized...).

I've been trying to make it using local-eval to be able
to make a definition within a closure. There's only a
tiny problem: it's not working. When I execute:
(local-eval (list 'define a 5) (the-environment))
everything works fine, but when I make a function of it,
(define (define@ name value) (local-eval (list 'define name value)
(the-environment)))
and when I invoke it, it breaks with "Bad define placement".
The problem gets solved when I make a macro of it:
(define-macro (define@ name value) `(local-eval (list define ,name
,value)(the-environment)))
but it still breaks when called from a nested local-eval.

> Doing such things, however, is fairly unschemey.

What things and why?

What I'm trying to do is to understand the rules of making
and using environments. As for now, these rules seem to be quite
random and unpredictable (so it's rather hard to call them rules
actually), which is sad because closures are a very powerful
yet simple mechanism (definitely simpler than what GOOPS or
CLOS have to offer if it comes to OOP -- both in concepts and
implementation)

See you around :)
M.




  reply	other threads:[~2008-08-01 22:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-29 21:18 Me no understand scoping Maciek Godek
2008-07-30  3:24 ` Clinton Ebadi
2008-07-30  8:42   ` Maciek Godek
2008-07-30 14:03     ` Jon Wilson
2008-07-30 15:04       ` Klaus Schilling
2008-07-30 19:24       ` Maciek Godek
2008-07-31  7:20         ` Neil Jerram
2008-07-31 19:21           ` Maciek Godek
2008-07-31 21:37             ` Neil Jerram
2008-07-31 23:07               ` Maciek Godek
2008-08-02 17:43                 ` Neil Jerram
2008-08-02 21:36                   ` Maciek Godek
2008-08-08 20:54                     ` Neil Jerram
2008-08-10 21:49                       ` Maciek Godek
2008-08-09 11:05                     ` Andy Wingo
2008-08-10 22:30                       ` Maciek Godek
2008-09-11 14:56                       ` JonWilson
2008-07-31 23:48             ` Clinton Ebadi
2008-08-01 22:00               ` Maciek Godek [this message]
2008-08-02  5:13                 ` Jon Wilson
2008-08-02 21:35                   ` Maciek Godek
     [not found] <cmu-lmtpd-29005-1217434291-0@mail-imap1.uio.no>
2008-07-30 16:18 ` Kjetil S. Matheussen
2008-07-30 19:03   ` Clinton Ebadi

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=e2ceda030808011500ua612e89yb02148dde0a2fd5a@mail.gmail.com \
    --to=pstrychuj@gmail.com \
    --cc=guile-user@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).