jsoftware / jsource

J engine source mirror
Other
645 stars 91 forks source link

tail-call optimisation and 'tail usage optimisation' #153

Open moon-chilled opened 1 year ago

moon-chilled commented 1 year ago

More important than regular tco is automatically turning the last use of a local name in an explicit definition into a self-effacing reference, so that it can be in-placed (or simply reclaimed sooner than otherwise). Should be controllable with a global toggle as it inhibits debugging (but should be separate from the ordinary debug toggle).

moon-chilled commented 1 year ago

A difficulty:

f=: {{
 g=: ".
 b=: 'y' }}
h=: {{
 f''
 u y
 v g b }}

Smuggles in a reference to the name, so can't transparently be turned into u y_:.