ProtoObject

Abstract

ProtoObject — Root of the Beamtalk class hierarchy.

ProtoObject is the ultimate superclass of all objects. It defines the minimal protocol that every object supports: identity, equality, class introspection, dynamic dispatch, and error signaling.

ProtoObject is abstract — it cannot be instantiated directly. All useful objects inherit from Object (or Actor) which adds instantiation, nil testing, and display protocols.

All methods are compiler intrinsics dispatched at the call site.

Instance Methods

== other source

Test value equality (Erlang ==).

Examples

42 == 42           // => true
"abc" == "abc"     // => true
/= other source

Test value inequality (negation of ==).

Examples

1 /= 2             // => true
42 /= 42           // => false
class source

Return the class of the receiver.

Examples

42 class            // => Integer
"hello" class       // => String
doesNotUnderstand: selector args: arguments source

Handle messages the receiver does not understand. Override for custom dispatch.

Examples

42 unknownMessage   // => ERROR: does_not_understand
perform: selector withArguments: arguments source

Send a message dynamically with an arguments list.

Examples

42 perform: #abs withArguments: #()   // => 42
performLocally: selector withArguments: arguments source

Execute a class method in the caller's process, bypassing gen_server dispatch.

The caller takes responsibility for knowing the method does not mutate class state. Useful for long-running class methods that would otherwise block the class object's gen_server.

Limitations: only resolves methods defined directly on the target class module (does not walk the superclass chain). Class variables and self are not available to the method (nil and #{} are passed).

Examples

MyClass performLocally: #run:ctx: withArguments: #(input, ctx)
perform: selector withArguments: arguments timeout: timeoutMs source

Send a message dynamically with an arguments list and explicit timeout.

The timeout (in milliseconds or #infinity) applies to the gen_server:call when the receiver is an actor. For value types, timeout is ignored.

Examples

actor perform: #query withArguments: #(sql) timeout: 30000