unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Maciek Godek" <pstrychuj@gmail.com>
To: "Neil Jerram" <neiljerram@googlemail.com>
Cc: guile-user@gnu.org
Subject: Re: Me no understand scoping
Date: Sun, 10 Aug 2008 23:49:42 +0200	[thread overview]
Message-ID: <e2ceda030808101449r33a654eei352621e33172fe0a@mail.gmail.com> (raw)
In-Reply-To: <49dd78620808081354v292fd767q97d8f24bbdb9c6cf@mail.gmail.com>

2008/8/8 Neil Jerram <neiljerram@googlemail.com>:

>> The main reason is that there's no documented way
>> of accessing GOOPS objects from C (except from using
>> scm_c_eval_string etc.), or at least I couldn't find any
>> documentation for that.
>
> Yes, that's a fair point.  And one that keeps coming up.  I hope we
> can remedy this some time soon.

I obviously started to develop my own OO system -- purely
to understand everything. By the way I came up with some
conclusions regarding objects and classes and that is:
- a class can be implemented as a vector of three elements:
  * vector of methods (closures)
  * hash table mapping method names to their closures
  * hash table mapping slot names to vector indices.
- an object (instance) could also be implemented as a
simple vector -- its first field would be a reference to its
class, and the remaining ones would be the slots.

Interfacing such a system from the C level is rather
straightforward (or at least as straightforward as accessing
scm_vectors) and efficient.
(Perhaps goops does it more efficiently, I dunno)

>> I also get this unpleasant feeling that all these 'getters'
>> and 'setters' are entities multiplied beyond necessity
>> (even the infamous C++ doesn't explicate them)
>
> I don't understand you here.  And in any case, getters and setters are
> optional.  You can just use slot-ref and slot-set! if you prefer.

I bet you're right. I'm just learning and trying to justify all the
features that are provided by goops. Anyway, I can't get rid of
a feeling that many of them are redundant and quite random,
but I'm still examining it.

>> I'm really trying to get close
>> to the classical OOP notation: object.method() -- and
>> it's probably why I explore the potential of using these
>> "poor man's objects"
>
> Unfortunately that's only "classical" for non-Lisp-like languages!
> Still, I'd take your point if you said you wanted to write something
> that would be familiar to OO programmers in non-Lisp languages.

Fortunately Andy Wingo recommended his essay about this.

>> And so I never stopped to believe that (define x 5) is more or
>> less equivalent to (hash-set! global-scope 'x 5).
>
> Well yes.... but I'm afraid I'm still not sure how that leads us to
> local-eval !  Sorry if I'm being dumb about this!

Its genesis reaches the Kejtil's suggestion for accessing closure's
scope. The fact that it is possible in guile lead me to the conclusion
that it can be done to implement a simple oo system. (I'm just
beginning to realize how inefficient this can be).


Thanks a lot
M.




  reply	other threads:[~2008-08-10 21:49 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 [this message]
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
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=e2ceda030808101449r33a654eei352621e33172fe0a@mail.gmail.com \
    --to=pstrychuj@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=neiljerram@googlemail.com \
    /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).