Re: diff. betw. equal and eq on simbols



Nikola Skoric wrote:
I've been reading "COMMON LISP: A Gentle Introduction to Symbolic Computation" by David S. Touretzky, and came across a section where he describes difference between eq and equal. And, says "Due to its greater efficiency, programmers often use EQ instead of EQUAL when symbols are being compared." Now, why would eq be more efficient than equal when comparing only one symbol?

EQ doesn't need to perform checks of which types the arguments are, but can just blindly perform a comparison of the pointers itself. EQL has to perform a test whether the arguments are numers, characters or other objects, and EQUAL has to perform even more checks in the general case. The loss of efficiency is due to the overhead spent on the type tests.



Pascal

--
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
.



Relevant Pages

  • Re: diff. betw. equal and eq on simbols
    ... > Computation" by David S. Touretzky, and came across a section where he ... > efficiency, programmers often use EQ instead of EQUAL when symbols are ... > comparing only one symbol? ...
    (comp.lang.lisp)
  • Re: Downside to Methanol
    ... That 37% is about twice the efficiency of an internal combustion engine, ... You are also comparing the optimum peak PEM output with a plain old ICE ... Efficiency over the power curve of PEM will not be the optimum. ... "We need an energy policy that encourages consumption" ...
    (sci.energy.hydrogen)
  • Re: Most efficient way of adding to a list?
    ... > better to define it with defparameter from the start). ... > and that's what got me thinking about efficiency in the first place. ... scan/traversal of your items list comparing each element to the new ... My real e-mail is ...
    (comp.lang.lisp)
  • Re: diff. betw. equal and eq on simbols
    ... >>> efficiency, programmers often use EQ instead of EQUAL when symbols are ... >>> comparing only one symbol? ... I'll get myself a interpreter which will be smart enough to check ...
    (comp.lang.lisp)
  • Re: Geared unicycles? Old hat
    ... >I don't know what they're comparing the efficiency to. ... >comparing it to an automatic automobile transmission ... Note how they say powertrain SYSTEM efficiency. ...
    (rec.sport.unicycling)