Had a slight problem with Seaside this weekend which came down to
Com-ExtensionsToBase overriding Seaside's implementation of Array>>at:ifAbsent: with its own that does not consider 0-index access as "absent". So doing "Array new at: 0 ifAbsent: [nil]" COM's version would return SubscriptOutOfBoundsError whereas the Seaside version would return nil. Don't you hate these? One could argue for either depending on the mood, so I just thought I'd throw it out there and see what people think in general. Cheers! -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 [hidden email] CONFIDENTIALITY NOTICE This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments. Thank you. smime.p7s (4K) Download Attachment |
Boris Popov wrote:
>Had a slight problem with Seaside this weekend which came down to >Com-ExtensionsToBase overriding Seaside's implementation of >Array>>at:ifAbsent: with its own that does not consider 0-index access as >"absent". So doing "Array new at: 0 ifAbsent: [nil]" COM's version would >return SubscriptOutOfBoundsError whereas the Seaside version would return >nil. Don't you hate these? One could argue for either depending on the mood, >so I just thought I'd throw it out there and see what people think in >general. > >Cheers! > >-Boris > > SubscriptOutOfBoundsError. That's what the ifAbsent: is there to prevent. I think that the seaside version is the right one in this case. David Buck |
In reply to this post by Boris Popov, DeepCove Labs (SNN)
> Had a slight problem with Seaside this weekend which came down to
> Com-ExtensionsToBase overriding Seaside's implementation of > Array>>at:ifAbsent: with its own that does not consider 0-index > access as "absent". So doing "Array new at: 0 ifAbsent: [nil]" > COM's version would return SubscriptOutOfBoundsError whereas the > Seaside version would return nil. Don't you hate these? One could > argue for either depending on the mood, so I just thought I'd throw it > out there and see what people think in general. FWIW, I'm the one who added #at:ifAbsent: (to SequenceableCollection) to Seaside. I simply copy/pasted the method code from Squeak. Seaside needs it in a couple of locations where, ironically, the index value is always positive, i.e. COM's version would be OK. Michel. |
In reply to this post by Boris Popov, DeepCove Labs (SNN)
There was a discussion on the list a while back as to whether Array
should have at:ifAbsent: as part of their protocol, that is a valid question. But if it is implemented then it should be the Squeak implementation. There is no point to the implementation in the COM package. Either the index is in bounds in which case no need for the ifAbsent: block or the index is out of bounds in which case it will throw an exception so no need for the ifAbsent: block, you may as well use at:. The only thing having at:ifAbsent: buys you is the ability to be a bit sloppy about the parameters to code that uses at:ifAbsent:. But this is a pathological bit of polymorphism. Joerg ----- Joerg Beekmann DeepCove Labs 4th floor 595 Howe Street Vancouver, BC, V6C 2T5 voice +1.604.689.0322 fax +1.604.689.0311 [hidden email] CONFIDENTIALITY NOTICE Unless otherwise indicated this email contains information that is private and confidential. If you have received it in error, please notify the sender and delete this message along with any attachments. > -----Original Message----- > From: Bany, Michel [mailto:[hidden email]] > Sent: Tuesday, May 23, 2006 10:05 AM > To: [hidden email] > Subject: RE: Implementation detail of #at:ifAbsent: in COM > > > Had a slight problem with Seaside this weekend which came down to > > Com-ExtensionsToBase overriding Seaside's implementation of > > Array>>at:ifAbsent: with its own that does not consider 0-index > > access as "absent". So doing "Array new at: 0 ifAbsent: [nil]" > > COM's version would return SubscriptOutOfBoundsError whereas the > > Seaside version would return nil. Don't you hate these? One could > > argue for either depending on the mood, so I just thought I'd throw > > > out there and see what people think in general. > > FWIW, I'm the one who added #at:ifAbsent: (to SequenceableCollection) > to Seaside. I simply copy/pasted the method code from Squeak. > Seaside needs it in a couple of locations where, ironically, the index > value is always positive, i.e. COM's version would be OK. > > Michel. |
Free forum by Nabble | Edit this page |