guile-user
[Top][All Lists]
Advanced

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

Re: A couple of questions about goops method parameters


From: Panicz Maciej Godek
Subject: Re: A couple of questions about goops method parameters
Date: Wed, 3 Sep 2014 18:20:49 +0200

Howdy,

> 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.

I'm not sure if I get the question right, but you usually overload the
"initialize" method (which calls (next-method)) and use the
"let-keywords" form if you want to add additional initialization
parameters

> 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?

This is a good question and I'd like to know the answer myself,
but it seems to me that GOOPS methods and keyword arguments are
simply incompatible. Obviously you can obtain default arguments in GOOPS
quite easily:

(define-method (f (x <t1>) (y <t2>))
  ...)

(define-method (f (x <t1>))
  (f x default-y-value))

(define-method (f)
  (f default-x-value))

One could also come up easily with a macro that allows to expand

(define-method/default (f (x <t1> default-x-value) (y <t2> default-y-value))
  ...)

to the above code. But I don't think that the goops dispatcher was
anyhow suited for the keyword arguments (I could be wrong, though)



reply via email to

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