Jim - FooBar(); jimpil1...@gmail.com writes:
funny you should mention that!!! that is exactly what I meant by 'my
fault'...I've come to realise that dynamic scope is almost evil, thus
I go to great lengths to avoid it completely...in the rare cases where
I do use it I always make sure it is
AtKaaZ atk...@gmail.com writes:
Seems like a good idea to have the root binding be nil. How would you
make it check for bound inside the function? do we need some kind of
macro?
If the var has a root binding of nil, then you can't distinguish the
cases explicitly bound to nil and root
Gary Trakhman gary.trakh...@gmail.com writes:
If you're passing the var itself, I don't see why you'd need a macro.
If you want to check the namespace for a var matching an unquoted
symbol, you could do that in a macro.
In case you really don't have the var itself but just its value, then
On Tue, Apr 30, 2013 at 11:00 AM, Tassilo Horn t...@gnu.org wrote:
Gary Trakhman gary.trakh...@gmail.com writes:
If you're passing the var itself, I don't see why you'd need a macro.
If you want to check the namespace for a var matching an unquoted
symbol, you could do that in a macro.
On Tue, Apr 30, 2013 at 10:51 AM, Tassilo Horn t...@gnu.org wrote:
Jim - FooBar(); jimpil1...@gmail.com writes:
funny you should mention that!!! that is exactly what I meant by 'my
fault'...I've come to realise that dynamic scope is almost evil, thus
I go to great lengths to avoid it
How do you guys handle the cases when the var is unbound? I mean
specifically in the cases where you just test if the var is nil.
= (def a)
#'clojurewerkz.titanium.graph-test/a
= a
#Unbound Unbound: #'clojurewerkz.titanium.graph-test/a
= (nil? a)
false
= (bound? a)
ClassCastException
I 've found that whenever I get a var-unbound exception it is almost
always my fault and my fault only...why would you do (def a) anyway?
Jim
On 29/04/13 16:32, AtKaaZ wrote:
How do you guys handle the cases when the var is unbound? I mean
specifically in the cases where you just test if the
I'm thinking something like (def ^:dynamic *a*) where it would make more
sense that it's unbound at first
On Mon, Apr 29, 2013 at 7:00 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:
I 've found that whenever I get a var-unbound exception it is almost
always my fault and my fault only...why
Why not make the root binding nil? If your decorate function is supposed
to handle all vars, then they have to deal with the unbound case as that's
part of the contract of vars.
If it's a generic thing, then maybe make a multimethod or protocol for it.
On Mon, Apr 29, 2013 at 12:17 PM, AtKaaZ
Seems like a good idea to have the root binding be nil. How would you make
it check for bound inside the function? do we need some kind of macro?
On Mon, Apr 29, 2013 at 7:23 PM, Gary Trakhman gary.trakh...@gmail.comwrote:
Why not make the root binding nil? If your decorate function is
If you're passing the var itself, I don't see why you'd need a macro. If
you want to check the namespace for a var matching an unquoted symbol, you
could do that in a macro.
On Mon, Apr 29, 2013 at 12:29 PM, AtKaaZ atk...@gmail.com wrote:
Seems like a good idea to have the root binding be
funny you should mention that!!! that is exactly what I meant by 'my
fault'...I've come to realise that dynamic scope is almost evil, thus I
go to great lengths to avoid it completely...in the rare cases where I
do use it I always make sure it is bound to a init/default value :)
Jim
On
I'm thinking of a hacky way of doing it...
(def a nil)
(def b)
= (defn x [in]
(when (not (nil? in)) (.v in)))
#'clojurewerkz.titanium.graph-test/x
= (x b)
#'clojurewerkz.titanium.graph-test/b
= (x a)
nil
On Mon, Apr 29, 2013 at 7:31 PM, Gary Trakhman gary.trakh...@gmail.comwrote:
If
oh right, you mean that I should pass the var like (decorate #'a), I didn't
get that when I first read it. But suppose I'm just passing the
whatever-that-is (value?) like (decorate a) do I need to use a macro inside
the decorate function to check if the passed thing is an unbound var?
On Mon,
You would only need a macro if you want to pass in 'a' and mean #'a.
Syntactic abstraction. Like I said, I'd make the implementation
polymorphic on that value via a protocol so you're not special-casing it
within the function itself. Protocols are open for extension so someone
else could come
thank you, I'll look into protocols
On Mon, Apr 29, 2013 at 7:54 PM, Gary Trakhman gary.trakh...@gmail.comwrote:
You would only need a macro if you want to pass in 'a' and mean #'a.
Syntactic abstraction. Like I said, I'd make the implementation
polymorphic on that value via a protocol so
Try this:
user= (def a)
#'user/a
user= (bound? (var a))
false
user= (def a nil)
#'user/a
user= (bound? (var a))
true
Sean
On Mon, Apr 29, 2013 at 8:32 AM, AtKaaZ atk...@gmail.com wrote:
How do you guys handle the cases when the var is unbound? I mean
specifically in the cases where you just
the pain with that is that it wouldn't work inside a function where a would
be the function parameter, ok it would work in a macro but inside a
function... that would be interesting to see
On Mon, Apr 29, 2013 at 9:01 PM, Sean Corfield seancorfi...@gmail.comwrote:
Try this:
user= (def a)
If you don't want to set the initial value to nil, set it to ::unbound or
similar. Should be very
hard to accidentally bind the same value.
Jonathan
On Mon, Apr 29, 2013 at 8:04 PM, AtKaaZ atk...@gmail.com wrote:
the pain with that is that it wouldn't work inside a function where a
would be
On Apr 29, 2013 1:07 PM, Jonathan Fischer Friberg odysso...@gmail.com
wrote:
If you don't want to set the initial value to nil, set it to ::unbound or
similar. Should be very
hard to accidentally bind the same value.
Please take Jonathan's advice if nil is a valid value for a user to bind;
use
20 matches
Mail list logo