Cold Help System: Programming: ColdC Reference Manual: Language Structure: Data Types: Frob


Frobs are an abstract data type used for dynamically handling data when using it as the receiver of a method-call expression. Normally, when data is used as the receiver for a method call, the interpreter will actually lookup and use an object with an object name that is the same as the type of data being used (such as an object named $string if the data is a 'string). In the case of a frob, the receiver is specified within the frob, as the Frob Class. Frobs also give the ability to specify special method to handle the call with.

Frobs are useful for grouping, abstracting and encapsulating a set of similar data by associating it with a handler object. Frobs are constructed by enclosing the class and representation within a less-than sign (<) and a greater-than sign (>), seperated by a comma. All of the following are valid frobs:

<$thing_frob, #[['desc, "worthless"], ['name, "coin"]]>
<$coins, [923]>
<#73, [1, 2]>

The usefullness of a frob becomes apparent when used as the recipient in a method-call expression. In this instance the frob class becomes the recipient and the frob value becomes the first argument sent to the method. For instance, the following two method calls are equivalent:

(<$list, [1, 2, 3]>).reverse('do_this)
$list.reverse([1, 2, 3], 'do_this)

Furthermore, if a handler is used, the handler is called as the method, and the expected method is sent as a symbol argument. The following two method calls are equivalent:

(<$obj, #[], 'handle_it>).tell("foof")
$obj.handle_it(#[], 'tell, "foof")

Because of the difference in how a frob method is called, it is possible to define a method as a frob-only method. If a method is defined as a frob-only method it is only called when called by a frob. Calling it in the standard syntax would not retrieve the frob-only method, but would instead look for the same method further up the ancestor heirarchy. For more information see Defining Methods.

Frobs are always logically true.

See Also: frob_class(), frob_value() and frob_handler()


Integer | Float | String | Symbol | List | Object Number | Dictionary | Error Codes | Frob | Buffer


the Cold Dark