Basically, i'm trying to automatically define a method which expands into something like this:
(defmethod general-walker::application-form ...)
This code is in another package. The problem is getting the general-walker::application-form to be produced. I don't want to export the symbol application-form from general-walker package. I tried (find-symbol 'application-form :general-walker), but it only returns a symbol which has been inhereted from another package (:arnesi). So, all in all, i want to be able to find multiple symbols in a package which have the same name (they're both method names). How can i do this?
Thx!
Symbols
Re: Symbols
What do you mean "automatically"? Are you trying to do it at runtime?Harnon wrote:Basically, i'm trying to automatically define a method
Why?This code is in another package.
You can't do that.i want to be able to find multiple symbols in a package which have the same name
Within one package, any particular name can refer to at most one symbol.
You can't access methods directly. You can only define them and then call or pass the corresponding generic function.(they're both method names)
Can you say more about your application? Maybe there's a simpler way to do what you have in mind.
--Dan B.
Re: Symbols
Sorry, i was in a rush, i wasn't thinking. I actually didn't need to do this, but here's a convoluted example to demonstrate my question, which i guess has no practical use .
Question rephrased: Let's say there is a package, named arnesi, which exports the symbol walker. This symbol is actually the name of a method. The package :general-walker uses the arnesi package, but also defines a method named
walker which specializes on a different class. Since you can create methods with the same name, there'll be no error. So, the question is, if you try to find the symbol 'walker in package :general-walker, will it return the inherited method symbol from arnesi or that from general-walker? Why? On lispworks, using (find-symbol 'walker :general-walker) will return (values 'arnesi:walker :external). I half expected it to return (values 'general-walker::walker :internal)
Question rephrased: Let's say there is a package, named arnesi, which exports the symbol walker. This symbol is actually the name of a method. The package :general-walker uses the arnesi package, but also defines a method named
walker which specializes on a different class. Since you can create methods with the same name, there'll be no error. So, the question is, if you try to find the symbol 'walker in package :general-walker, will it return the inherited method symbol from arnesi or that from general-walker? Why? On lispworks, using (find-symbol 'walker :general-walker) will return (values 'arnesi:walker :external). I half expected it to return (values 'general-walker::walker :internal)
Code: Select all
(defpackage :arnesi (:use :cl) (:export :walker :application-form))
(in-package :arnesi)
(defclass application-form () ())
(defmethod walker ((class application-form)) (print "arnesi-walker"))
(defpackage :general-walker (:use :cl :arnesi) (:export :walker))
(in-package :general-walker)
(defmethod walker ((class application-form))
(print "general-walker-form"))
(defpackage :test (:use :cl ))
(in-package :test)
(find-symbol 'walker :general-walker)
Re: Symbols
WALKER is created in ARNESI, so its SYMBOL-PACKAGE is ARNESI. Because when you inherit a symbol it is the same symbol its SYMBOL-PACKAGE doesn't change.
Re: Symbols
As qbg said, GENERAL-WALKER uses the existing symbol in ARNESI. It doesn't create a new one. So general-walker:walker is EQ to arnesi:walker. The methods have to be named by exactly the same symbol to be dispatched by the same generic function.Harnon wrote:So, the question is, if you try to find the symbol 'walker in package :general-walker, will it return the inherited method symbol from arnesi or that from general-walker? Why?
In SBCL, (find-symbol "WALKER" :general-walker) returns ARNESI:WALKER and :INHERITED.On lispworks, using (find-symbol 'walker :general-walker) will return (values 'arnesi:walker :external). I half expected it to return (values 'general-walker::walker :internal)
--Dan B.
Re: Symbols
Thxs! I guess that clear up my not-so-useful question