Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

State of ifEmpty:ifNotEmpty:, ifNil:ifNotNil: and related messages across Smalltalks?

What is the current state of messages like ifEmpty:ifNotEmpty:, ifEmpty:, ifNotEmpty: ifNil:ifNotNil:, ifNil: and ifNotNil:?

Are they available across Smalltalks, and do they behave consistently? You still see things like "object isEmpty ifTrue: [...] ifFalse: [...]" in older code.

like image 743
andrew Avatar asked Jan 11 '14 19:01

andrew


1 Answers

Currently, I think the state of the art is covered very well by the Seaside coding convetions:

Portability

[…]

Do not use any of these methods, they are missing, broken or have different semantics on some platforms:

[…]

  • Object: #ifNotNil:, #ifNotNilDo:, #in:, ...
  • Boolean: #and:and:and:, #or:or:or:, ...
  • Collection: #=, #pairsDo:, #with:collect:
  • String: #match:
  • Stream: #position, #position:, #isEmpty

[…]

(highlighting by yours truly)

Since Seaside has been ported to Pharo, Squeak, GemStone, Dolphin, VisualWorks, VA Smalltalk, GNU Smalltalk, I think this list has some authority.

Also note that even #isEmpty seems to be not portable, for Streams at least.

like image 52
Tobias Avatar answered Sep 30 '22 13:09

Tobias