In Squeak, what is the cost of using an accessor vs. a direct call to the ivar? In VisualAge, for example, the compiler optimizes a send to an accessor and makes it equivalent to a direct access. At least, I believe it is - I'll have to run tests to verify. I think this is true with other dialects as well.
Jeff Odell
----- Original Message ----- From: Carl Gundel morphic@hotmail.com To: squeak@cs.uiuc.edu Sent: Saturday, July 31, 1999 1:03 PM Subject: re: Please use accessors!
From: Alan Lovejoy sourcery@pacbell.net Reply-To: squeak@cs.uiuc.edu
<big snip> >8. Given the above, I would avoid being dogmatic on this >issue. I think the fact that so many good Smalltalk programmers >still access instance variables directly, and that code that commits >this "sin" has lasted unchanged for so long, should cause one to >at least question whether or not it's all that sinful. <snip>
Thanks for the brain dump Alan! :-)
I understand the pragmatics of this issue well, but I feel compelled to
make
a counterpoint about the above. Code that accesses ivars directly can be brittle. In particular, code which uses both direct access and accessor methods on the same ivars can behave in unpredictable ways. Sometimes
such
code survives for a very long time because it is brittle and hard to understand, and no one wants to touch it for fear of breaking it.
I tend to defer writing code which accesses ivars directly until
performance
tuning time. I wish I never had to write such code because it hurt the maintainability and extensibility of my design, but I live in the real
world
(oh Bah!).
Thanks again!
-Carl
Get Free Email and Do More On The Web. Visit http://www.msn.com