On Tue Apr 08 19:11:10 2008, pmichaud wrote: > On Fri, Apr 04, 2008 at 02:15:26PM -0700, Christoph Otto (Volt) wrote: > > When running the following PIR code, Parrot does the Perlish thing > > and implicitly converts s to an int. This violates the principle > > of least surprise and makes it unnecessarily difficult to test > > whether an element exists within an array. > > > > It would be much more logical if the array-like PMCs threw an > > exception in this circumstance. > > > > .sub _main > > .local pmc a > > .local string s > > a = new 'ResizablePMCArray' > > a['foo'] = 'stuff' > > s = a['bar'] > > print s #prints 'stuff' > > s = a[0] > > print s #prints 'stuff' > > print "\n" > > .end > > What about the case of ... ? > > .sub _main > .local pmc a > .local pmc s > s = new 'String' > s = 'foo' > > a = new 'ResizablePMCArray' > a[s] = 'stuff' > > $S0 = a[0] > say $S0 # prints "stuff\n" > .end > > It seems to me that whatever we do with String PMCs as keys > we should also do with string registers. In this case it means > numifying the string (just as we would any PMC key). > > As far as testing for existence of an element, that should > probably be some special behavior attached to the exists_p_s > opcode as opposed to a set_* opcode. > > Pm >
Sounds good to me. Resolved.