<< Back to previous view

[MCOMB-7] Fix reflection errors Created: 03/May/16  Updated: 03/May/16

Status: Open
Project: math.combinatorics
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Mark Engelberg
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File box-longs.patch    

 Description   

I get several reflection errors compiling math.combinatorics 0.1.1 on Clojure 1.8.

They were quite confusing to fix, but refactoring loops into multi-arity functions consistently fixed these errors.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 03/May/16 12:43 PM ]

Patch fixes reflection errors in Clojure 1.8.

Comment by Mark Engelberg [ 03/May/16 2:48 PM ]

These loop auto-boxing warnings are because integer literals are now read in as primitive longs (since 1.6?), but these loops want boxed longs.

The simplest fix, I think, would be to replace the literals in the loop args with boxed longs. So, for example, 1 becomes (Long. 1). I believe that this is what the compiler does automatically when it sees that recur isn't passing in a primitive long (thus the warning that it is auto-boxing the loop arg), so I don't think it would have any impact on performance (this isn't actually a warning that it needs to do reflection at runtime), but it would make the warning disappear.

Breaking the loop out into a separate function strikes me as a heavy-handed solution (it makes the warning disappear because Clojure boxes numbers on function calls unless otherwise annotated, but there's really no need to break it into a separate function).

Comment by Ambrose Bonnaire-Sergeant [ 03/May/16 3:26 PM ]

Ah. My understanding here is limited. Would you like me to work on another patch with those suggestions?

Comment by Mark Engelberg [ 03/May/16 7:10 PM ]

Sure. I'm pretty sure there's no performance penalty in its current form, but if you find the warnings a nuisance and don't mind creating another patch, that would be great.

Comment by Ambrose Bonnaire-Sergeant [ 03/May/16 8:32 PM ]

New patch that explicitly boxes Long's to work around reflection errors, as suggested by Mark.





Generated at Wed May 04 10:38:21 CDT 2016 using JIRA 4.4#649-r158309.