Is it possible to make function calls within a function?

Pixilang programming language
Post Reply
ShockWave
Posts: 51
Joined: Thu Jul 21, 2022 3:48 pm

Is it possible to make function calls within a function?

Post by ShockWave »

Hi I have been using pixilang for less than a week so Im not sure if I am just ignorant or if it is indeed impossible to call functions from within a function since I keep getting syntax errors whenever I try and keep to the same syntax as calling functions outside of the function and that does work.
If this Isnt the case I would like to request this as a feature it would make working in Pixilang a lot more intuitive imo.

Thanks in advance.
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Is it possible to make function calls within a function?

Post by NightRadio »

since I keep getting syntax errors
Please show your code
ShockWave
Posts: 51
Joined: Thu Jul 21, 2022 3:48 pm

Re: Is it possible to make function calls within a function?

Post by ShockWave »

Uh dont know what did wrong the first time but it works... bc ofc it does now. I probably made a mistake somewhere and accidentally fixed it. I was going to write functions in a switch case in the default sunvox curve generator but for the sake of completeness here is the example code.

Code: Select all

fn functionExampleVoid( $x ){
    $randomCode = "randomCode";
}

fn functionExampleRet( $x ){
    $y = $x;
    ret($y);
}


fn curve_function( $x ){
    //$y = $x;

    functionExampleVoid( $x );

    $y = functionExampleRet( $x );
    ret( $y );
}
maks
Posts: 43
Joined: Sat Mar 26, 2022 4:28 am

Re: Is it possible to make function calls within a function?

Post by maks »

Just FYI Pixilang has high order functions, so you can actually pass around references to functions as I recently learnt: https://warmplace.ru/forum/viewtopic.php?f=6&t=6154
Post Reply