unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Krister Svanlund <krister.svanlund@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Fwd: Making every goops object applicable
Date: Tue, 15 May 2012 02:46:03 +0200	[thread overview]
Message-ID: <CAO_vGe8nGc+O1v-2aWwhP0qTykSiyT=m5A8FV1Wq0EH9h1xdNQ@mail.gmail.com> (raw)
In-Reply-To: <CAO_vGe-fjX4iHusc5FdLV89i6+eBt3iCF4KP_S43LbP2ZQu4UA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2909 bytes --]

---------- Forwarded message ----------
From: Krister Svanlund <krister.svanlund@gmail.com>
Date: Tue, May 15, 2012 at 2:45 AM
Subject: Re: Making every goops object applicable
To: Mark H Weaver <mhw@netris.org>


On Tue, May 15, 2012 at 12:16 AM, Mark H Weaver <mhw@netris.org> wrote:

> Krister Svanlund <krister.svanlund@gmail.com> writes:
> > In our work to look into how Python 3 could be implemented for Guile
> > we have figured out that the only way to make a goops object
> > applicable is to have it inherit <applicable-struct>. This does not
> > always work the way it could be expected, for example when inheriting
> > from several classes.
>
> Can you elaborate on what doesn't work as expected?
>

For example an instance of a class inheriting a class that inherits
<applicable-struct> that defines 'procedure is not applicable.


>
> > Apparently this works by some flag being set by
> > <applicable-strukt> in libguile for the object and that flag is
> > checked during application, calling the 'procedure slot if it's set
> > with some optimization assuming that 'procedure is the first slot.
> > Is this correct and if so, is there any particular reasoning behind
> > this rather than just having all classes that has the slot 'procedure
> > be applicable?
>
> I see at least two problems with your suggestion: (1) it would be very
> slow to search the list of slots for a slot named 'procedure' on every
> application.  (2) a user might create a class with a slot named
> 'procedure' without intending that the slot should be used in this way.
>

(1) Given that slots aren't dynamic at runtime (as they are in Python for
example) and there is already some magic being done by <applicable-struct>
I have a hard time seeing how looking up a slot for application can't be
done in almost constant time (one look-up and then storing a pointer to the
position of the slot for future applications) and only a tiny bit slower
than the current implementation. And after all, Guile is, judging by it's
documentation, focused on being an extension language where the heavy
lifting is supposed to be done in C code.
(2) This I'm not entirely sure how to fix but I have the impression that
this could be done analogous to the initialization method of the
meta-object protocol, but I assume this could require some severe internal
changes and in fact slow down applications in general in Guile. My thought
is that you simply have a metaclass that has a method ('apply or similar)
that specifies what will happen if an instance of any of it's classes is
being used as a function.

I'm mostly interested in getting all possible input about how good/bad of
an idea this is so please prove (in the looses sense of the word) that I'm
wrong. When I have some free time this summer I will probably make an
attempt at doing this anyhow, I just want to know what I'm getting myself
into.

Yours,
Krister Svanlund

[-- Attachment #2: Type: text/html, Size: 3942 bytes --]

  parent reply	other threads:[~2012-05-15  0:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-14 17:24 Making every goops object applicable Krister Svanlund
2012-05-14 22:16 ` Mark H Weaver
     [not found]   ` <CAO_vGe-fjX4iHusc5FdLV89i6+eBt3iCF4KP_S43LbP2ZQu4UA@mail.gmail.com>
2012-05-15  0:46     ` Krister Svanlund [this message]
2012-05-15 15:46     ` Mark H Weaver
2012-05-15 19:43       ` Neil Jerram
2012-05-16  5:18         ` Mark H Weaver
2012-05-15 12:31 ` Ludovic Courtès
2012-05-15 18:36 ` Andy Wingo

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='CAO_vGe8nGc+O1v-2aWwhP0qTykSiyT=m5A8FV1Wq0EH9h1xdNQ@mail.gmail.com' \
    --to=krister.svanlund@gmail.com \
    --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).