| 
									
										
										
										
											2017-01-03 00:10:12 -05:00
										 |  |  | USING: classes classes.builtin classes.union.private compiler.units | 
					
						
							|  |  |  | help.markup help.syntax kernel ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | IN: classes.union | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ARTICLE: "unions" "Union classes" | 
					
						
							| 
									
										
										
										
											2008-05-10 19:09:05 -04:00
										 |  |  | "An object is an instance of a union class if it is an instance of one of its members." | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     POSTPONE: UNION: | 
					
						
							|  |  |  |     define-union-class | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | "Union classes can be introspected:" | 
					
						
							| 
									
										
										
										
											2015-07-20 04:01:31 -04:00
										 |  |  | { $subsections class-members } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | "The set of union classes is a class:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     union-class | 
					
						
							|  |  |  |     union-class? | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-05-10 19:09:05 -04:00
										 |  |  | "Unions are used to define behavior shared between a fixed set of classes, as well as to conveniently define predicates." | 
					
						
							| 
									
										
										
										
											2017-03-16 06:24:28 -04:00
										 |  |  | { $see-also "mixins" "maybes" "tuple-subclassing" } ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ABOUT: "unions" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 00:10:12 -05:00
										 |  |  | HELP: (define-union-class) | 
					
						
							| 
									
										
										
										
											2019-10-24 17:10:41 -04:00
										 |  |  | { $values { "class" class } { "members" { $sequence class } } } | 
					
						
							| 
									
										
										
										
											2017-01-03 00:10:12 -05:00
										 |  |  | { $description "Defines a union class." } | 
					
						
							|  |  |  | { $errors "Throws " { $link cannot-reference-self } " if the definition references itself." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | HELP: define-union-class | 
					
						
							| 
									
										
										
										
											2019-10-24 17:10:41 -04:00
										 |  |  | { $values { "class" class } { "members" { $sequence class } } } | 
					
						
							| 
									
										
										
										
											2007-12-30 16:09:21 -05:00
										 |  |  | { $description "Defines a union class with specified members. This is the run time equivalent of " { $link POSTPONE: UNION: } "." } | 
					
						
							| 
									
										
										
										
											2007-12-30 15:08:48 -05:00
										 |  |  | { $notes "This word must be called from inside " { $link with-compilation-unit } "." } | 
					
						
							| 
									
										
										
										
											2017-01-03 00:10:12 -05:00
										 |  |  | { $side-effects "class" | 
					
						
							|  |  |  | } ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | { union-class define-union-class POSTPONE: UNION: } related-words | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: union-class | 
					
						
							|  |  |  | { $class-description "The class of union classes." } ;
 | 
					
						
							| 
									
										
										
										
											2017-01-03 00:10:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: union-of-builtins? | 
					
						
							|  |  |  | { $values { "class" class } { "?" boolean } } | 
					
						
							|  |  |  | { $description { $link t } " if the class either is a " { $link builtin-class } " or only contains builtin classes." } ;
 |