The snippet
int test(int a;int b=2)
{
return a+b;
}
returns invalid default value for parameter b error
Is there a way to have default values for function arguments in vex snippets?
Default values for function arguments in vex snippets error
3489 5 1- pashakabush
- Member
- 12 posts
- Joined: March 2017
- Offline
- BabaJ
- Member
- 2042 posts
- Joined: Sept. 2015
- Offline
- tamte
- Member
- 8598 posts
- Joined: July 2007
- Offline
if you expect it to work like python and being able to just omit b to get the defaults, then it's not automatic
you can however create the representation of the function with just a and use default value for b inside
like this:
you can however create the representation of the function with just a and use default value for b inside
like this:
int test(int a;int b) { return a+b; } int test(int a) { int b = 2; return test(a, b); } printf("%g\n", test(1)); // returns 3 (1 + default 2) printf("%g\n", test(1,1)); // returns 2 (1 + 1)
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- lizardstailz
- Member
- 2 posts
- Joined: March 2017
- Offline
tamte
if you expect it to work like python and being able to just omit b to get the defaults, then it's not automatic
you can however create the representation of the function with just a and use default value for b inside
like this:int test(int a;int b) { return a+b; } int test(int a) { int b = 2; return test(a, b); } printf("%g\n", test(1)); // returns 3 (1 + default 2) printf("%g\n", test(1,1)); // returns 2 (1 + 1)
That's exactly what i did)
Still it's strange that this example errors out in snippets
taken from http://www.sidefx.com/docs/houdini/vex/lang [www.sidefx.com]
surface noise_surf(vector clr = {1,1,1}; float frequency = 1; export vector nml = {0,0,0}) { Cf = clr * (float(noise(frequency * P)) + 0.5) * diffuse(normalize(N)); nml = normalize(N)*0.5 + 0.5; }
- tamte
- Member
- 8598 posts
- Joined: July 2007
- Offline
lizardstailzI don't think you can define a shader in the snippet
Still it's strange that this example errors out in snippets
snippet already runs within the context function
so you can use just normal VEX functions, which don't have default values for arguments
Edited by tamte - Oct. 30, 2017 17:25:16
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- pashakabush
- Member
- 12 posts
- Joined: March 2017
- Offline
-
- Quick Links