as

Coerces an object to a type.  That is, it returns an instance of type that has the same contents as object.  If object is already an instance of type, it is returned unchanged.  In general, the value returned may or may not be freshly allocated.

Predefined methods allow coercion between integers and characters, between strings and symbols, and between collection types.  No methods are predefined for other classes.  Programs may define additional methods.

Exported from

Modifiers

open

Arguments

typeAn instance of <type>.
objectAn instance of <object>.

Values

instanceAn instance of <object>.
Summary
Coerces an object to a type.
as is defined for <sequence>s.
This method on <integer>, <character> returns a numeric equivalent for the character.
This method on <character>, <integer> returns the character equivalent of the integer.
This method on as returns the symbol that has the name string.
This method on as returns the name of the symbol, which will be a string.
The method on <string>, <character> creates a string of length 1, containing the character.

Functions

as

as is defined for <sequence>s.  When converting between collection types, the return value will have the same number of elements as collection.  If the collection is an instance of <sequence> and the collection-type is a subtype of <sequence>, the elements will be in the same order.  The individual elements may also undergo some conversion.

Arguments

collection-typeAn instance of <type>.
collectionAn instance of <sequence>.

Values

instance-of-collection-typeAn instance of collection-type.

as

This method on <integer>, <character> returns a numeric equivalent for the character.  The integer returned is implementation dependent.

Arguments

typeAn instance of singleton(<integer>).
characterAn instance of <character>.

Values

integerAn instance of <integer>.

as

This method on <character>, <integer> returns the character equivalent of the integer.

Arguments

typeAn instance of singleton(<character>).
integerAn instance of <integer>.

Values

characterAn instance of <character>.

as

This method on as returns the symbol that has the name string.  If the symbol does not yet exist, it is created.  This method on as will always return the same symbol for strings of the same characters, without regard to alphabetic case.

as(<symbol>, "foo")
⇒ #"foo"
#"FOO" == as(<symbol>, "foo")
⇒ #t
#"Foo"
⇒ #"foo"

Arguments

typeAn instance of singleton(<symbol>).
stringAn instance of <string>.

Values

symbolAn instance of <symbol>.

as

This method on as returns the name of the symbol, which will be a string.

as(<string>, #"Foo")
⇒ "Foo"

Arguments

typeAn instance of singleton(<string>).
symbolAn instance of <symbol>.

Values

symbolAn instance of <string>.

as

The method on <string>, <character> creates a string of length 1, containing the character.

Coerces an object to a type.
The class of collections whose keys are consecutive integers starting from zero.
The class of integers.
The class of characters.
The class of sequences with elements that are characters.
The common-dylan module.
Whenever possible, we have tried to keep the Dylan module pristine and unextended, preferring to add our extensions to separate modules or libraries.
The class of all types, including classes and other types.
The class of all Dylan objects.
The class of symbols.