Variable Size Objects

Damien Cassou, St├ęphane Ducasse and Luc Fabresse http://stephane.ducasse.free.fr

Variable Size Instances?

Array new: 10
> #(nil nil nil nil nil nil nil nil nil nil)
Array new: 5
> #(nil nil nil nil nil)

Yes arrays can have different sizes

What You Will Learn

Roadmap

Variable Class Definition

Use message variableSubclass: instead of subclass:

Example

ArrayedCollection variableSubclass: #Array
	instanceVariableNames: ''
	classVariableNames: ''
	package: 'Collections-Sequenceable'

Example Variable Class

Example

Object variableSubclass: #StrangePoint
        instanceVariableNames: 'x y'
        classVariableNames: ''
        package: 'Collections-Sequenceable'

Roadmap

Variable Class Instantiation and Index Access

| a |
a := Array new: 4.
a at: 2 put: 'lulu'.
a at: 1
> nil
a at: 2 
> 'lulu'

Classes with Different Shape

Refining the Variable Part

Indexed Named Definition Method Examples
No Yes #subclass:... Color
Yes No #variableSubclass: AdditionalMethodState
Yes No #variableByteSubclass: ByteString
Yes No #variableWordSubclass: Bitmap

Some methods related to class types: isPointers, isBits, isBytes, isFixed, isVariable

Constraints

What You Should Know

/