Primitive: returning a String
Andrew C. Greenberg
werdna at gate.net
Wed Dec 1 00:37:31 UTC 1999
>Alternatively, you could do something like the following in your primitive:
>
>----
>interpreterProxy
> instantiateClass: (interpreterProxy classString)
> indexableSize: <the size you need>.
>---
>
>This way, you could make whatever call you need to make, then allocate a
>String for the correct size, and copy the data into that string. Probably
>very little difference in performance either way (the copy might be a tad
>faster if done in C).
Right. However, if it is done in the primitive, all other references
to oops or parts of oops stored in local variables must be presumed
invalid. This is because #instantiateClass:indexableSize: can cause
a garbageCollection. Accordingly, depending upon whethe you need
actual access to other oops (as opposed to their values), you may
need to go back to the stack to re-access parameters.
More information about the Squeak-dev
mailing list
|