Retraction
January 15, 2009 at 11:45 pm | In coding, lisp, scheme | 1 CommentTags: chicken, r5rs, scheme
It would appear that point #4 of my earlier proposal is entirely unnecessary. A modifiable load function, like the one found in CHICKEN Scheme, can be implemented as follows:
(define (load path . evalproc) (let ((eval (lambda (expr) (eval expr (interaction-environment))))) (if (and evalproc ;; Do some checks on the procedure (list? evalproc) (> (length evalproc) 0) (procedure? (car evalproc))) (set! eval (car evalproc)) ;; True #f) ;; False (letrec ((eval-datum (lambda () (let ((datum (read))) (if (eof-object? datum) path (begin (eval datum) (eval-datum))))))) (with-input-from-file path eval-datum))))
Some of this code is probably unnecessary, but I felt it better to err on the side of checking too much before using the optional evaluation procedure. I could also trivially rewrite it to use the more clear DO form, rather than a tail-recursive lambda. Also, it might be more adviseable to use the standard LOAD function if no special evaluation procedure is given. I’m torn on that last one. Whatever.
But anyway, I see now that I really should have given the matter some deeper thought before immediately writing a lengthy proposal to change fundamental language features. Over the next few days, I intend to work on a Scheme implementation detection library. If I am successful, the two most important points of my earlier proposal will have been fulfilled, and I will be content.
It’s been a learning experience.
1 Comment »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.
[...] that implementation detection and redefining the load function are tasks eminently better fitted to an external library than to a modification to the core language. While I still believe that Unicode and Unix shebangs [...]
Pingback by We Need An R5.1RS « It Seemed Like A Good Idea, At The Time — January 15, 2009 #