Dave Herman's research blog.
it's actually (T option) in ML :) -- well what you actually *say* is (SOME V) or (NONE), (T option) is the type.-marius
Ack! Of course. Fixed.
Hey,I've used ternary logic in Smalltalk before, using the values 'true', 'false' and 'nil'.^ aPerson isHappy ifNil: ['Maybe?.']; ifTrue: ['It's true'] ifFalse: ['It's false'].Notice that this consists of 2 message sends (cascaded to the same receiver by the semicolon syntax), they are:1) ifNil: 2) ifTrue:ifFalse:
"Either T or #f" is not so good in Scheme if T can be #f. Better is "(list T) or #f", or your favorite box of T or your favorite non-box cookie (empty list, zero element vector).But the other way to say maybe is "pair of continuations", sometimes even in direct style.
In scala:val foo: Option[T]Here's the API doc.
Fine, but that's no different from T option in ML. My list was intended to demonstrate implementations of the pattern that are different in interesting ways.
Post a Comment