Undocumented TLisp feature: Variable arguments

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

Sun Sep 17, 2017 4:05 am

While browsing Transcendence's source code, I came across a surprising comments that completely blew everyone's minds: you can actually make variable arguments!


And indeed it works. What's mind-blowing is that it's NEVER used ANYWHERE.
This allows you to create a higher-order function partial defined as follows

Code: Select all

(setq partial
  (lambda (func %args)
    (block ((const_args %args)) ; Required to create a closure which stores frozen arguments and also create an alias for %args
      (lambda (%args) ; partial returns a function
        (apply func (append const_args %args)))))) ; func is stored in the closure and so is const_args,

Post Reply