musictheory / NilScript

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

Support for @CLASS, @SEL, @FUNCTION #58

Closed IngwiePhoenix closed 8 years ago

IngwiePhoenix commented 9 years ago

Is there a good way to pick up the current selector while debugging? For instance:

console.log(oj.getThisSelector(), "msg...");

I am currently debugging my main application, and it would be nice to display the current class/selector to quickly pick up where what is happening.

Kind regards, Ingwie

iccir commented 9 years ago

Not currently. It would need to be inserted by the compiler (as the runtime doesn't know). Objective-C accomplishes this via __FILE__, __LINE__, __PRETTY_FUNCTION__, etc.

Double underscores are reserved for the compiler in ANSI-C, but not in JS, so we would probably use an @-prefixed keyword:

Perhaps: @FILE - Current File @LINE- Current Line @FUNCTION - Current pretty function (class and selector) @CLASS - Current class @SELECTOR or @SEL - Current selector

IngwiePhoenix commented 9 years ago

That sounds pretty solid! :) There is a lot of good stuff comming up to the list for OJ. You have any ToDo? :p

iccir commented 8 years ago

Going with @CLASS, @SEL, @FUNCTION. Holding off on file/line information for now.

iccir commented 8 years ago

Just to reiterate: these are for debugging only. They will report the squeezed symbol name if the squeezer is turned on.

iccir commented 8 years ago

Each of these is transformed into a string by the compiler:

- (void) test {
    console.log("Error in " + @FUNCTION + ", Mooooo");
}
IngwiePhoenix commented 8 years ago

Works just fine. :) It is better than having no idea at all.