Page 1 of 1

Undocumented TLisp feature: Variable arguments

Posted: Sun Sep 17, 2017 4:05 am
by EditorRUS
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,