guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A couple of questions about goops method parameters


From: Carlos Pita
Subject: A couple of questions about goops method parameters
Date: Tue, 2 Sep 2014 23:05:02 -0300

Hi all,

I've some questions about parameter handling in goops methods:

1) initialize takes the initargs argument as a list, because of the
way make-instance is defined. But the documentation states:

    In theory, initarg … can have any structure that is understood by
whatever methods get applied when the initialize generic function is
applied to the newly allocated instance.

One could think this implies that initargs won't necessarily be packed
as a list. Indeed, that would be very convenient and sensible for
custom initialization methods. But make-instance is implemented as:

    (define-method (make-instance (class <class>) . initargs)
      (let ((instance (allocate-instance class initargs)))
        (initialize instance initargs)
        instance))

So one would need to rewrite it in order to apply initargs, or
something like that, in order to "unpack" the list.

How do you typically implement a custom initialization method, then?
Using pattern matching? Maybe ice-9 optargs? Maybe apply? Maybe you
directly call initialize? In any case, why is this so? Wouldn't it be
better for initialize to just get the "unpacked" argument list? This
perplexes me.

2) What is the relationship between the lambda* family and methods?
Are methods restricted in the sense that they can't aspire to get the
greater flexibility of lambda* parameter handling? Maybe because of
the way dispatching is done?

Thank you very much in advance for any help.

Best regards
--
Carlos



reply via email to

[Prev in Thread] Current Thread [Next in Thread]