JSLの関数のコピーやあ、
私の関数Fは複雑な関数であり、場合によっては、古い機能を維持したまま再定義する必要があります。 変更する前にFのコピーを保管したいと思います。 これまでのところ、JSLでこれを行う方法は見つかりませんでした。 これが私がやろうとしている小さな例です。 関数をリンクするだけでなく、実際にコピーする正しい方法は何ですか?
ありがとう!
F = Function( {x,y}, x+y ); // actually much more complex
Show(F(1,2)); // 3
// G = F; // Error, JMP complains about missing parameters
G = Function( {x,y}, F(x,y));
Show(G(1,2)); // 3
F = Function( {x,y}, x*y ); // Changes G, too.
Show(F(1,2)); // 2
Show(G(1,2)); // 2, but I want it to remain 3.
スクリプティングRe:JSLの関数のコピー基本的に、関数ポインタを取得できます。名前Expr()指図
F = Function( {x,y}, x+y ); // actually much more complex
Show(F(1,2)); // 3
G = Name Expr( F ); // use the magic NameExpr function to grab a pointer
Show(G(1,2)); // 3
F = Function( {x,y}, x*y ); // Changes G, too.
Show(F(1,2)); // 2
Show(G(1,2)); // 2, but I want it to remain 3.
/*:
F(1, 2) = 3;
G(1, 2) = 3;
F(1, 2) = 2;
G(1, 2) = 3;
*/
このサイトに問題があり、適切なJSLコードの挿入が妨げられているようです