chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Question about COOPS, generic methods, and modules


From: Felix
Subject: Re: [Chicken-users] Question about COOPS, generic methods, and modules
Date: Thu, 23 Sep 2010 04:15:59 -0400 (EDT)

From: Taylor Venable <address@hidden>
Subject: [Chicken-users] Question about COOPS, generic methods, and modules
Date: Wed, 22 Sep 2010 21:06:33 -0400

> Hi there!
> 
> I found this while writing some code for work earlier (I'm lucky enough to
> be able to write testing programs in the language of my choice). I define a
> class and a generic method in a module in a file, then load it into the
> REPL. I can make an instance of that class, binding it to a variable at the
> toplevel, and use the generic method just fine. If I then reload my code, I
> cannot use the generic method with the bound instance: I get the "no method
> defined for given argument classes" error. If my class and generic method
> definitions are not in a module, everything works fine. I'm wondering if
> this is me misunderstanding something, or it is intentional behaviour, or
> maybe it's a bug. Here is a concrete example:
> 

`define-method' is basically only working if you had a previous
`define-generic' definition for that method. To allow extending
previously existing generics and for convenience, `define-method' will
do an implicit `define-generic' if the syntactic/import environment
does not contain a toplevel binding for this method-name. Inside a
module, the syntactic environment will only contain what has been
imported. In your second example, the module will create a fresh
generic, removing the one that previously existed, since `lols' has
not been imported and is thus not visible.


cheers,
felix



reply via email to

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