Functions ignore declaration order #2913
Replies: 2 comments 3 replies
-
If we do this then we absolutely lock ourselves into functions not having upvalues. Just want to make sure you're aware of this and that everyone is okay with that. (This JS/TS code errors at runtime, but I wouldn't want it to do that but instead error at compile time.) test();
let y = 2;
function test() {
console.log(y);
} |
Beta Was this translation helpful? Give feedback.
-
Because that adds a good amount of overhead. I'm treating functions / lambdas as lower level languages do. Maybe that isn't as fair since the syntax is like typescript, where they are practically the same. Functions don't have upvalues since they're supposed to be created once at compile time now. Same as events. This was originally to address the problem of people having to nest their functions in Anyway, for the big reason -- lambdas are not strictly typed at compile time, so they can't/won't be interchangeable with functions. They could be casted to lambdas as denneisk says, but I want to be very careful with that as it could get very confusing. At least right now there's a clear separation between the two. If I were to implement it I'd at the very least want it to be explicit, ie const Lambda = myfn as function |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Allow user-defined functions to be called from anywhere in the script even if not originally defined.
i.e.,
should compile.
Beta Was this translation helpful? Give feedback.
All reactions