Coercing and Copying ObjectsThese functions are used to perform shallow copies on objects, and to coerce objects to other classes.
as class object => instance [Generic Function]
as coerces object to class. That is, it returns an instance of class that has the same contents as object.
If object is already an instance of class, it is returned unchanged.
Predefined methods allow coercion between numeric types, between integers and characters, between strings and symbols, and between collection types. No methods are defined for other classes.
When converting between collection types, the new collection (the returned object) will have the same number of elements as the source collection (the object). If the source and target class are both subclasses of <sequence>, the elements will be in the same order. The individual elements may also undergo some conversion.
shallow-copy object => new-object [Generic Function]
shallow-copy returns a new object that has the same contents as object. The contents are not copied but are the same objects contained in object.
Dylan includes methods for copying collections. The method for <collection> creates a new object by calling make on the class-for-copy of object. For other classes, the programmer must provide a method.
class-for-copy object => class [Generic Function]
class-for-copy returns an appropriate collection class for creating mutable copies of the argument. For collections that are already mutable, the collection's actual class is generally the most appropriate, so the <object> method of class-for-copy can be used. The class-for-copy value of a sequence should be a subclass of <sequence>, and the class-for-copy value of an explicit-key-collection should be a subclass of <explicit-key-collection>. In all cases, the class-for-copy value must be a mutable collection.Next section: The classes <type>, <class>, and <singleton>