[racket-users] Racket should not cancel an OS shutdown
When I try to shutdown my Mac Racket (run from the command line) cancels the shutdown or logout. I can install an application-quit-handler (with racket/gui) like this: ;; ;; Operating System Interface Incoming (define (quit-request) ;; XXX this is called but racket still cancels ;; any shutdown, restart or logout (debug-message quit-request called) (send main-frame show #f) (exit) #t) (application-quit-handler quit-request) On logout or shutdown the new handler is called, closes main-frame but Racket still does not exit and cancels the shutdown. It does exit when the only window main-frame is closed manually, when I choose a menu item with exit in its handler or when I choose the Quit menu item in the Mac Application menu. There is an old bug report about this here: http://bugs.racket-lang.org/query/?cmd=viewpr=12252 Does anyone know how to make Racket behave better? -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
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
RE: [racket-users] constant propagation
Hi Matthias, Thanks for your clear answer. You're right, of course. I am curious, but that's not bad I think, although it may sometimes be annoying. Consider my post as a compliment, please. Thanks again, Jos _ From: Matthias Felleisen [mailto:matth...@ccs.neu.edu] Sent: lunes, 18 de mayo de 2015 13:17 To: Jos Koot Cc: racket-users@googlegroups.com Subject: Re: [racket-users] constant propagation Constant propagation is not a property of a language but its implementation. Few implementations document which transformations they currently implement. -- Matthias On May 18, 2015, at 7:11 AM, Jos Koot wrote: Very nice constant propagation in Racket. For example the Racket compiler pre-evaluates: (let ((b 2)) (sqrt (+ 2 b))) to '2. That is what zo-parse and decompile tell me. May be I missed it, but looking for info on constant propagation I found no info about this in the docs. If there is info, please tell me where. Thanks to the plt Racket team! Jos koot -- 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.
Re: [racket-users] racket testing on openwrt
At Mon, 18 May 2015 07:16:39 -0400, Jay McCarthy wrote: On Sun, May 17, 2015 at 5:00 PM, Neil Van Dyke n...@neilvandyke.org wrote: Can someone recommend an easy way to test Racket 9.2 pre-release on OpenWrt (embedded GNU/Linux, running on a normal home WiFi router)? For example, is there a big tree of files that I could just copy onto a USB flash drive, and run with one command, and it would dump its log to a file or stdio? (I see http://drdr.racket-lang.org/help;, but I don't know whether that's what I should be using, nor what an easy way to use it would be. I'd prefer to run the tests disconnected from the Internet, if that matters.) DrDr is just a service used by PLT to make sure there are no software regressions. It isn't really designed to be usable by other people because the configuration is so specific. The `raco test --drdr` tool is meant to encode the testing that DrDr performs so that anyone can run the same tests. Also, while only some tests are included in the main distribution, all tests are in packages. So, to test everything in the main distribution, you should be able to install the main-distribution-test package and run `raco test --drdr .` in the collects and share/pkgs directories. It looks like we're missing an option to `raco test` that means all collections, and I'll look into adding that. -- 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.
[racket-users] Doing pattern matching by reader macro
Hi Racketeers, I am a new user of Racket. I would want to be able to write the following segment of code: (define (f #t) 2) (define (f #f) 3) (define (f _) 0) My intention is to define a function f, such that given an argument #t it will produce 2, or in case given an argument #f it will produce 3. For any other value (shown by underscore), it will give 0. This is done by pattern matching. Obviously, I cannot do this straightforward, because in current Racket the definitions in the prior lines will be overshadowed by definitions given in the lines after. Moreover, I cannot give the real values of argument, #t, #f and underscore, directly. If I do want to write the code as shown above, probably I have to use reader macro. The question now is, how to do it? How to implement a pattern-matching-style syntax by means of reader macro? Thank you all for helping me, a real new beginner in Racket language. M. -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
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
Re: [racket-users] Doing pattern matching by reader macro
#lang racket (define/match (f n) [(#t) 2] [(#f) 3] [(_) 0]) (list (f #t) (f #f) (f where's my homework)) On May 18, 2015, at 9:04 AM, Mianlai Zhou mianlai.resea...@gmail.com wrote: Hi Racketeers, I am a new user of Racket. I would want to be able to write the following segment of code: (define (f #t) 2) (define (f #f) 3) (define (f _) 0) My intention is to define a function f, such that given an argument #t it will produce 2, or in case given an argument #f it will produce 3. For any other value (shown by underscore), it will give 0. This is done by pattern matching. Obviously, I cannot do this straightforward, because in current Racket the definitions in the prior lines will be overshadowed by definitions given in the lines after. Moreover, I cannot give the real values of argument, #t, #f and underscore, directly. If I do want to write the code as shown above, probably I have to use reader macro. The question now is, how to do it? How to implement a pattern-matching-style syntax by means of reader macro? Thank you all for helping me, a real new beginner in Racket language. M. -- 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.
Re: [racket-users] Doing pattern matching by reader macro
Your best bet is to define a new language that overrides define after taking over the body of the module. This may even be an example in the docs. On May 18, 2015, at 9:39 AM, Mianlai Zhou mianlai.resea...@gmail.com wrote: Hi Matthias, Thanks for answer. However, this is not what I wanted: I want to persist that I can write the code below (where define can be changed to other name): (define (f #t) 2) (define (f #f) 3) (define (f _) 0) to do what I want to do. So how should I define my define in order to do it? Your answer is perfect but it is a different form from my original code above. Could you give me an answer? Thanks. M. On Mon, May 18, 2015 at 9:20 PM, Matthias Felleisen matth...@ccs.neu.edu wrote: #lang racket (define/match (f n) [(#t) 2] [(#f) 3] [(_) 0]) (list (f #t) (f #f) (f where's my homework)) On May 18, 2015, at 9:04 AM, Mianlai Zhou mianlai.resea...@gmail.com wrote: Hi Racketeers, I am a new user of Racket. I would want to be able to write the following segment of code: (define (f #t) 2) (define (f #f) 3) (define (f _) 0) My intention is to define a function f, such that given an argument #t it will produce 2, or in case given an argument #f it will produce 3. For any other value (shown by underscore), it will give 0. This is done by pattern matching. Obviously, I cannot do this straightforward, because in current Racket the definitions in the prior lines will be overshadowed by definitions given in the lines after. Moreover, I cannot give the real values of argument, #t, #f and underscore, directly. If I do want to write the code as shown above, probably I have to use reader macro. The question now is, how to do it? How to implement a pattern-matching-style syntax by means of reader macro? Thank you all for helping me, a real new beginner in Racket language. M. -- 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.
[racket-users] Typed Racket: Shuffle Polymorphic Function problem
Folks, I'm trying to write a shuffle function in TR, composed of a Cutter function and a Riffler function. I start with a few types and implementations for a cutter and a riffler. The shuffler is basically (riffle (cut deck)): -- #lang typed/racket (define-type (Cutter A) ((Listof A) - (Values (Listof A) (Listof A (define-type (Riffler A) ((Listof A) (Listof A) - (Listof A))) (define-type (Shuffler A) ((Listof A) - (Listof A))) (: overhand-cutter Cutter) (define (overhand-cutter l) (split-at l (random (length l (: overhand-riffler Riffler) (define (overhand-riffler p1 p2) (append p2 p1)) (: uncomposed-o/h-shuffler Shuffler) (define (uncomposed-o/h-shuffler deck) (call-with-values (λ () (overhand-cutter deck)) overhand-riffler)) -- uncomposed-o/h-shuffler behaves (typewise), as I'd expect: (:print-type uncomposed-o/h-shuffler) Shuffler ((inst uncomposed-o/h-shuffler Integer) '(1 2 3)) - : (Listof Integer) (2 3 1) ((inst uncomposed-o/h-shuffler Symbol) '(1 2 3)) [X] Type Checker: type mismatch expected: (Listof Symbol) given: (List One Positive-Byte Positive-Byte) in: (quote (1 2 3)) Now I want to factor that composition into a function that takes a cutter, a riffler and produces a shuffler: -- (: shuffler-composer (All (A) (Cutter A) (Riffler A) - (Shuffler A))) (define ((shuffler-composer cut riffle) deck) (call-with-values (λ () (cut deck)) riffle)) ;; Note the annotation is currently commented out ;; (: composed-overhand-shuffler (All (A) (Shuffler A))) (define composed-overhand-shuffler (shuffler-composer overhand-cutter overhand-riffler)) -- composed-overhand-shuffler is of type: (:print-type composed-overhand-shuffler) (- (Listof Any) (Listof Any)) Which is not a shuffler (it doesn't undertake to return the same type of list as its input). Uncommenting the : annotation above the function declaration moves the problem to be a syntax error... -- [X] shuffle.rkt:27:2: Type Checker: Polymorphic function `shuffler-composer' could not be applied to arguments: Argument 1: Expected: (- (Listof A) (values (Listof A) (Listof A))) Given:Cutter Argument 2: Expected: (- (Listof A) (Listof A) (Listof A)) Given:Riffler Result type: (- (Listof A) (Listof A)) Expected result: Shuffler in: (shuffler-composer overhand-cutter overhand-riffler) -- I have tried everything (with the exception of the right thing) to mould this function to my will: - used longhand types rather than the define-types Riffler, Cutter and Shuffler - All'ed, inst'ed, ann'ed and cast'ed everywhere - used various approached to the implementation. Here we have call-with-values, but I have used define-values (with/without annotations), explicit and automatic currying -- the works. Everything seems to be being done; except the annotation of the return from shuffler-composer. What am I missing? Do I not understand something? Am I not hinting TR quite well enough? Is there a bug in TR stopping me? Is this a fundamental limitation of TR's type system? Please could someone help. Thanks. Tim --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
George Neuner gneun...@comcast.net writes: 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? Since i can not reproduce this behavior reliably anymore and because this happend only while typing the expression by hand that should be the most plausible explanation. Thanks to everyone for your help -- 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.
Re: [racket-users] Typed Racket: Shuffle Polymorphic Function problem
Thanks Sam, I swear I came *so* close to that! I'll take a good hard look over the TR Guide; I'm sure it'll make sense. Tim On 18/05/15 17:16, Sam Tobin-Hochstadt wrote: Typed Racket doesn't bring the type variable `A` into scope on the right-hand side of the `define`, because it isn't a function definition. This should probably change, but it means that all we need to do is make the definition less point-free: (: composed-overhand-shuffler (All (A) (Shuffler A))) (define (composed-overhand-shuffler x) (((inst shuffler-composer A) overhand-cutter overhand-riffler) x)) Sam On Mon, May 18, 2015 at 4:15 AM Tim Brown t...@timb.net mailto:t...@timb.net wrote: I have tried everything (with the exception of the right thing) to mould this function to my will: - used longhand types rather than the define-types Riffler, Cutter and Shuffler - All'ed, inst'ed, ann'ed and cast'ed everywhere - used various approached to the implementation. Here we have call-with-values, but I have used define-values (with/without annotations), explicit and automatic currying -- the works. -- Tim Brown CEng MBCS tim.br...@cityc.co.uk City Computing Limited · www.cityc.co.uk City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB T:+44 20 8770 2110 · F:+44 20 8770 2130 City Computing Limited registered in London No:1767817. Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE VAT No: GB 918 4680 96 -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
Il giorno 18/mag/2015, alle ore 18.06, Atticus ha scritto: I guess it's a matter of definition. I must admit that i didn't reflect on equality that much. My (very limited) knowledge about that stuff comes mostly from the The Little Schemer which imho explains it really well with the 'eqan?' and 'eqlist?' procedure. The reason why i checked (eq? 'symbol1 'symbol2) in the first place in racket was because in gambit scheme (eq? string string) returned #f and in racket returns #t. I just wanted to check the differences between racket and gambit and was really surprised as (eq? 'symbol1 'symbol2) returned #f in the racket repl (which was likely because of escape characters) It's great to see someone do these checks. I guess it's important to realize that (eq? 'symbol 'symbol) should always return true because of its definition. If it does not return true than that would be a real error and as symbols are usually used all over the place to denote unimplemented concepts the system would break early on. I was not able reproduce the described behavior but one never knows ... Comparing two strings on the other hand is not defined for eq? or let's say it's defined as unspecified. That's because some implementations might create a new data object for each string and return #f for (eq? string string). Other implementations try to save memory and realize that string and string have the same content so they can be substituted by a pointer to one data structure containing string. But I cannot rely on that behavior because in other situations the same string might be represented by another pointer to a different data structure. So eq? only checks for equality of pointers to data structures. Two different lists with the same content are not equal because list creates a new data object each time it's called: (eq? (list 'a) (list 'a)) = #f The only exception to that definition is the empty list '() (or null): (eq? '() '()) returns true by definition. Comparing two empty strings with (eq? ) does not make sense on the other hand because the return value of eq? is unspecified when comparing strings. Unspecified means it might be true, it might be false but I cannot count on it. To check for the equality of strings one needs to use equal? which is defined to analyze the contents of the data structures and not the pointers. Same for lists (equal? (list 'a) (list 'a)) = true (equal? string string) = true Rackets 's reference and guide sometimes are a bit vague about these things. So it's better to check their current standard R6RS. When you open the documentation and search for eq? you should see several results: rnrs/base-6 is the one you want to have a look at. But as far as I could see Gambit does not support R6RS so you might want to check r5rs, too. -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
I guess it's a matter of definition. I must admit that i didn't reflect on equality that much. My (very limited) knowledge about that stuff comes mostly from the The Little Schemer which imho explains it really well with the 'eqan?' and 'eqlist?' procedure. The reason why i checked (eq? 'symbol1 'symbol2) in the first place in racket was because in gambit scheme (eq? string string) returned #f and in racket returns #t. I just wanted to check the differences between racket and gambit and was really surprised as (eq? 'symbol1 'symbol2) returned #f in the racket repl (which was likely because of escape characters) Michael Tiedtke michael.tied...@o2online.de writes: 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:
RE: [racket-users] Strange behaviour of the eq? operator in racket repl
I think Rackets's reference and guide are *very clear* about eq?, eqv? and equal?. They are even described well for structures and hashes and much more. Be aware, though, that in general equality can be interpreted in many ways. At the mathematical level equality is a difficult and in many cases even an unsolvable thing. Jos -Original Message- From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of Michael Tiedtke Sent: lunes, 18 de mayo de 2015 19:00 To: racket-users@googlegroups.com Subject: Re: [racket-users] Strange behaviour of the eq? operator in racket repl SNIP Rackets 's reference and guide sometimes are a bit vague about these things. So it's better to check their current standard R6RS. When you open the documentation and search for eq? you should see several results: rnrs/base-6 is the one you want to have a look at. But as far as I could see Gambit does not support R6RS so you might want to check r5rs, too. SNIP -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
In my early time learning Racket, I wish someone had given me the following advice: For now? Just use `equal?`. `equal?` will usually do the right thing, including for numbers, strings, symbols, immutable lists, and so on. A type-specific function like `=` or `string-=?` might be a bit faster. `eq?` might be a lot faster. But `equal?` will still be correct. `eq?` or `eqv?` might matter semantically if you're doing certain things -- but you're not likely to be doing them in your early days with Racket. So if you're getting side-tracked and confused, you can probably set it aside for now, and just use `equal?` That advice might make some of you cringe as simplistic, but it would have been a helpful simplification for me. And I'm talking about modern Racket, not Schemes generally. Of course there are also things like `egal?` that are fun to learn about, eventually. -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
Il giorno 18/mag/2015, alle ore 20.50, Jos Koot ha scritto: I think Rackets's reference and guide are *very clear* about eq?, eqv? and equal?. Yes, right. It was the Racket Reference to tell me exactly that eqv? is an eq? that works for numbers and characters, too. I really had to look this up and found an simple and concise description. But the entries for for-each and map do not state anything about the execution order of the list processing. The other entry whose description I found a bit confusing was cond - I always need to look that up no matter which Scheme I'm on because I always (want to) forget that it takes only the first branch whose condition is true and ignores the rest. Perhaps someday they will change this but R5RS states that behavior clearly enough. That's what I meant when I wrote the guide and the reference are sometimes a bit vague about these things and I'm sorry about being too vague about it. They are even described well for structures and hashes and much more. Be aware, though, that in general equality can be interpreted in many ways. At the mathematical level equality is a difficult and in many cases even an unsolvable thing. Maybe, I never thought about that in mathematical terms if not with the concept of identity. How could they do without it? Two objects (in memory) are identical when ... no, they preferred talking about sameness. Perhaps they were right; for each and every case you can define equality rather well. But equality as an abstract concept may lead to a search in nothing which can take forever and ever: like the moon that keeps circling around the earth without any reason one's mind can circle around nothing. That's mighty. But that's off topic. -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
2015-05-18 21:25 GMT+02:00 Michael Tiedtke michael.tied...@o2online.de: Il giorno 18/mag/2015, alle ore 20.50, Jos Koot ha scritto: I think Rackets's reference and guide are *very clear* about eq?, eqv? and equal?. Yes, right. It was the Racket Reference to tell me exactly that eqv? is an eq? that works for numbers and characters, too. I really had to look this up and found an simple and concise description. But the entries for for-each and map do not state anything about the execution order of the list processing. Here is what the documentation say: Racket docs: Applies proc to the elements of the lsts from the first elements to the last. R5RS: The dynamic order in which proc is applied to the elements of the lists is unspecified. I interpret the Racket docs to mean that the procedure are applied to the elements in the list in the order they appear in the list. In contrast R5RS (on purpose) state that the order is unspecified, which means that an implementor of R5RS Scheme is free to choose the order which fits his system best. Potentially the freedom to choose the order could enable some optimizations. -- Jens Axel Søgaard -- 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.
RE: [racket-users] Strange behaviour of the eq? operator in racket repl
A fact is that equal? does not distinguish between for example two mutable lists that happen to have the same content (whatever the same may mean) They may be equal? at one moment and not be equal? a little bit later. With eq? you don't have this problem, BUT that's a very distinct kind of equality. Jos -Original Message- From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of Greg Hendershott Sent: lunes, 18 de mayo de 2015 20:56 To: racket-users@googlegroups.com Subject: Re: [racket-users] Strange behaviour of the eq? operator in racket repl In my early time learning Racket, I wish someone had given me the following advice: For now? Just use `equal?`. `equal?` will usually do the right thing, including for numbers, strings, symbols, immutable lists, and so on. A type-specific function like `=` or `string-=?` might be a bit faster. `eq?` might be a lot faster. But `equal?` will still be correct. `eq?` or `eqv?` might matter semantically if you're doing certain things -- but you're not likely to be doing them in your early days with Racket. So if you're getting side-tracked and confused, you can probably set it aside for now, and just use `equal?` That advice might make some of you cringe as simplistic, but it would have been a helpful simplification for me. And I'm talking about modern Racket, not Schemes generally. Of course there are also things like `egal?` that are fun to learn about, eventually. -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
On May 18, 2015, at 1:19 AM, 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 In Racket, (eq? 2 2) is specified as true. It says here: http://docs.racket-lang.org/reference/numbers.html A fixnum is an exact integer whose two’s complement representation fit into 31 bits on a 32-bit platform or 63 bits on a 64-bit platform; furthermore, no allocation is required when computing with fixnums. See also the racket/fixnum module, below. Two fixnums that are = are also the same according to eq?. Otherwise, the result of eq?applied to two numbers is undefined, except that numbers produced by the default reader in read-syntax mode are interned and therefore eq? when they are eqv?. And about symbols, they should always be eq? if they are interned, which they always are unless they are produced by a function like gensym or string-uninterned-symbol. The symbol=? predicate uses eq? to compare the symbols. -- 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.
RE: [racket-users] Strange behaviour of the eq? operator in racket repl
No, what you describe is not off topic at all. It is at the core of the problem of defining what equality means. As you already have seen, there are several definitions (and cases in which a definition does not work) Kind regards, Jos -Original Message- From: Michael Tiedtke [mailto:michael.tied...@o2online.de] Sent: lunes, 18 de mayo de 2015 21:26 To: Jos Koot; racket-users@googlegroups.com Subject: Re: [racket-users] Strange behaviour of the eq? operator in racket repl snip Maybe, I never thought about that in mathematical terms if not with the concept of identity. How could they do without it? Two objects (in memory) are identical when ... no, they preferred talking about sameness. Perhaps they were right; for each and every case you can define equality rather well. But equality as an abstract concept may lead to a search in nothing which can take forever and ever: like the moon that keeps circling around the earth without any reason one's mind can circle around nothing. That's mighty. But that's off topic.= -- 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.
[racket-users] Specifying a contract for the end of a list
I've recently wanted a contract that lets me check the last element of a (potentially improper) list, ignoring the other elements. To do this in a general sense, I came up with this. (define (listof* init/c last/c) (flat-named-contract `(listof* ,(contract-name init/c) ,(contract-name last/c)) (flat-rec-contract listof* last/c (cons/c init/c listof* That definition can then be used like this. (define/contract num-tail (listof* any/c number?) '(a b c . 4)) The use-case I've found most helpful, though, is combining it with listof contracts to check sequences within lists or at the end of the lists. (define/contract num-tail-proper (listof* any/c (list/c number?)) '(a b c 4)) This works, but it only works with flat contracts. Would it be possible to generalize this to work with all contracts? Also, would this sort of combinator make sense in the standard library? The name I've used probably wouldn't be usable (since it could be confused with list*of), but I think the functionality is helpful. -- 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.
[racket-users] munger package
I’m interested in your munger package for data analysis, but … it looks like there are no docs or examples? Any plans to work on this? Thanks! John Clements -- 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.
Re: [racket-users] Strange behaviour of the eq? operator in racket repl
On Mon, May 18, 2015 at 08:50:50PM +0200, Jos Koot wrote: At the mathematical level equality is a difficult and in many cases even an unsolvable thing. Indeed. It is suspected by some that difficulties with equality lie at the root of problems with set theory. There are two concepts of equality: (a) equality from below, which defined two sets to be equal iff they have the same elements, and (b) equality from above, which defines two sets as being equal iff they have the same properties. Set theory conflates these two concepts. Scheme has various eqialities, but they are all equalities from below. -- hendrik -- 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.
[racket-users] constant propagation
Very nice constant propagation in Racket. For example the Racket compiler pre-evaluates: (let ((b 2)) (sqrt (+ 2 b))) to '2. That is what zo-parse and decompile tell me. May be I missed it, but looking for info on constant propagation I found no info about this in the docs. If there is info, please tell me where. Thanks to the plt Racket team! Jos koot -- 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.
Re: [racket-users] racket testing on openwrt
On Sun, May 17, 2015 at 5:00 PM, Neil Van Dyke n...@neilvandyke.org wrote: Can someone recommend an easy way to test Racket 9.2 pre-release on OpenWrt (embedded GNU/Linux, running on a normal home WiFi router)? For example, is there a big tree of files that I could just copy onto a USB flash drive, and run with one command, and it would dump its log to a file or stdio? (I see http://drdr.racket-lang.org/help;, but I don't know whether that's what I should be using, nor what an easy way to use it would be. I'd prefer to run the tests disconnected from the Internet, if that matters.) DrDr is just a service used by PLT to make sure there are no software regressions. It isn't really designed to be usable by other people because the configuration is so specific. Neil V. -- 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. -- Jay McCarthy http://jeapostrophe.github.io Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great. - DC 64:33 -- 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.
Re: [racket-users] constant propagation
Constant propagation is not a property of a language but its implementation. Few implementations document which transformations they currently implement. -- Matthias On May 18, 2015, at 7:11 AM, Jos Koot wrote: Very nice constant propagation in Racket. For example the Racket compiler pre-evaluates: (let ((b 2)) (sqrt (+ 2 b))) to '2. That is what zo-parse and decompile tell me. May be I missed it, but looking for info on constant propagation I found no info about this in the docs. If there is info, please tell me where. Thanks to the plt Racket team! Jos koot -- 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.