Re: checking if a method is defined

2012-03-03 Thread Herwig Hochleitner
Also keep in mind, that in (.something obj), the compiler doesn't see a call to .method, but the whole thing is desugared into a call to the dot form: (. obj something). Since . is a special form, it is always defined. So when trying to analyze a call to the dot special form, keep in mind that the

Re: checking if a method is defined

2012-02-29 Thread Meikel Brandmeyer (kotarak)
Hi, as others said: to check that a protocol function exists you can use resolve as with every other function. If you wanted to know, whether a type participates in a protocol directly, you would check whether it implements the protocol's interface . user=> (defprotocol Foo (foo [this])) Foo u

Re: checking if a method is defined

2012-02-29 Thread Armando Blancas
> > What should I be using to check that the symbol .firstName and > .fullName are defined in the current scope? > "fullName" is easier because it gets interned in the current namespace: user=> (ns-interns 'user) {fullName #'user/fullName, ->Person #'user/->Person,

Re: checking if a method is defined

2012-02-29 Thread Cedric Greevey
On Wed, Feb 29, 2012 at 5:12 PM, Frank Wilson wrote: > Hi, > > The behaviour of resolve for named functions seems pretty clear to me: > > (resolve 'xyz) > > returns nil  (when xyz has not been defined). > > and > > (defn xyz [x] 1) > > (resolve 'xyz) > > returns #'user/xyz (when xyz is defined) >

checking if a method is defined

2012-02-29 Thread Frank Wilson
Hi, The behaviour of resolve for named functions seems pretty clear to me: (resolve 'xyz) returns nil (when xyz has not been defined). and (defn xyz [x] 1) (resolve 'xyz) returns #'user/xyz (when xyz is defined) However if I try to define types: (defprotocol Named (fullName [Named]))