SICP isn' the bible, especially not on programming language knowledge. I'd recommend checking out relevant literature instead.
On May 18, 2015, at 8:24 AM, Michael Tiedtke <michael.tied...@o2online.de> wrote: > Structure and Interpretation of Computer Programs (sicp2) about sameness: > > https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#footnote_Temp_230 >> We can consider two symbols to be ``the same'' if they consist of the same >> characters in the same order. Such a definition skirts a deep issue that we >> are not yet ready to address: the meaning of ``sameness'' in a programming >> language. We will return to this in chapter 3 (section 3.1.3). > > https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-20.html#%25_idx_2994 >> A language that supports the concept that ``equals can be substituted for >> equals'' in an expresssion without changing the value of the expression is >> said to be referentially transparent. Referential transparency is violated >> when we include set! in our computer language. This makes it tricky to >> determine when we can simplify expressions by substituting equivalent >> expressions. Consequently, reasoning about programs that use assignment >> becomes drastically more difficult. >> >> Once we forgo referential transparency, the notion of what it means for >> computational objects to be ``the same'' becomes difficult to capture in a >> formal way. Indeed, the meaning of ``same'' in the real world that our >> programs model is hardly clear in itself. In general, we can determine that >> two apparently identical objects are indeed ``the same one'' only by >> modifying one object and then observing whether the other object has changed >> in the same way. But how can we tell if an object has ``changed'' other than >> by observing the ``same'' object twice and seeing whether some property of >> the object differs from one observation to the next? Thus, we cannot >> determine ``change'' without some a priori notion of ``sameness,'' and we >> cannot determine sameness without observing the effects of change. > > Maybe the uncertainities of wether to use eq?, eqv? or equal? have their > roots in the general concept of sameness and the needs of different > implementations. Two symbols with the same sequence of characters should be > eq? and eqv?. > > But eq? is not well defined for numbers: (eq? 2 2) is unspecified but what > about (eq? '2 '2)? > (+ '1 '2) => 3 because the reader treats numerical symbols in another way. > > Anyway (eq? 'l 'l) should always be true even though this morning I read it > as (eq? 1 1) which looks almost the same. > > > Il giorno 18/mag/2015, alle ore 07.28, Alexis King ha scritto: > >> Yes, Scheme (and therefore Racket) has eq?, eqv?, and equal?. I understand >> the desire for eq? and equal?, but I’ve always been skeptical of the >> necessity of eqv?. Either way, Scheme left this behavior unspecified, but I >> believe Racket specifies it (though I could be wrong). >> >> Racket has two kinds of symbols, interned and uninterned. Symbols produced >> by the reader, whether via read or read-syntax, are interned. Additionally, >> string->symbol produces interned symbols. Certain functions such as gensym >> and string->uninterned-symbol produce uninterned symbols, but these are not >> commonly encountered, anyway. >> >> Interned symbols, I believe, are guaranteed to be eq? since they’re, well, >> interned. There is a pool of interned symbols such that all symbols made up >> of the same string are all the same object, so they’re all eq?. >> >> I can’t reproduce the behavior in the original message, and I don’t think it >> should be possible. >> >>> On May 17, 2015, at 22:19, Michael Tiedtke <michael.tied...@o2online.de> >>> wrote: >>> >>> I'm new to Racket but even R5RS is rather clear about this issue: >>> >>> (citation from doc/r5rs/r5rs-std/r5rs-Z-H-9.html) >>>> (eq? 2 2) ===> unspecified >>>> >>>> Rationale: It will usually be possible to implement eq? much more >>>> efficiently than eqv?, for example, as a simple pointer comparison instead >>>> of as some more complicated operation. One reason is that it may not be >>>> possible to compute eqv? of two numbers in constant time, whereas eq? >>>> implemented as pointer comparison will always finish in constant time. Eq? >>>> may be used like eqv? in applications using procedures to implement >>>> objects with state since it obeys the same constraints as eqv?. >>> >>> >>> You should use "=" with numbers as far as I remember. >>> >>> >>> Il giorno 18/mag/2015, alle ore 02.41, George Neuner ha scritto: >>> >>>> Hi, >>>> >>>> On 5/17/2015 5:32 PM, Atticus wrote: >>>>> --------------------------- >>>>> $ racket >>>>> Welcome to Racket v6.1.1. >>>>>> (eq? 'l 'l) >>>>> #f >>>>>> (eq? 'l 'l) >>>>> #t >>>>>> >>>>> >>>>> $ racket --no-jit >>>>> Welcome to Racket v6.1.1. >>>>>> (eq? 'l 'l) >>>>> #f >>>>>> (eq? 'l 'l) >>>>> #t >>>>>> (eq? 'l 'l) >>>>> #f >>>>>> (eq? 'l 'l) >>>>> #t >>>>>> (eq? 'l 'l) >>>>> #t >>>>>> (eq? 'l 'l) >>>>> #t >>>>>> (eq? 'l 'l) >>>>> #f >>>>>> (eq? 'l 'l) >>>>> #f >>>>>> >>>>> >>>>> --------------------------- >>>>> >>>>> How to reproduce this behaviour? Just start racket from the command line >>>>> and type '(eq? 'l 'l), this should return #f (or sometimes #t). The next >>>>> time the same expression returns #t. Whats also interesting is that with >>>>> the command line option --no-jit the return value seems to randomly >>>>> change between #t and #f. ... >>>> >>>> I can't reproduce this. Might there have been some control characters >>>> accidentally in your input? >>>> >>>> I have 6.1.1 32-bit and 64-bit on Windows 7, and 64-bit on Centos 6.6 and >>>> Ubuntu 14.04. Tried them all with and without JIT. Also tried the repl >>>> in DrRacket on Windows (Linux are command line only). All worked as >>>> expected. >>>> >>>> George >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Racket Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send an >>>> email to racket-users+unsubscr...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Racket Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to racket-users+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Racket Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to racket-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.