Problem trying to change SmallInt < SmallInt primitive

Brian T. Rice water at tunes.org
Mon Aug 9 15:51:32 PDT 2004


Paul Dufresne <dufrp at hotmail.com> said:

> I have tried to change the Slate version of primitive33 in
> src/mobius/vm/ext/prims.slate to:
> ===
> x at SmallIntegerTraits < y at SmallIntegerTraits
> [
>   interpreter stackPush:
>     [| a!LongInt b!LongInt |
>     a: x asSmallInt.
>     b: y asSmallInt.
>     ( x < y
>       ifTrue: [CurrentMemory TrueObject]
>       ifFalse: [CurrentMemory FalseObject])] do.
> ] `pidginPrimitive.
> ===
> but got:
> ===
> Generating load of interpreter
> Generating argument
> Casting
> Generating message do
> 
> Checking infixes
> Checking prefixes
> Checking accessors
> Searching for function do
> The following condition was signaled:
> Error: A method translation wasn't found for do.
> 
> The following restarts are available:
> 0)      Inspect a stack frame
> 1)      Abort evaluation of expression
> 2)      Quit Slate
> ===
> 
> Am I trying too much for a primitive, I means evaluating a block?
> 
> --Paul

Yes, this is not within the pidgin semantics yet to execute a block of code 
inline (this requires lambda-lifting as I recall, which we do have some code 
for, but not for pidgin); you have to use one of the pre-defined methods with 
translators to C for now. Basically you have to execute the code and use the 
result of the last expression in the stackPush:... like so, should work:

x at SmallIntegerTraits < y at SmallIntegerTraits
[| a!LongInt b!LongInt |
  a: x asSmallInt.
  b: y asSmallInt.
  interpreter stackPush:
    (x < y ifTrue: [CurrentMemory TrueObject]
           ifFalse: [CurrentMemory FalseObject]).
] `pidginPrimitive.

This actually looks more natural, anyway. The extra block you were using may 
as well have been the whole method.

Why are you creating a and b and then testing x vs. y? :)




More information about the Slate mailing list