<<<<<<<<<<<<<<<<<

collection(lymb) Core Classes collection(lymb)

NAME

collection

DESCRIPTION

Collections are objects that forward messages to their members. Collections are bags, that is they are unordered and can contain duplicate entries. They accept any message, and if the message is not one of those that they respond to, they forward the message to each of their members. There are special messages to do such things as print (printall!) or free (freeall!) each member of a collection.

SUPERCLASS

object

INSTANCE VARIABLES

members is the list of collection's members.

current is the current member returned by message member_next?

MESSAGES

appendall: file sends an append: message to each member.

forward:args message forwards message to all members, with args as arguments.

free! frees the collection but not its members.

member_next? returns the name of the next member in a collection. If there are no more members, returns no arguments.

member_start! sets the next member pointer to the first member of a collection. Further member_next? messages will return successive members.

members! prints, on standard output, the names of its members.

members+ arguments appends its arguments to its member list.

members- arguments deletes its arguments from its member list.

members= arguments sets its member list to its arguments.

members? returns a list of its members.

members_delete_all! clears it members list, but does not delete the members themselves.

mtimeall? obtains the modified time of the most recently modified object in the list of members. Members that are not objects are ignored. If there are no objects in the members list, or all the members are not objects, then a 0 is returned.

new! creates a new collection with a null member list.

number_members? returns the number of methods in collection

print! prints a description of its members.

variablesall? returns the instance variables of all the collection's members.

printall! sends a print! message to each of its members.

writeall: file sends a write: message to each of its members.

EXAMPLE

collection new: c members=(a, b); scalar new: a = 1990; string new: b = "good year"; c print:value;

NOTES

If a collection contains itself as a member, messages will not be forwarded to it to avoid infinite loops unless the message is understood by the collection itself. For example, if a printall! message is sent to a collection containing itself as a member, a print! will be forwarded to the collection.

You can't predict the order in which messages will be forwarded to members of a collection based on the ordering of members in the collection. In particular, if a collection contains itself as a member, it will receive forwarded messages after all other members of the collection.

SEE ALSO

object, parser, msg


Please send comments and suggestions to
consult@rpi.edu