Created
March 15, 2015 15:51
-
-
Save tizoc/c7d5898135a2f28ee130 to your computer and use it in GitHub Desktop.
This file contains 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
diff -u -w ../Shen 17.3/Sources/macros.shen shen-sources/macros.shen | |
--- ../Shen 17.3/Sources/macros.shen 2015-03-02 17:34:22.000000000 -0200 | |
+++ shen-sources/macros.shen 2015-03-15 12:48:45.000000000 -0300 | |
@@ -176,7 +176,7 @@ | |
(define function-abstraction-help | |
F 0 Vars -> [F | Vars] | |
F N Vars -> (let X (gensym (protect V)) | |
- [/. X (function-abstraction-help F (- N 1) (append Vars [X]))])) | |
+ [lambda X (function-abstraction-help F (- N 1) (append Vars [X]))])) | |
(define undefmacro | |
F -> (let MacroReg (value *macroreg*) | |
diff -u -w ../Shen 17.3/Sources/prolog.shen shen-sources/prolog.shen | |
--- ../Shen 17.3/Sources/prolog.shen 2015-02-12 13:14:32.000000000 -0200 | |
+++ shen-sources/prolog.shen 2015-03-02 19:04:46.000000000 -0200 | |
@@ -526,7 +526,9 @@ | |
(define call | |
[F | X] ProcessN Continuation | |
- -> (call-help (m_prolog_to_s-prolog_predicate (lazyderef F ProcessN)) X ProcessN Continuation) | |
+ -> (let Pred (m_prolog_to_s-prolog_predicate (lazyderef F ProcessN)) | |
+ PredF (symbol->function Pred (length X)) | |
+ (call-help PredF X ProcessN Continuation)) | |
_ _ _ -> false) | |
(define call-help | |
diff -u -w ../Shen 17.3/Sources/sys.shen shen-sources/sys.shen | |
--- ../Shen 17.3/Sources/sys.shen 2015-02-12 13:12:44.000000000 -0200 | |
+++ shen-sources/sys.shen 2015-02-16 20:03:38.000000000 -0200 | |
@@ -39,8 +39,14 @@ | |
(map (function eval-without-macros) (package-contents Macroexpand)) | |
(eval-without-macros Macroexpand)))) | |
+(define proc-defmacro | |
+ [defmacro F | Rest] -> (add-macro F) | |
+ X -> X) | |
+ | |
(define eval-without-macros | |
- X -> (eval-kl (elim-def (proc-input+ X)))) | |
+ X -> (let Result (eval-kl (elim-def (proc-input+ X))) | |
+ Macro (proc-defmacro X) | |
+ Result)) | |
(define proc-input+ | |
[input+ Type Stream] -> [input+ (rcons_form Type) Stream] | |
@@ -51,13 +57,14 @@ | |
(define elim-def | |
[define F | Rest] -> (shen->kl F Rest) | |
[defmacro F | Rest] -> (let Default [(protect X) -> (protect X)] | |
- Def (elim-def [define F | (append Rest Default)]) | |
- MacroAdd (add-macro F) | |
- Def) | |
+ (elim-def [define F | (append Rest Default)])) | |
[defcc F | X] -> (elim-def (yacc [defcc F | X])) | |
[X | Y] -> (map (function elim-def) [X | Y]) | |
X -> X) | |
+(define symbol->function | |
+ Sym N -> (eval-kl (function-abstraction Sym N))) | |
+ | |
\\(define add-macro | |
\\ F -> (set *macros* (adjoin F (value *macros*)))) | |
@@ -66,7 +73,8 @@ | |
NewMacroReg (set *macroreg* (adjoin F (value *macroreg*))) | |
(if (= MacroReg NewMacroReg) | |
skip | |
- (set *macros* [(function F) | (value *macros*)])))) | |
+ (let MacroF (symbol->function F 1) | |
+ (set *macros* [MacroF | (value *macros*)]))))) | |
(define packaged? | |
[package P E | _] -> true | |
diff -u -w ../Shen 17.3/Sources/writer.shen shen-sources/writer.shen | |
--- ../Shen 17.3/Sources/writer.shen 2015-01-23 13:27:22.000000000 -0200 | |
+++ shen-sources/writer.shen 2015-02-13 17:46:33.000000000 -0200 | |
@@ -116,7 +116,7 @@ | |
S _ -> (@s (n->string 34) S (n->string 34))) | |
(define vector->str | |
- V Mode -> (cases (print-vector? V) ((<-address V 0) V) | |
+ V Mode -> (cases (print-vector? V) ((symbol->function (<-address V 0) 1) V) | |
(vector? V) (@s "<" (iter-vector V 1 Mode (maxseq)) ">") | |
true (@s "<<" (iter-vector V 0 Mode (maxseq)) ">>"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment