musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

Major: Obj-C and oj differ when functions/variables inside of @implementation #87

Closed iccir closed 1 year ago

iccir commented 8 years ago

Per the oj 0.x and 1.x documentation:

Behind the scenes, the oj compiler changes the @implementation/@end block into a JavaScript function block. Hence, private functions and variables may be declared inside of an @implementation without polluting the global namespace.

This differs in behavior from Objective-C. Consider the following:

@interface Foo : NSObject
@end

@implementation Foo
static int sInt = 0;
static void sFoo() { }
int theInt = 0;
void foo() { }
@end

sInt, sFoo, theInt, and foo are all visible/callable from outside of the @implementation block:

int main(int argc, const char * argv[])
{
    sFoo();
    foo();
    sInt = theInt + 4;
    return 0;
}

If changed, this would require a major bump.

Note: I don't think this change should occur for its own sake; rather, it's an ok change to make if #86 requires it.

iccir commented 1 year ago

No longer applicable due to #166