[Vm-dev] Re: [Pharo-project] #at:ifAbsent: for Array(s) could be
David T. Lewis
lewis at mail.msen.com
Thu Nov 3 02:09:39 UTC 2011
On Wed, Nov 02, 2011 at 01:23:33PM -0700, Eliot Miranda wrote:
> On Wed, Nov 2, 2011 at 1:15 PM, Igor Stasenko <siguctua at gmail.com> wrote:
> > Of course i was thinking about changing VM too. But i am uncertain if
> > it worth doing so, because maybe this is too low reward for putting
> > effort in it.
> > But if we going to make new prim , here's what i'd like to have
> > - use proper prim error code(s) to distinguish between cases:
> > - a receiver is not indexable/variable object
> > - an index is integer, but points outside of array's range
> > - an object passed as index is non-integer
> I agree. I was going to brag that the Cog VM already has this implemented
> but the error code returned for a non-indexable receiver is wrong. It
> should be #'bad receiver' but the prim always answers #'bad index'. I'll
> fix this. Primitive error codes and relevant usage in primitives still
> need to be ported to the standard VM though.
Hopefully we're not too far apart on this. I added your basic mechanism
for error codes a while back (see below) so adding the relevant usage to
primitives should be strightforward, and in principle a new primitive that
uses error codes should work on both Cog and the standard VM.
Time: 23 May 2011, 11:38:51.478 pm
Convert primitive error reporting to use #primitiveFailFor: such that the
successFlag variable is replaced with primFailCode (integer value, 0 for
success, 1, 2, 3... for failure codes), consistent with oscog.
Includes improved #failed, #successful, and #success: methods recoded for
performance in C, yielding performance equivalent to previous implementation
Changes were applied as follows:
- Replaced all occurances of "successFlag := true" with "self initPrimCall",
which initialize primFailCode to 0.
- Replaced all "successFlag := false" with "self primitiveFail".
- Replaced all "successFlag ifTrue:  ifFalse: " with
"self successful ifTrue:  ifFalse: ".
- Updated #primitiveFail, #failed and #success: to use primFailCode rather
- Removed successFlag variable.
More information about the Vm-dev