This page is part of the web mail archives of SRFI 10 from before July 7th, 2015. The new archives for SRFI 10 contain all messages, not just those from before July 7th, 2015.
Date: Mon, 4 Oct 1999 20:50:52 GMT Reply-to: oleg@xxxxxxxxx From: oleg@xxxxxxxxx > Using `#,' in a program has two effects: it causes side effects to > occur at read time and it ensures that a form is evaluated only once. > The first has questionable utility and semantics. The second is > already available in R5RS as `delay' and `force'. I have come across a counter-example to the last statement. Not too hard. I don't know what I was thinking. Please ignore my alternative proposal. The fact that my solution to the problem doesn't work does not mean that SRFI-10 does. You did not respond to the problem that I was trying to solve. The reader is used in two different ways: it is used to read the original program and it is used when that program calls `read'. But how can a program modify the reader that was used to read it? The only way is to break the program in two parts, the first of which runs before the second is read. There is no way to do this in Scheme without using either `load' or `eval'. It is true that my solution uses `eval' (or `load'), but so does yours. BTW, nowhere does SRFI-10 tell that the constructor is a Scheme function; it can be written in any language as long as the reader is able to invoke it passing appropriate parameters. For example, one can write a Scheme->foo _compiler_ in ML and implement reader-constructors as ML functions. I don't understand. The only way to supply contructor functions in SRFI-10 is by doing (define-reader-ctor <symbol> <proc>). How can <proc> be other than a Scheme function? The biggest problem with the above eval-solution is that it assumes that the form read from a file is an expression to be evaluated. Suppose the file contains a string "(1 2 #,(f32 1.0 2.0))" How can you pass the result of reading of this string to eval? It is easy to give a parameterized reader for use in a program. Nothing so involved as read-time evaluation is required. For example: (make-reader) -> <reader> (extend-reader <reader> <symbol> <proc>) -> <reader> A <reader> is function of one argument, an input port, that reads and returns the next s-expression from the port. (<reader> <input-port>) -> <s-expression> `Make-reader' returns a reader that parses the R5RS external syntax. `Extend-reader' returns a new reader that is the same as its first argument except that it uses <proc> as a constructor when it finds #,(<symbol> . <args>) in the input, as is done in SRFI-10. This provides the same functionality as SRFI-10 for reading data values during execution. It has the added advantages of being modular (a program may have multiple readers) and being easy to implement in R5RS. It doesn't solve the problem of using #, in a program, but neither does SRFI-10. -Richard Kelsey