[Sidefx-houdini-list] array elements referring in VEX

Szymon Kapeniak szymon.kapeniak at gmail.com
Tue Aug 24 06:39:18 EDT 2010


Hi Olex,
momentarily I feel my expectation is bizarre, but what interest me is
that rsl code works this way. Since all variables are send by
reference, I felt it makes sense that:

void userf( float a) {a=1;} modifies array's element test[0] sent to
user function because any user function expects a reference to a
variable (and shouldn't pay an attention that it's an array element in
fact).

 ...at least for my untrained-in-pointers brain it makes sense. Anyhow
looks like vex doesn't like this approach.

thanks!



2010/8/24 Olex P <hoknamahn at gmail.com>:
> Hi Szymon,
>
> I believe there is nothing like a C pointer in VEX, so even if you can pass
> one element of array and give it's value to other variable like this:
>
> <code>
>
> void userf(float a) {  float b = a; }
>
> surface test()
> {
>
>  float test[] = {0,0,0};
>  userf(test[0]);
>  printf("%f", test);
> }
>
> </code>
>
> you still need an indexing operation in order to modify an element of array.
>
>
> On Tue, Aug 24, 2010 at 10:57 AM, Szymon Kapeniak <szymon.kapeniak at gmail.com
>> wrote:
>
>> hello,
>> me or vex can't handle referencing array's element as user function's
>> variable. Is it my mistake (hopefully), or in fact a current
>> limitation (rsl seems to work this way)?
>>
>> <code>
>>
>> void userf(float a) {  a = 1.0; }
>>
>> surface test()
>> {
>>
>>   float test[] = {0,0,0};
>>   userf(test[0]);
>>   printf("%f", test);
>> }
>>
>> </code>
>>
>> if userf() is changed to accept w whole array, this of course works:
>>
>> void userf(float a[]) { a[0] = 1.0; }
>>
>>
>> thanks for any comments!
>> skk.
>> _______________________________________________
>> Sidefx-houdini-list mailing list
>> Sidefx-houdini-list at sidefx.com
>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>>
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>



More information about the Sidefx-houdini-list mailing list