# symbol Specification Sheet

Computer Algebra Kit (c) 1993,00 by Comp.Alg.Objects. All Rights Reserved.

# Symbol

Inherits from: CAObject

## Class Description

Maturity Index : Relatively Mature

For symbols created with the factory method str:, the first character of the str of the symbol object must be a letter. Subsequent characters can be letters or digits. Whitespace or control characters are not allowed.

Using the factory method chars:count:, it's possible to use arbitrary C strings as the value of the symbol; in this case Symbol just acts like a regular Objective C String class. If you intend to use the object as a mathematical symbol, it's not advised to do this as you might incorrectly interpret spaces etc. as mathematical operators.

## Method types

### Creation

- str:
- chars:count:
- copy
- deepCopy
- release

### Identity

- str
- str:
- hash
- isEqual:
- compare:
- isLetter

### Printing

- printOn:

## Methods

### str:

> +str:(STR)aString

Creates a new symbol, and sets its value to a copy of aString. Returns nil if aString is not suited as value for a symbol (when the first letter is not a letter, for instance).

### chars:count:

> +chars:(STR)aBuffer count:(int)numChars

Creates a new symbol, and sets its value to a copy of the first numChars characters of aBuffer. For this method, there are no restrictions on the C string being used.

### copy

> -copy

Returns a new symbol object. Copies the string.

### deepCopy

> -deepCopy

Equivalent to copy.

### release

> -release

Frees the memory for the string value.

### str

> - (STR)str

Returns the string value of the symbol. The first character is a letter, subsequent characters can be alphanumeric.

### str:

> -str:(STR)aString

Creates a new symbol, and sets its value to a copy of aString. Returns nil if aString is not suited as value for a symbol.

### hash

> - (unsigned)hash

Returns a hash value based upon the string.

### isEqual:

> - (BOOL)isEqual:b

Returns YES if the str's of both objects are equal.

### compare:

> - (int)compare:b

Compares the str's of both objects.

### isLetter

> - (BOOL)isLetter

Whether the symbol consists of just one character (and hence, is a letter, not a digit).

### printOn:

> -printOn:(IOD)aFile

Prints the symbol to aFile.