4 ms·
In a language like guile scheme or racket this could be implemented as a macro. In guile, the (define-inlinable ...) Is already defined as a macro, and while do
by bjoli 6y ago
In a language like guile scheme or racket this could be implemented as a macro. In guile, the (define-inlinable ...) Is already defined as a macro, and while doing it in reverse would be harder it could be done and tested in an hour.
I would probably do it by overriding (define ...) to make it also store the source of the function somewhere and make (inline ...) just insert it as an anonymous function:
(define (square x) (* x x))
(inline square 5)
The last call would be expanded to
((lambda (x) (* x x) 5)
Which the guile inliner always in-lines.