-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add C++ style method definition and invocation. #839
base: main
Are you sure you want to change the base?
Conversation
Hi there, no comments about the details in the PR from me at this stage (I'm interested though!) Can just suggest for these sort of major language additions/changes that the oslc compiler emits a cpp macro define that indicates the presence of the feature? I haven't looked through the code in detail (sorry!) so it may be there already? But for example in this case: And perhaps for your other PR Absolutely no attachment to those names so feel free to change the naming schema/convention but just some sort of mechanism for osl shader writers to migrate their code gracefully between major feature leap versions of OSL. Interesting stuff though! I'm not adverse to having a few C++-isms in OSL myself! I realise these sorts of things are hard to implement efficiently in a language but dynamic resizable arrays sure helped cut some corners when you are designing more niche/experimental algorithms (or bubble sorting algorithms etc). Sorry to go off topic a little but just throwing in 2 pence worth on this while I can :) |
Using OSL_VERSION_MAJOR and OSL_VERSION_MINOR macros should work. Besides the convenience of init-list syntax, I need OSL & C++ to be able to intermingle a bit better than they currently can. I can't speak for the maintainers, but inheritance and dynamic memory isn't on the horizon for me. |
…ass ASTnamed_symbol.
Interestingly, this also allows a clean path forward for the class of ambiguity:
|
Description
Ads ability to invoke and define functions with an implicit this argument for both structs and vector types.
I'm not particularly keen on the
this[i]
syntax of the second example and would prefer named component access (#836) and to make that a syntax error.The third example is perhaps a bit to broad and could be limited to opt in or out via some meta-data on the function.
Tests
Variety of tests defining, invoking, and warning about variables shadowing fields:
testsuite/function-method
testsuite/oslc-err-method
testsuite/oslc-err-names
Checklist: