Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

Given a function with one fixed argument and a vararg, it should be sufficient to force evaluation of 2 elements for apply to know which arity it should select, however it currently forces 3:

`
user=> (defn x ([a & b]))

'user/x

user=> (apply x (map println (iterate inc 0)))
0
1
2
nil
`

This makes lazy functions that use apply (for example mapcat) less lazy than they could be.
The proposed patch makes RT.boundedLength short-circuit immediately after the seq count is greater than the max fixed arity:

`
user=> (defn x ([a & b]))

'user/x

user=> (apply x (map println (iterate inc 0)))
0
1
nil
`

2 Answers

0 votes
by

Comment made by: bronsa

The patch in this ticket slightly improves the issue reported at http://dev.clojure.org/jira/browse/CLJ-1218

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1583 (reported by bronsa)
...