On Tue, Apr 30, 2013 at 10:51 AM, Tassilo Horn wrote:
> "Jim - FooBar();" 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 ca
On Tue, Apr 30, 2013 at 11:00 AM, Tassilo Horn wrote:
> Gary Trakhman 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 h
Gary Trakhman 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
"unbound" is a value, to
AtKaaZ 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 binding", so I thi
"Jim - FooBar();" 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 bound to a init/
On Apr 29, 2013 1:07 PM, "Jonathan Fischer Friberg"
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 nil as the ini
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 wrote:
> the pain with that is that it wouldn't work inside a function where a
> would be the function pa
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 wrote:
> Try this:
>
> user=> (def a)
> #'user/a
> user=> (b
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 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
thank you, I'll look into protocols
On Mon, Apr 29, 2013 at 7:54 PM, Gary Trakhman wrote:
> 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-ca
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 al
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, Apr
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 wrote:
> If you're passing the va
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 29/04
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 wrote:
> Seems like a good idea to have the root binding be nil. How would you
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 wrote:
> Why not make the root binding nil? If your decorate function is supposed
> to handle all vars
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
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(); wrote:
> 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)
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
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
#
=> (nil? a)
false
=> (bound? a)
ClassCastException clojure.lang.Var$Unbound cannot be cast to
clojure.lang.Var
20 matches
Mail list logo