[squeak-dev] Advice from Plugin gurus

Igor Stasenko siguctua at gmail.com
Mon Sep 22 13:19:57 UTC 2008


2008/9/22 Gerardo Richarte <gera at corest.com>:
> Igor Stasenko wrote:
>> 2008/9/22 Gerardo Richarte <gera at corest.com>:
>>
>>>    There's a native function I need to call (I called it 'aPrintf' in
>>> the code below) with a specific calling convention:
>>>
>> I wondering , why you prefer using string formatting in C, while in
>> smalltalk you have own? You can easily format strings in smalltalk,
>> and print only the resulting string w/o need in inventing safe schemes
>> or conversion.
>>
> Hi Igor, nice to see you again!
>
> I knew this was going to happen :)
>
> It was just an example, I'm not using string formatting. The actual
> function I'm calling is the callout interface for OpenFirmware, through
> which OpenFirmware provides services to the booted operating
> system. Pretty much like BIOS' INT mechanism, but much more
> powerful.
>

Okay. Then i don't see any problems with this primitive, except maybe one thing:

a primitive should never change the contents of any argument(s). As in
general smalltalk methods, a primitive should be allowed to change the
contents only of receiver object, otherwise its breaking a smalltalk
encapsulation rules.
I would advice you to allocate separate byte array and fill it with
values, then pass to C routine. Since its a byte array you don't need
to care about it contents, and don't need a cleanup (GC will collect
it as garbage eventually).

>   richie
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list