I agree it's a little weird, but I think the resolution should be that
those calls throw just as they do in the JVM variant.  If they don't, it's
probably because it's too much of a performance hit to do so.

On Wed, Sep 13, 2017 at 1:57 PM Gary Trakhman <[email protected]>
wrote:

> This is specific to cljs, jvm clojure doesn't allow a nil in number ops
> and max doesn't allow 0 args.
>
> In general, clojure defers to the host for number operations since those
> often need to be fast and overhead-free, so this is showing some
> implementation details in the emitted javascript.
>
> I disagree that this is a 'referential transparency' issue when doing it
> creates the same result every time.  There's no 'references'.
>
> Upon inspecting, I notice that the emitted code for the apply
> cljs.core.apply.call(null,cljs.core.max,cljs.core.PersistentVector.EMPTY)
> returns 'undefined', where the emitted code for (max) is a bit different.
>  "function (){
> return ((1) > (function (){var x__24812__auto__ = null;
> var y__24813__auto__ = null;
> return ((x__24812__auto__ > y__24813__auto__) ? x__24812__auto__ :
> y__24813__auto__);
> })());
>
> I think the issue here is that 'max' is implemented as a macro but not
> when you use apply:
>
> https://github.com/clojure/clojurescript/blob/r1.9.908-12-g998933f/src/main/clojure/cljs/core.cljc#L1146
>
> https://github.com/clojure/clojurescript/blob/998933f5090254611b46a2b86626fb17cabc994a/src/main/cljs/cljs/core.cljs#L2649
>
> On Wed, Sep 13, 2017 at 1:40 PM <[email protected]> wrote:
>
>> Hi Everyone!
>>
>> I recently come up against an unexpected behavior in my program written
>> in cljs (version 1.7.145)
>> and I verified that the same problem happen with lumo.
>>
>> cljs.user=> (> 1 nil)
>> true
>> cljs.user=> (apply max [])
>> nil
>> cljs.user=> (> 1 (apply max []))
>> false
>>
>> This seems to be a problem of Referential Opacity and I think is due to
>> the fact that ">" is a macro.
>> But I'm not sure... Can someone give me a detailed explanation of the
>> reason? :)
>>
>> Thanks! :)
>>
>> --
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ClojureScript" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/clojurescript.
>>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to