Classes | JITLib > Environments | Live Coding

Maybe : Ref : AbstractFunction : Object

referentially transparent proxy object
Subclasses: Fdef


A Maybe object can contain either nil or some other object, and allows to construct calculations without knowing this other object yet. If the calculation fails, due to a loop or a not yet defined object, Maybe returns nil.

The name Maybe stems from the programming language Haskell, where it represents a somewhat similar entity. See also: Fdef

NOTE: A Maybe object lazily constructs an operation as an object instead of performing it immediately. Its implementation remains incomplete necessarily, in the current form: it is limited to the arithmetic operations that AbstractFunction implements and the following collection methods: put, addAll, add, putAll, atAll.

You can extend Maybe as you need for your purpose, by the following schema:

Class Methods

From superclass: Ref

create a new instance



an object or nil.

Inherited class methods

Undocumented class methods


Maybe.callFunc = value




Maybe.defaultValue = value


Maybe.protected = value


Maybe.verbose = value

Instance Methods


.source = obj

return or set the contained object


.value = value

set the contained object or return the source, or the value of the contained object, if it is a Maybe. If there is a recursion, return nil.

.apply( ... args)

return the value, or the value of the contained object, if it is a Maybe. This method allows recursion, so that recursive calculations can be made.

.doesNotUnderstand(selector ... args)

(called by any message that Maybe doesn't understand.)

returns a composition function that, when evaluated, returns the value.

Inherited instance methods

Undocumented instance methods


.add( ... args)

.addAll( ... args)


.at( ... args)

.atAll( ... args)



.composeBinaryOp(aSelector, something, adverb)

.composeNAryOp(aSelector, anArgList)





.functionPerformList(selector, arglist)



.o( ... args)


.put( ... args)

.putAll( ... args)

.reduceFuncProxy(args, protect: true)

.reverseComposeBinaryOp(aSelector, something, adverb)


.valueArrayEnvir( ... args)

.valueEnvir( ... args)