Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!mintaka!ai-lab!zurich.ai.mit.edu!jinx From: jinx@zurich.ai.mit.edu (Guillermo J. Rozas) Newsgroups: comp.lang.scheme Subject: Re: Are numbers self evaluating? Message-ID: Date: 27 Feb 91 01:54:36 GMT References: <1991Feb26.205210.21352@cunixf.cc.columbia.edu> Sender: news@ai.mit.edu Reply-To: jinx@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 62 In-reply-to: amh@cunixb.cc.columbia.edu's message of 26 Feb 91 20:52:10 GMT In article <1991Feb26.205210.21352@cunixf.cc.columbia.edu> amh@cunixb.cc.columbia.edu (Adam M. Heyman) writes: Path: ai-lab!mintaka!snorkelwacker.mit.edu!usc!wuarchive!bcm!dimacs.rutgers.edu!rutgers!cunixf.cc.columbia.edu!cunixb.cc.columbia.edu!amh From: amh@cunixb.cc.columbia.edu (Adam M. Heyman) Newsgroups: comp.lang.scheme Date: 26 Feb 91 20:52:10 GMT Sender: news@cunixf.cc.columbia.edu (The Daily News) Organization: Columbia University Lines: 53 While fooling around with MIT Scheme 7.1, found this interesesting phenomena. Apparently, multidigit numbrs are not self evaluating, they need to go through adds (+) and multiplies (*) in order to evaluate. What follows is an edited journal of a session: [journal deleted] If anyone out there has some insight as to why Scheme is doing this, please let me know. I would be very interested to learn why it decomposes numbers, and then builds them back up (from the point of view of the user, I realize that the decomposition is probably just the way the input handler functions, but this is pure conjecture), especially since numbers in scheme are supposed to be self evaluating. You are confusing reading with evaluation. Self evaluation means that the value of a numeral is the number it represents without needing to quote it. You are right in assuming that the process that you've discovered is the act of constructing the number from the individual characters that compose the numeral, but it is not the evaluation of the number. The interpreter is given character sequences which must be converted to Scheme objects before they can be evaluated. Numbers are built one digit at a time by the process that you noticed. Once they are built, evaluation is idempotent on them. In other words, what you saw was READ doing its job. Your input had not yet been given to EVAL (and will never be, since EVAL does not deal with character strings). If you think about it, you'll realize that C's scanf, Pascal's read and almost every other language's formatted reader must do something equivalent. C and Pascal compilers use similar things for constructing self-evaluating numbers at compile time. BTW, the message in (trace +) Automagically impurifying an object... ;;What the heck does this mean? ;No value means that the value of + was in a static area of memory that cannot be written (pure space). Thus when you asked for it to be traced (which involves a side effect), it needed to be moved out before your request could be honored. The message is a notification that an object was being moved out of pure space. I personally think that such messages should not appear unless explicitly allowed by the user, but...