Because this is not the whole functionality ;d The check is just a
fragment, the one that doesn't work. There is much more to it, like taking
the object, taking some keys and values and using them in (let) and then
executing some code in this context (which is another parameter, which is
not in my example as I wanted to keep it simple).
If I could do it with a function, I would of course prefer it, but I am not
sure if it can work.

wujek


On Mon, Jan 14, 2013 at 3:41 PM, Jim foo.bar <[email protected]> wrote:

> Why does this have to be a macro? Why can't it be a first-class function
> instead?
>
> (defn with-obj [ob]
>  (if-let [obj-meta (meta ob)]  name
>   (throw (IllegalArgumentException. (str ob " seems not be our object")))))
>
> Jim
>
>
>
> On 14/01/13 14:34, Jim foo.bar wrote:
>
>> Of course you should know that built-in java types do not support
>> meta-data...You need to  implement IObj in order to provide meta-data
>> support to your own types...otherwise use records...
>>
>> Jim
>>
>>
>> On 14/01/13 14:32, Jim foo.bar wrote:
>>
>>> On 14/01/13 14:27, [email protected] wrote:
>>>
>>>> (defmacro with-obj [name]
>>>>  (let [obj-meta (meta name)]
>>>>   (if (or (nil? obj-meta)) ; (not (::my-obj obj-meta)))
>>>>    (throw (IllegalArgumentException. (str name " seems not be our
>>>> object")))))
>>>>  `(println "nice"))
>>>>
>>>>
>>>
>>> Try this:
>>>
>>>
>>> (defmacro with-obj [name]
>>>  `(if-let [obj-meta# (meta ~name)]
>>>     (println "nice")
>>>   (throw (IllegalArgumentException. (str ~name " seems not be our
>>> object")))))
>>>
>>> HTH...
>>>
>>> Jim
>>>
>>>
>>>
>>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscribe@**googlegroups.com<clojure%[email protected]>
> For more options, visit this group at
> http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to