2011/2/15 Eliot Miranda <eliot.miranda@gmail.com>:
On Tue, Feb 15, 2011 at 11:18 AM, Igor Stasenko <siguctua@gmail.com> wrote:
On 15 February 2011 19:59, Eliot Miranda <eliot.miranda@gmail.com> wrote:
On Mon, Feb 14, 2011 at 11:00 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Eliot
you use caseOf: for the generation of C in Slang and VM maker. Now this means that     - it does not need to be inlined
No. Â If it is not inlined the simulator will go *much* slower. Â e.g. CogVMSimulatorLSB>>byteAt: byteAddress | lowBits long | lowBits := byteAddress bitAnd: 3. long := self longAt: byteAddress - lowBits. ^(lowBits caseOf: { [0] -> [ long ]. [1] -> [ long bitShift: -8 Â ]. [2] -> [ long bitShift: -16 ]. [3] -> [ long bitShift: -24 ] }) bitAnd: 16rFF
so why not put it:
^ (long bitShift: (-8*lowBits) ) bitAnd: 16rFF
? Or this will be slower than caseOf: ?
Because that was the way the code was written. Â I just copied the method. Â Further, it is only one example. Â I'm not going to rewrite the VMMaker's uses of caseOf: jyst to suit some whim of purity. Â It is making unnecessary work. Â Taking it out is *much* more work (/and/ emotional energy) than just leaving it alone. Â Can't we try and be constructive?
I agree with Eliot, byteAt: byteAt:put: are the easy part to rewrite - plus they are copy/pasted a number of times ;) The other cog's caseOf: are tougher and if caseOf: just works, why bother... Nicolas
    - it could be packaged with VMMaker
No. Â It needs to be in the compiler to be inlined. Â Why have you got on this hobby-horse? Â It is a non-issue. Â caseOf: ios not widelty used but extremely useful in certain circumstances. Â This has the feeling of a religious pogrom, not a rational approach to the system. Â IIABDFI = If It Ain't Broke, Don't Fix It.
This concept kinda appeal to me. From other side, i am also strongly feel that house should be kept clean :)
Are these two points correct?
No, IMO, definitely not.
Stef
-- Best regards, Igor Stasenko AKA sig.