unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: ken.dickey@whidbey.com
To: mikael@djurfeldt.com
Cc: guile-user@gnu.org
Subject: Re: Advice on ST-Object data-structure setup
Date: Sat, 20 Apr 2024 08:08:00 -0700	[thread overview]
Message-ID: <80cc9c65938b61e8209ef7be24663c7f@whidbey.com> (raw)
In-Reply-To: <CAA2Xvw+7qVis-84m--FuKy4Nqkq-Qf6V1OTMS6hSJxsy6xw1VQ@mail.gmail.com>

On 2024-04-20 02:49, Mikael Djurfeldt wrote:

> Have you looked at Guile's OOP system GOOPS?

Thanks, Mikael.

I have implemented a number of object systems, including CLOS style 
systems such as GOOPS.

The mismatch here is in the overhead of the multimethod dispatch.

I would like something fairly efficient -- and without using caches if 
possible.

You probably know/have seen this, but back to basics...

If you look at the `behavior` function in 
https://github.com/KenDickey/Crosstalk/blob/master/guile-st-kernel.scm 
you will see that the basic dispatch mechanism is (primLookup: (behavior 
self) selectorSym) where the lookup is just a hash-table lookup with 
suitable failure handling.

(define (primLookup: methodDict symbol)
   (hashtable-ref methodDict
                  symbol
                  (lambda (self . rest-args)
                    (send-failed self symbol rest-args)))
                    ;; (make-messageSend self symbol rest-args)))
)

The natural way to interoperate with Scheme data types is to use type 
tag as an array index into a vector of functions which return a suitable 
behavior/hash-table.

For generic Smalltalk objects, this is just the first slot of a vector 
of value slots.  For typical Scheme objects, this is a method-dictionary 
for that kind of object.  So Scheme vectors, numbers, #true, closures, 
and so forth just work as expected when viewed as Smalltalk Arrays, 
numbers, true, BlockClosures..

So after optimization, dispatch mechanics is just mask the tag, shift, 
index, hash, apply.

The hard parts have to do with thisContext (call/cc interactions) 
keeping a proper debugging context, and Smalltalk`become`.

It appears that Guile has evolved to have suitable low-level mechanisms 
to be able to do this.

I find things out by writing code.  "If it works, it must be possible."

So my investigation is to get a basic Smalltalk working and then get 
into the compilation and runtime mechanics to see if I can make this 
efficient enough.

Starting with a CLOS style dispatch is a bit further from where I want 
to end up.

Thanks again for the thoughtful comments,
-KenD



      parent reply	other threads:[~2024-04-20 15:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 21:14 Advice on ST-Object data-structure setup ken.dickey
2024-04-17  7:10 ` Basile Starynkevitch
2024-04-17  7:14   ` Basile Starynkevitch
2024-04-17 16:34     ` Maxime Devos
2024-04-17 14:28   ` ken.dickey
2024-04-17 16:34 ` Maxime Devos
2024-04-17 18:29   ` ken.dickey
2024-04-20  9:49 ` Mikael Djurfeldt
2024-04-20 10:03   ` Mikael Djurfeldt
2024-04-20 15:08   ` ken.dickey [this message]

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=80cc9c65938b61e8209ef7be24663c7f@whidbey.com \
    --to=ken.dickey@whidbey.com \
    --cc=guile-user@gnu.org \
    --cc=mikael@djurfeldt.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).