surprising immigrate behavior (?)
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Stuart Halloway <stuart.hallo... @gmail.com>
Date: Mon, 5 Oct 2009 11:11:27 -0400
Local: Mon, Oct 5 2009 11:11 am
Subject: surprising immigrate behavior (?)
A consequence of using immigrate is that vars intended for rebinding show up in multiple namespaces, and you have to be careful to get the right one: (use 'compojure)
; surprise: *errors* appear unbound! (binding [*errors* {:foo "bar"}] ((error-class text-field) :foo)) = > [:input {:type "text", :name "foo", :id "foo"}]
; correct binding (different var!) (binding [compojure.validation/*errors* {:foo "bar"}] ((error-class text-field) :foo)) => [:div.error [:input {:type "text", :name "foo", :id "foo"}]]
This is logical, given how immigrate works, but it still feels weird-- and it forces you to poke around in the "real" namespaces sometimes.
Is this a feature or a bug?
Stu
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Daniel Renfer <d... @kronkltd.net>
Date: Mon, 5 Oct 2009 11:58:07 -0400
Local: Mon, Oct 5 2009 11:58 am
Subject: Re: surprising immigrate behavior (?)
This is one of the very reason that I refuse to use any immigrated
namespaces in my own application. I got sick of seeing multiple copies
of vars because I used different levels of immigration all over the
place.
Don't get me wrong. The immigration is great for the simple case where
you can just require compojure and go, but IMO, it's better to use the
real namespaces when possible.
On Mon, Oct 5, 2009 at 11:11 AM, Stuart Halloway
<stuart.hallo
... @gmail.com> wrote:
> A consequence of using immigrate is that vars intended for rebinding
> show up in multiple namespaces, and you have to be careful to get the
> right one:
> (use 'compojure)
> ; surprise: *errors* appear unbound!
> (binding [*errors* {:foo "bar"}] ((error-class text-field) :foo))
> = > [:input {:type "text", :name "foo", :id "foo"}]
> ; correct binding (different var!)
> (binding [compojure.validation/*errors* {:foo "bar"}] ((error-class
> text-field) :foo))
> => [:div.error [:input {:type "text", :name "foo", :id "foo"}]]
> This is logical, given how immigrate works, but it still feels weird--
> and it forces you to poke around in the "real" namespaces sometimes.
> Is this a feature or a bug?
> Stu
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Brian Carper <briancar... @gmail.com>
Date: Mon, 5 Oct 2009 14:01:15 -0700 (PDT)
Local: Mon, Oct 5 2009 5:01 pm
Subject: Re: surprising immigrate behavior (?)
On Oct 5, 8:58 am, Daniel Renfer <d... @kronkltd.net> wrote:
> Don't get me wrong. The immigration is great for the simple case where
> you can just require compojure and go, but IMO, it's better to use the
> real namespaces when possible.
I must agree... I gave up on (use 'compojure) and friends and I refer
to the namespaces explicitly everywhere. The behavior was too
unpredictable.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
James Reeves <weavejes... @googlemail.com>
Date: Mon, 5 Oct 2009 16:32:21 -0700 (PDT)
Local: Mon, Oct 5 2009 7:32 pm
Subject: Re: surprising immigrate behavior (?)
On Oct 5, 11:11 am, Stuart Halloway <stuart.hallo... @gmail.com> wrote:
> This is logical, given how immigrate works, but it still feels weird--
> and it forces you to poke around in the "real" namespaces sometimes.
> Is this a feature or a bug?
I'm tempted to remove the immigrated namespaces altogether. They're
nice for "hello world" examples, but they can lead to unintuitive
behaviour.
- James
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Vagif Verdi <vagif.ve... @gmail.com>
Date: Thu, 8 Oct 2009 13:23:06 -0700 (PDT)
Local: Thurs, Oct 8 2009 4:23 pm
Subject: Re: surprising immigrate behavior (?)
On Oct 5, 4:32 pm, James Reeves <weavejes... @googlemail.com> wrote:
> I'm tempted to remove the immigrated namespaces altogether. They're
> nice for "hello world" examples, but they can lead to unintuitive
> behaviour.
How about a macro (use-group compojure) That will add a bunch of
defined uses ?
You must
Sign in before you can post messages.
You do not have the permission required to post.