lib.st

";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; convenient class creation
"
! Symbol methods !
isa: class
     ^class subclass: self
          instanceVariableNames: ''
          classVariableNames: ''
          poolDictionaries: ''
          category: nil
!
isa: class with: vars
     ^class subclass: self
          instanceVariableNames: vars
          classVariableNames: ''
          poolDictionaries: ''
          category: nil
!
isa: class with: vars shares: classVars
     ^class subclass: self
          instanceVariableNames: vars
          classVariableNames: classVars
          poolDictionaries: ''
          category: nil
!!

";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; convenient instance creation
"
! Symbol methods !
new
        ^self new: [^self error]
!
new: ifAbsent
         ^(Smalltalk at: self ifAbsent: ifAbsent) new
!!

";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; convenient prinint
"

! Object methods !
o       ^self s display   !
oo      ^self s displayNl !
s       ^self displayString !
!

";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; metaKnowledge
"

! Object methods !
isIterable   ^false !
isBasic      ^false !!

! Collection methods !
isIterable  ^true !!

! String methods !
isBasic ^true  !!

! Magnitude methods !
isBasic ^true
!!


";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ifNil:
"

! UndefinedObject methods !
ifNil: aBlock
       ^aBlock value
!!

! Object methods !
ifNil: aBlock
       ^self
!!

";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; String tricks
"

! String methods !
asWords
        ^(self tokenize: '\s+') asOrderedCollection
!
fileLinesDo: aBlock
    |f last|
    f := File name: self.
    f readStream linesDo: [:line|
        last := aBlock value: line].
    ^last.
!!