Skip to content

Add new way to call exists defined functions in strict mode besides using lambdas #3700

Description

@AlexALX

Describe the feature

With new @strict mode and removing support for callable string functions there is missing one feature what are very useful for complex projects.

By old string callable way i could call any function by knowing string name and call it if its defined.

With new way for make function callable it must be stored in variable, which making impossible to call defined functions in any way except make wrappers like

@strict

function void defined_func() {
   print("Hello")
}

CallbableFunc = function() {
    defined_func()
}

local CurOps = minquota()

CallbableFunc()

print("OPS USED", CurOps - minquota())

OPS USED 57

this making code is much much larger for nothing. previous way was simple and making less code. now multiply this code to 100 functions, each need wrapper or stored as variable or table with functions. makes even more OPS to call them.

function void defined_func() {
   print("Hello")
}

local CurOps = minquota()

FuncName = "defined_func"
FuncName()

print("OPS USED", CurOps - minquota())

OPS USED - 42

and as table and @strict

@strict

function void defined_func() {
   print("Hello")
}

local Table = table()
Table["CallbableFunc",function] = function() {
    defined_func()
}

local CurOps = minquota()

FuncName = "CallbableFunc"
Table[FuncName,function]()

print("OPS USED", CurOps - minquota())

OPS USED 57

What problem does this solve?

We need some trade off between new and old system.

As a compromise i propose make new function like "executeFunc("stringname")" or something like this, this will cover old way without need to write more code. i know why this change made - to make functions be processed during compile time to speed up e2 processing, but adding way to call it via string value should be possible with extra function without need of legacy callable strings support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature requestRequest to add or improve something in Wiremod

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions