So there's some sort of "boxing" going on here where the nil produced
as the values of s-expressions are actually Objects which are nulls,
while literal nils are actually nulls?
Such as in java where:
Object t = null;
Thread r = new Thread((String) t);
is valid but
Thread r = new Thread(null);
is not ?
Isn't this breaking referential transparency that (Thread. ((fn [])))
and (Thread. nil) are not the same (you can't replace a function call
with it's value in this case)? This is not the behaviour I would
expect at all, as it would make any clojure function with a nil in
it's range no longer pure.
--Robert McIntyre
On Tue, Dec 28, 2010 at 3:53 AM, Alex Osborne <[email protected]> wrote:
> Robert McIntyre <[email protected]> writes:
>
>> seems there's no type hint required:
>>
>> (def t nil)
>> (Thread. t)
>>
>> also works...
>>
>> How are you able to determine that it's calling the String constructor?
>>
>> --Robert McIntyre
>
> Ah, no I'm wrong. I was jumping to conclusions. It's the Runnable
> one:
>
> (let [^String o nil] (Thread. o)) ; error
>
> (let [^Runnable o nil] (Thread. o)) ; no error
>
> --
> 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
--
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