In Glossary§

See primary documentation in context for Allomorph

A type that has two related values which may be used depending on the context. For example IntStr allomorph is both an Int and a Str, so it will be accepted by anything that expects an Int, a Str, or an IntStr. Keep in mind that certain constructs, such as sets, bags, and mixes care about object identity, and so will not accept an allomorph as equivalent of its components alone.

The allomorph types IntStr, NumStr, RatStr and ComplexStr may be created as a result of parsing a string quoted with angle brackets:

say <42>.^name;     # OUTPUT: Â«IntStr␀» 
say <42.1e0>.^name# OUTPUT: Â«NumStr␀» 
say <42.1>.^name;   # OUTPUT: Â«RatStr␀»

Note: angle brackets can also be used to create literals for which you'd normally need to use some operator (e.g. / for Rat or + for Complex). This allows you to use such literals in places where expressions are not allowed, for example, as literals in signatures:

# Wrong, can't use an operator there: 
multi foo (1/3{ say "It's one third!" }
# Right, a Rat literal: 
multi foo (<1/3>{ say "It's one third!" }

If you do want an allomorph and not a literal Numeric, then include whitespace around angle brackets:

say <42/1>.^name;    # OUTPUT: Â«Rat␀» 
say <42+0i>.^name;   # OUTPUT: Â«Complex␀» 
say < 42+0i >.^name# OUTPUT: Â«ComplexStr␀» 
say < 42/1 >.^name;  # OUTPUT: Â«RatStr␀»

Please see the Numerics page for a more complete description on how to work with these allomorphs.