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: Closure?
Date: Mon, 14 Jul 2008 23:14:59 +0200	[thread overview]
Message-ID: <e2ceda030807141414s65a19603k77f46eaa1dd33f14@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0807141815040.5269@ttleush>

Kjetil S. Matheussen:

> I think local-eval is necessary for making
> a namespace system of the below type without having to use
> codewalking macros to expand the bodies of functions:
>
> (define-namespace bank)
> (def-bank sum 0)
> (def-bank (add n)
>  (set! sum (+ n sum)) ;; Note that it's enough to write "sum".
>
> (bank.add 50)
> bank.sum
> => 50

This certainly looks like trashing global namespace
(which isn't good in the long run) and doesn't allow you
to have object handlers (like many variables referring
to the same object) without additional quirks.

> But for implementing a message passing OO system,
> it's easier to use macros and hash tables, plus
> that it probably performs much better:

Pefrorms better than local-eval or better than
define-namespace?

> (def-class <bank>
>   (def-var sum 0)
>   (def-method (add n)
>      (set! sum (+ n sum)))
>
> (define bank (new <bank>))
> (-> bank add 50)
> (-> bank sum)
> => 50
>
> There's a bunch of these systems for scheme.
> The syntax above is used from
> http://snd.cvs.sourceforge.net/snd/cvs-snd/oo.scm?view=log
>
> Guile's own OO system called GOOPS is also very nice.
> GOOPS a quite verbose but very powerful and a lot
> more interactive. It's similar to CL's CLOS, which
> you should look at if you are not familiar with
> already.

Well, I've read some documentation of GOOPS and then
I took a glimpse at its source. It has at least a few
disadvantages, for it is an object system implemented in
scheme -- it is therefore hard to access its objects from C
(while closures are easily accessible through
scm_local_eval) and it probably won't run as fast as
local-eval, at least conceptually.

(It is essential to observe that closures are already like
objects and that any additional object systems are doubtfully
needed with closures implemented properly -- as long as
you can access their scope)

Yet still I reserve the right to be wrong as a newbie :)




  reply	other threads:[~2008-07-14 21:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cmu-lmtpd-15105-1216051603-3@mail-imap1.uio.no>
2008-07-14 16:30 ` Closure? Kjetil S. Matheussen
2008-07-14 21:14   ` Maciek Godek [this message]
     [not found]   ` <e2ceda030807141414i5acef7d1h37d12d14e01cc1d@mail.gmail.com>
2008-07-14 21:41     ` Closure? Kjetil S. Matheussen
2008-07-14 22:46       ` Closure? Maciek Godek
     [not found] <cmu-lmtpd-26382-1215792454-10@mail-imap1.uio.no>
2008-07-11 17:42 ` Closure? Kjetil S. Matheussen
2008-07-11 17:47   ` Closure? Kjetil S. Matheussen
2008-07-11 20:54     ` Closure? Maciek Godek
2008-07-12 11:47       ` Closure? Kjetil S. Matheussen
2008-07-13  6:59         ` Closure? Maciek Godek
2008-07-12 22:43     ` Closure? Neil Jerram
2008-07-15  7:59       ` Closure? Ludovic Courtès
2008-07-15  9:11         ` Closure? Andy Wingo
2008-07-16 16:42           ` Closure? Ludovic Courtès
2008-07-11 14:48 Closure? Maciek Godek
2008-07-11 15:01 ` Closure? Ludovic Courtès
2008-07-11 15:32   ` Closure? Maciek Godek
2008-07-12 22:57 ` Closure? Neil Jerram
2008-07-13  6:57   ` Closure? Maciek Godek
2008-07-13 22:56     ` Closure? Neil Jerram
2008-07-14  1:15       ` Closure? Maciek Godek

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=e2ceda030807141414s65a19603k77f46eaa1dd33f14@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).