1 ! Copyright (C) 2017 Alexander Ilin.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel ;
8 ARTICLE: "maybes" "Maybe classes"
9 "A " { $snippet "maybe" } " is an anonymous union class (" { $link "unions" } ") of its members and the " { $link POSTPONE: f } " class. An object is an instance of a " { $snippet "maybe" } " class if it is either an instance of any of its participants, or " { $link POSTPONE: f } "." $nl
10 "The " { $snippet "maybe" } " classes are used to declare typed slots that are optional for a tuple. Without this mechanism it would be an error to assign " { $link POSTPONE: f } " to such a typed slot, and therefore any tuple containing them without specifying an " { $link POSTPONE: initial: } " value could not be created with the word " { $link new } "." $nl
11 "A slot with an empty " { $snippet "maybe{ }" } " class can only hold the " { $link POSTPONE: f } " value."
14 "USING: prettyprint ;"
15 "TUPLE: test-maybe { value maybe{ fixnum string } } ;"
16 "test-maybe new value>> ."
20 { $see-also "unions" POSTPONE: maybe{ } ;