Skip to main content
Discovery icon for VRChat Discord server

VRChat

111,304 Online
419,703 Members
# world-development5 people

how recursive works in UdonSharp

UdonSharp stores local variables as class fields unless marked recursive, which adds stack push and pop overhead to prevent overwriting.

  • UdonSharp typically compiles local variables as class fields, causing recursive function calls to overwrite values unless the recursive attribute is used
  • The recursive attribute instructs the compiler to push and pop local variables on a stack, introducing slight performance overhead
  • A recursive method may still function without the attribute if local variables are not written to prior to the self-call
  • Calculating algorithms like Fibonacci without the recursive attribute produces incorrect results due to variable clobbering
  • UdonSharp generates type-specific implementations for static generic functions, copying static functions directly into each calling class
Summarized from recent messages, might be inaccurate

More conversations

Talk, Play, &
Hang Out

Find your space to hang out, discuss the latest updates with the party chat, and see who's down to join your next match.
Get App