IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 1 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Hold on here
Are you proposing to replace array of function pointers with a hash? Wouldn't it be a bit too slow? Are you saying that, say, Smalltalak does a lookup on method descriptor every time a message is passed?
--

It made Ketchup!
Sweet Ketchup!
Put it on a hot dog, put it on a burger,
Put it on your sister and she'll holler blody murder!
Sweet Ketchup.

--Tom Paxton.
New Not too slow
slower? OK sure.

We have GIGAHertz machines these days and smalltalk was originally working with decent performance on 8MHz boxes.

Now to be fair, ST has some tricks. One is that the very most common message sends to the most common objects are actually treated specially and implemented as byte code ops - its sort of the 80/20 rule. So for instance the #ifTrue: message

finished ifTrue: [ dosomething ]

is pedagogically implemented as a polymorphic message to Boolean with specializations in subclasses True and False - but this isn't how it *really* works. Instead the compiler generates special instructions for a small number of key messages (which you can change BTW). Loops are also treated specially.

Otherwise - yeah - there's a lookup. Its a pretty cheap lookup though.

Plus, having the methods in a method dictionary lets you do crazy things like create new kinds of scope, wacky fallback strategies, etc....

Smalltalk is an environment that will let you create pretty much any kind of programming model you like.






"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New C++ also uses lookups...
...when you declare your functions as Virtual - which is really the only proper way to do methods for objects.
New No
C++ uses an index into an array of function pointers. Very fast, not terribly future-proof. Smaltallk (if I get it right) uses hashing on actual function signature. For most cases. My head is still spinning.
--

It made Ketchup!
Sweet Ketchup!
Put it on a hot dog, put it on a burger,
Put it on your sister and she'll holler blody murder!
Sweet Ketchup.

--Tom Paxton.
New Method Dispatch in Smalltalk
Smaltalk (if I get it right) uses hashing on actual function signature. For most cases. My head is still spinning.

Strickly speaking, you are correct. However, most modern Smalltalks will optimize that lookup quite heavily. A Cincom developer once described to me the mechanism they use to make method lookups (on the average) faster than the typical implementation of C++ virtual method dispatch. Fascinating stuff!
--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Yep - pretty amazing stuff
It totally depends on the implementation and there are a lot of really clever tricks. It might not seem like it - but ST actually (sometimes) gets you closer to the metal in a lot of nifty ways than something like C. Its very freaky.

For instance, the opencroquet guys are moving a huge amount of rendering into graphics hardware despite the fact that you're calling it from Smalltalk with ST data structures.




"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
     OO Design in C - (Ovid) - (12)
         Hmm...If I were doing ObjectOrienteed in C - (Simon_Jester)
         Take a look at the source-code to Ruby - (ben_tilly)
         Lots of ways - (tuberculosis) - (8)
             That reminds me of another thread here. - (Another Scott) - (1)
                 Re: That reminds me of another thread here. - (neelk)
             Hold on here - (Arkadiy) - (5)
                 Not too slow - (tuberculosis) - (4)
                     C++ also uses lookups... - (ChrisR) - (3)
                         No - (Arkadiy) - (2)
                             Method Dispatch in Smalltalk - (JimWeirich) - (1)
                                 Yep - pretty amazing stuff - (tuberculosis)
         Free Book - (systems)

We come here for the righteous indignation and hilarity that follows.
91 ms