ccrma / chuck

ChucK Music Programming Language
http://chuck.stanford.edu/
GNU General Public License v2.0
777 stars 126 forks source link

Generics or `any` type? #205

Open RobertAlbus opened 2 years ago

RobertAlbus commented 2 years ago

I have a function that rotates an array of ints such that

[1,2,3,4] @=> int arr[];
rotate(arr, 1) @=> arr;
// arr now equal to [2,3,4,1]

I do not want to implement this function for floats, UGens, etc. Is there a facility in ChucK for what some languages call Templates or Generics?

RobertAlbus commented 2 years ago

@gewang @spencersalazar sorry to ping directly - haven't seen anything in the docs elucidating this. Perhaps the route forward for me is casting to Object and back to the original type?

gewang commented 10 months ago

hi @RobertAlbus currently chuck does not support generics, but it is on our list!

BTW you are warmly invited to the new ChucK Community Discord server that can further facilitate tracking issues, support, development, or just to hang; FYI as of May 2023, we are in the 5th major release of chuck (1.5.x.x) and we have a big development roadmap ahead!