Array assignment #26

lgritz opened this Issue May 20, 2011 · 1 comment


None yet
2 participants

lgritz commented May 20, 2011

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.)

ldo commented Jan 15, 2016

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[];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment