eerolanguage / eero

Eero was a fully binary- and header-compatible dialect of Objective-C, implemented with a modified version of the Apple-sponsored LLVM/clang open-source compiler. It featured a streamlined syntax, Python-like indentation, and other features that improve readability and code safety. It was inspired by languages such as Smalltalk, Python, and Ruby.
https://web.archive.org/web/20171101134337/http://eerolanguage.org/
288 stars 7 forks source link

Macros and escaping to Objective-C code #38

Closed esummers closed 11 years ago

esummers commented 11 years ago

The biggest problem I encountered playing with EERO is compatibility with CPP macros. This prevents Sen, Kiwi, Reactive Cocoa, etc. from working properly.

I think the obvious solution is to add syntax to escape to standard Objective-C and insert code that would otherwise be invalid in EERO. Ideally EERO should also automatically escape for CPP macros from non-EERO source files so they just work. Parameters to the macros would need to be excluded. This may also be useful for embedding C++ code that would otherwise have problems.

Example: (using "begin_objc { … }" as example syntax)

implementation

eeroMethod, return String = 'eero side'

begin_objc {
- (NSString *)objcMethod {
    return @"objc side";   
}
}

eeroMethod2, return String
    begin_objc {
        return [self objcMethod];
    }

eeroMethod3, return String
    return MY_OBJC_MACRO('arg 1', 'arg 2')

end
andyarvanitis commented 11 years ago

This is definitely a problem. I've done some investigation into automatic handling of "legacy" function-like macros, but haven't been happy with the results yet. We will look into it more.

The "escaped section" is also an interesting idea.

andyarvanitis commented 11 years ago

Work in progress can be found in branch "legacy_macros":

https://github.com/eerolanguage/clang-trunk/tree/legacy_macros

esummers commented 11 years ago

Very nice!

andyarvanitis commented 11 years ago

Just a quick update on this one: it's still undergoing testing, but looks good overall. It's still in the "legacy_macros" branch for now, and will be merged into master when this issue gets closed. ETA is a couple more days from now.

andyarvanitis commented 11 years ago

As of commit e04381ca59 (binary clang-eero-2013-08-09.zip), support for standard CPP macros is greatly improved. No special syntax is needed, they should just work. Parameters are parsed as eero syntax.

Tested with Foundation, ReactiveCocoa (incl 2.0), SenTestingKit, and other macros. Kiwi is more like a DSL, and doesn't work well embedded in eero code. I'll try to work on some workarounds for it. Closing this issue as I think the solution should be adequate for now.

esummers commented 11 years ago

Good work!

andyarvanitis commented 11 years ago

Thanks! Please feel free to report any other issues you find.