Jump to content

User talk:Kevin Reid: Difference between revisions

reply re eql and =
(→‎eql and = in CL: new section)
(reply re eql and =)
Line 29:
I noticed the change from eql to = on [[Combinations]]. I'm not going to undo it or anything, but it's worth nothing that = takes an arbitrary number of args and will compare numbers of different types. I'd guess that most compilers have a specialized =2 (e.g., LispWorks has <code>system:=2</code>), but without type declarations or a compiler smart enough to figure out that the values are integers, = still has the overhead for different numeric types. It's why I (by default) use <code>eql</code> for comparing two integers.
[[User:Tayloj|Tayloj]] 04:58, 8 August 2009 (UTC)
 
Unless performance is at issue, code should be written to be clear. One heuristic for clarity is to use the most specific (reasonably) operator that applies to the types being worked with, so = rather than EQL for numbers. Also, = will compare integers and floats by value. With regard to performance: I could equally argue that a compiler with unboxed-number support but not a full set of optimizations would need to box the numbers to invoke EQL on them, but not for = since that is an always-numeric operator. So I can't agree with your performance assumption without actual benchmark data. --[[User:Kevin Reid|Kevin Reid]] 16:43, 8 August 2009 (UTC)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.