ErlangModule

Inherits from ProtoObject
Sealed

ErlangModule — Proxy for calling functions on a specific Erlang module.

ErlangModule instances are value types (tagged maps) created by the Erlang class. They forward Beamtalk messages as erlang:apply/3 calls to the proxied module.

Examples

proxy := Erlang lists
proxy reverse: #(3, 2, 1)           // => [1, 2, 3]
proxy class                          // => ErlangModule

Selector Mapping

  • reverse: xslists:reverse(Xs) (keyword → function name)
  • seq: 1 with: 10lists:seq(1, 10) (first keyword = function)
  • nodeerlang:node() (unary → zero-arg call)

See ADR 0028 §1 for full mapping rules.

Instance Methods

doesNotUnderstand: selector args: arguments source

Forward an unknown message as an Erlang function call on the proxied module.

Invoked automatically when any message is sent to an ErlangModule instance. Maps the Beamtalk selector and arguments to erlang:apply(Module, Fun, Args) according to the selector-to-function-name rules in ADR 0028 §1. Compiled via @intrinsic erlangApply — no gen_server roundtrip.

Examples

(Erlang lists) reverse: #(3, 2, 1)    // => [1, 2, 3]
(Erlang erlang) node                   // => :'nonode@nohost'

Inherited Methods

From ProtoObject

== other

Test value equality (Erlang ==).

Examples

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

Test value inequality (negation of ==).

Examples

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

Return the class of the receiver.

Examples

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

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

Examples

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

Send a message dynamically with an arguments list.

Examples

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

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

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