Closed rexim closed 8 years ago
This trick is usually done via eval-when-compile
elisp macro.
Just managed to compile rot13 example:
(eval-when-compile
(require 'ebf))
(defun rot13 (text)
(let ((input (mapcar #'identity text))
(result nil))
(ebf (lambda () (if (not input) -1 (pop input)))
(lambda (x) (push x result))
-\,+
[-
[>>++++
[>++++++++<-]
<+<-
[>+>+>-
[>>>]
<
[[>+<-]>>+>]
<<<<<-]]
>>>[-]+
>--
[-[<->+++[-]]]<
[++++++++++++<
[>-
[>+>>]
>[+[<+>-]>+>>]
<<<<<-]
>>[<+>-]
>[-[-<<[-]>>]<<[<<->>-]>>]
<<[<<+>>-]]
<[-]
<.[-]
<-\,+])
(apply #'string (reverse result))))
(provide 'rot13)
And the resulting module really doesn't require ebf at runtime. It's possible.
But if I want to byte compile without runtime dependency I should not use ebf-input-string
in my code.
The result of the ebf macro expansion doesn't require ebf at runtime. So theoretically it's possible to byte-compile a brainfuck program that doesn't require ebf package at runtime. We need to check and document that.