Quote:
Originally Posted by Chompy
Elaborate.
|
Quote:
Originally Posted by WhiteDragon
There are a few problems.
- In certain cases, when passing around an anonymous function, you lose the ability to call it. I think the problem is when you call the anonymous function from a different class than it was defined, but I'm not certain exactly when it happens. (If someone wants to debug this, please do.)
My current hack around this is, given a function temp.f, doing (@temp.f)(), which casts the function pointer to a string like "function_913727", which is a global variable and can be called from anywhere as a result.
- When a class using anonymous functions is updated, most things break until you update the NPC/Weapon that they are joined to.
|
Mainly this. There's also this:
PHP Code:
function onCreated() {
temp.func = myTest();
(@ temp.func)();
myOtherTest(function () {
echo("yeah baby");
});
}
function myTest() {
return function () {
echo("yeah baby");
};
}
function myOtherTest(func) {
(@ func)();
}
Produces the following:
HTML Code:
Script compiler output for *scratch*:
error: unexpected token: function at line 3: myOtherTest(function () {
error: unexpected token: ( at line 3: myOtherTest(function () {
error: unexpected token: ) at line 3: myOtherTest(function () {
error: unexpected token: ) at line 5: });
error: unexpected token: function at line 13: return function () {
error: unexpected token: ( at line 13: return function () {
error: unexpected token: ) at line 13: return function () {
It doesn't seem right to me.