mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
WIP
This commit is contained in:
parent
f00929971d
commit
336eaa5059
1 changed files with 36 additions and 14 deletions
|
@ -1,19 +1,41 @@
|
||||||
(import (scheme base) (scheme write))
|
(import (scheme base) (scheme write))
|
||||||
|
|
||||||
;; Fails when compiling compiler benchmark:
|
;;; Fails when compiling compiler benchmark:
|
||||||
(define (proper-length l)
|
;(define (proper-length l)
|
||||||
(define (length l n)
|
; (define (length l n)
|
||||||
(cond ((pair? l) (length (cdr l) (+ n 1))) ((null? l) n) (else #f)))
|
; (cond ((pair? l) (length (cdr l) (+ n 1))) ((null? l) n) (else #f)))
|
||||||
(length l 0))
|
; (length l 0))
|
||||||
|
;
|
||||||
|
;
|
||||||
|
;;; One possible idea, alpha conversion could maintain a local lexical environment, "locals"
|
||||||
|
;;; and use that to rename identifiers that clash with primitives.
|
||||||
|
;;; Might be able to use a list of hash tables (or alists) for this purpose.
|
||||||
|
;;; Just load up a new list when a new scope is encountered, and add any
|
||||||
|
;;; "define", "set!", or "lambda" variables to it. then if a ref is a
|
||||||
|
;;; local, we need to rename it
|
||||||
|
;;; TODO: can we use same environments as "eval" uses for this? makes
|
||||||
|
;;; sense not to reinvent things
|
||||||
|
;
|
||||||
|
;(write (proper-length '(a b c)))
|
||||||
|
|
||||||
|
|
||||||
;; One possible idea, alpha conversion could maintain a local lexical environment, "locals"
|
;; Seems graphs is timing out, possibly due to too many mutations
|
||||||
;; and use that to rename identifiers that clash with primitives.
|
;; in its loops. see "set!" introduced by macro expansion below:
|
||||||
;; Might be able to use a list of hash tables (or alists) for this purpose.
|
(define size 10)
|
||||||
;; Just load up a new list when a new scope is encountered, and add any
|
(let loop ((i 1))
|
||||||
;; "define", "set!", or "lambda" variables to it. then if a ref is a
|
(if (< i size)
|
||||||
;; local, we need to rename it
|
(begin (write i) (loop (+ i 1)))))
|
||||||
;; TODO: can we use same environments as "eval" uses for this? makes
|
|
||||||
;; sense not to reinvent things
|
;; Current macro expansion
|
||||||
|
(newline)
|
||||||
|
((lambda (i)
|
||||||
|
((lambda (loop)
|
||||||
|
(set! loop
|
||||||
|
(lambda (i)
|
||||||
|
(if (< i size)
|
||||||
|
((lambda () (write i) (loop (+ i 1))))
|
||||||
|
#f)))
|
||||||
|
(loop i))
|
||||||
|
#f))
|
||||||
|
1)
|
||||||
|
|
||||||
(write (proper-length '(a b c)))
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue