From: Jecel A. Jr <je...@me...> - 2004-04-08 14:32:06
|
Ooops... I sent this only to Ian the first time instead of the list. He wrote a very nice reply giving even more examples of why this is a good idea. On Wednesday 07 April 2004 22:02, Ian Piumarta wrote: > Which reminds me of something else Dan & I talked about in the past: > evaluating arguments from right to left. Saves an awful lot of > tedious peeking into the middle of the stack to pick up the receiver. > (Combined with the above, potentially wins Really Big for 386 too. > OTOH, the tradeoffs for register architectures are a little more > complex.) My Neo Smalltalk evaluates right-to-left. That lets me get by with just one send instruction. The first instructions in a compiled method grab the right number of arguments from the caller's stack. Unless it is a short leaf method - in that case it can skip creating its own stack and run directly with the caller's stack. This is a very common case since I currently do very little inlining (just the usual ifTrue: stuff). In the green book Dan mentioned that the change to left-to-right from Smalltlak-78 to -80 was supposed to make people stop complaining about surprising results and to make creating really simple compilers possible. I didn't get this last part as the right-to-left order is easier in the recursive compilers I have written so far. -- Jecel P.S.: I hope comparing how my own and other implementations (I am very familiar with Self, for example) do things isn't too annoying. If it is, please let me know |