localfun
localfun
Section titled “localfun”localfun(<name>[,<argument>...]) calls an owner-local function. The executing object’s current owner selects the registry scope. Ordinary built-in and global function calls keep their existing resolution rules; local functions require this explicit call. Two owners can register the same local name independently.
@function/local <name>=<object>,<attribute>[,<minimum>,<maximum>] registers a function in your executor’s owner scope. The object must have that same owner, you must control it, and you must be able to read the attribute. Names contain ASCII letters, digits and underscores, up to 64 characters. Built-in names are reserved, including names contributed by loaded plugins. A temporary softcode deletion does not remove that reservation; compiled names stay reserved for the library’s lifetime. A live built-in clone also takes precedence over an existing local name, including calls through a local alias. Argument bounds default to zero through 32.
- localfun example: registering and calling a local function, and how it runs
- @function/local: listing, deleting, disabling, aliasing and restoring entries
- localfun ownership: what happens when ownership changes or an object is deleted
- local function startup: registering local functions again after a restart
Example and evaluation
Section titled “Example and evaluation”For example, when entered as separate client commands:
&DOUBLE me=mul(%0,2)@function/local double=me,DOUBLE,1,1think localfun(double,7)The result is 14. Arguments become %0, %1, and so on. They retain their markup and are not reconstructed as source text. Existing attribute execution, read permissions, register behavior, invocation limits and shared execution budgets apply. The body executes as the backing object, following ordinary attribute evaluation. A privileged caller has no switch for selecting another owner’s scope.
@function/local
Section titled “@function/local”@function/local lists your owner’s local entries, including disabled entries. @function/local <name> shows one entry. The following operations use that same scope:
@function/local/args <name>=<names>assigns the global ARGS signature grammar in this owner scope; empty names clear it. Numbered slots remain unchanged.@function/local/delete <name>removes an entry.@function/local/disable <name>prevents calls.@function/local/enable <name>enables calls.@function/local/alias <alias>=<name>creates an alias to a concrete local entry.@function/local/preserve <name>retains it during a bulk restore, including its concrete target when the preserved entry is an alias.@function/local/restore *removes unpreserved entries in your scope, except targets required by preserved aliases.@function/local/restore <name>removes that entry, including a preserved one.
Aliases stay within the same full owner identity. A disabled target cannot be called through its alias. Aliases cannot point to other aliases or global functions. Replacing a concrete entry with an alias is rejected while other aliases depend on that entry. Local cloning, restriction overlays and built-in replacement are not supported.
Ownership changes
Section titled “Ownership changes”Ownership changes and deletion remove affected local registrations and aliases. Each call also checks the backing object’s full identity and current owner, so recycled object numbers cannot inherit code. A calling object’s new owner selects the new scope immediately. Definitions are never cached in the shared built-in function table.
Local Function Startup
Section titled “Local Function Startup”The registry is in memory. Re-register local functions from the backing object’s STARTUP attribute after each engine restart, using the same @function/local command. For the example above:
&STARTUP me=@function/local double=me,DOUBLE,1,1; @function/local/args double=value/preserve affects a bulk registry restore within the running process. It does not persist the registration across a restart. Store the startup command as softcode; normal startup ownership and attribute permissions still apply.
Named example:
&SHOW me=%<who>|%0|%<items1>|%1|%<itemscount>@function/local show=me,SHOW@function/local/args show=who items...think localfun(show,Bob,A,B)Output: Bob|Bob|A|A|2. Generated itemscount is visible but not caller-supplied. Signature updates, including updates through aliases, follow the concrete definition; aliases resolve that definition, and redefinition clears its signature. Re-register signatures in STARTUP after the definition.