This works fine on my box:

foo=> (ns foo (require [clojure.core.async :refer [go <! chan >!!]]))
nil
foo=> (defmacro foo
 #_=>   [c]
 #_=>   `(<! ~c))
#'foo/foo
foo=>

foo=> (let [c (chan)]
 #_=>   (go (prn (foo c)))
 #_=>   (>!! c :hi))
:hi
nil
foo=>

Timothy Baldridge


On Mon, Aug 5, 2013 at 7:59 AM, Alice <dofflt...@gmail.com> wrote:

> I didn't have to fully qualify >! because I referred it using :refer. I'm
> Sorry if that was not clear.
>
>
> On Monday, August 5, 2013 10:45:16 PM UTC+9, tbc++ wrote:
>
>> Right, so if syntax quote fully qualifies unqualified symbols with the
>> current namespace, what good is user/>! to core.async? It has no clue that
>> you want that to be a put and not something else. So yes, either async/>!
>> or a fully qualified symbol is what you want here.
>>
>> Timothy Baldridge
>>
>>
>> On Mon, Aug 5, 2013 at 7:40 AM, Alice <doff...@gmail.com> wrote:
>>
>>> I'm not sure I understand your point. Syntax-quote fully qualifies
>>> unqualified symbols with the current namespace, so it shouldn't be a
>>> problem as long as I don't redefine the >! in the file that defines the
>>> macro. On the other hand, ~'>! would be dangerous because you don't know
>>> what it will be evaluated to in the user's namespace.
>>>
>>>
>>> On Monday, August 5, 2013 9:39:16 PM UTC+9, tbc++ wrote:
>>>
>>>> Your macro is incorrect. Notice what happens to un-namespaced symbols
>>>> inside a syntax quote:
>>>>
>>>> (ns 'user)
>>>> (macroexpand `(foo))
>>>>
>>>> =>(user/foo)
>>>>
>>>> So your use of >! is getting translated into mynamespace/>!. Core.async
>>>> sees your macro and expands it, it just doesn't condsider mynamespace/>! to
>>>> be a put! call. Instead it sees it as any other function.
>>>>
>>>> To get this to work the way you want, you need to do one of the
>>>> following
>>>>
>>>> `(~'>! c 42)
>>>>
>>>> or
>>>>
>>>> `(clojure.core.async/>! c 42)
>>>>
>>>> Or, if you've done the following
>>>>
>>>> (ns user
>>>>   (require [clojure.core.async :as async))
>>>>
>>>> Then you can do this:
>>>>
>>>> `(async/>! c 42)
>>>>
>>>> Timothy Baldridge
>>>>
>>>>
>>>> On Mon, Aug 5, 2013 at 5:52 AM, Tassilo Horn <ts...@gnu.org> wrote:
>>>>
>>>>> Alice <doff...@gmail.com> writes:
>>>>>
>>>>> > I didn't know that macros can do that!
>>>>>
>>>>> Then you might want to have a look at `macroexpand-1` and `macroexpand`
>>>>> from clojure.core and `mexpand-1`, `mexpand`, and `mexpand-all` from
>>>>> clojure.tools.macro.
>>>>>
>>>>> Bye,
>>>>> Tassilo
>>>>>
>>>>> --
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Clojure" group.
>>>>> To post to this group, send email to clo...@googlegroups.com
>>>>>
>>>>> Note that posts from new members are moderated - please be patient
>>>>> with your first post.
>>>>> To unsubscribe from this group, send email to
>>>>> clojure+u...@**googlegroups.com
>>>>>
>>>>> 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 unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to clojure+u...@**googlegroups.com.
>>>>>
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> “One of the main causes of the fall of the Roman Empire was
>>>> that–lacking zero–they had no way to indicate successful termination of
>>>> their C programs.”
>>>> (Robert Firth)
>>>>
>>>  --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@**googlegroups.com
>>> 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 unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> “One of the main causes of the fall of the Roman Empire was that–lacking
>> zero–they had no way to indicate successful termination of their C
>> programs.”
>> (Robert Firth)
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to