Created
March 26, 2017 13:52
-
-
Save aamedina/361daea7917797e40439232fb75ea119 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defvar *local-type-declarations* '()) | |
| (defmacro local-type-declare (declarations &body forms) | |
| `(compiler-let ((*local-type-declarations* | |
| (append ',declarations *local-type-declarations*))) | |
| ,@forms)) | |
| (defmacro typed-var (var) | |
| (let ((type (assoc var *local-type-declarations*))) | |
| (if type `(the ,(cadr type) ,var) var))) | |
| (defun f (x y) | |
| (local-type-declare ((x fixnum) (y float)) | |
| (+ (typed-var x) (typed-var y)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment