GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
WBN to extend the oso "assign" to be able to assign arrays in one instruction. This isn't allowed in OSL at the moment, but happens implicitly if you do structure assignment and the structure contains an array. Making it one assignment, instead of the current code generation for element-by-element copy, will make more compact oso's as well as make it very easy for the LLVM IR generation to turn it into a simple memcpy.
We could also open debate on whether we should allow assignment of arrays in the OSL source language. (The only important counter-argument is simply that C does not allow it, and we try to minimize gratuitous differences from C unless they are significant improvements or specializations for shader programming in particular.)
The problem with C is that it treats arrays and pointers the same in terms of element access. This is why it cannot allow direct array assignment. OSL doesn’t have such an issue, but when you make a language “C-like”, this is the price you pay.
Let me suggest a separate syntax indicating explicit array assignment: how about empty brackets? E.g.
arr1 = arr2;