From erich at snafu.de Tue Sep 1 08:38:28 2009 From: erich at snafu.de (Erich Rast) Date: Tue Sep 1 08:38:35 2009 Subject: [plt-scheme] Setting focus-ring of text-field controls programmatically Message-ID: <1251808708.21265.19.camel@darkstar> I'm switching between 4 text-field% instances in a tab-panel% by showing the activated one and hiding the others using change-children. Switching works fine, but I can't figure out how to make the text-field or its editor or its editor's canvas draw a blue focus-ring like it is done automatically when you allow switching between simple controls using the tab key. Is it possible at all to make text-fields draw a blue focus-ring on OS X when they are activated programmatically and get the keyboard focus? What settings control the drawing of focus-rings on OS X? I've already tried lots of things like making the field's editor the caret-owner, setting allow-tab-exit to #t in editor-canvas, using text% instances instead of text-field%, changing border settings of text %...those #"$?%?$ focus-rings just don't show up. Any help would be greatly appreciated! Best regards, Erich From toddobryan at gmail.com Tue Sep 1 09:18:01 2009 From: toddobryan at gmail.com (Todd O'Bryan) Date: Tue Sep 1 09:18:19 2009 Subject: [plt-scheme] hosed doc search Message-ID: <904774730909010618t45763075we67d8e9f462e6d7b@mail.gmail.com> I seem to have broken my documentation search. When I enter a search term and hit enter, something happens, but instead of the search results popping up, the same page pops back up. I've re-run setup-plt to no avail. What should I try next or where should I look to identify the problem? Todd From mflatt at cs.utah.edu Tue Sep 1 10:17:53 2009 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Tue Sep 1 10:18:19 2009 Subject: [plt-scheme] hosed doc search In-Reply-To: <904774730909010618t45763075we67d8e9f462e6d7b@mail.gmail.com> References: <904774730909010618t45763075we67d8e9f462e6d7b@mail.gmail.com> Message-ID: <20090901141757.F11236500A8@mail-svr1.cs.utah.edu> At Tue, 1 Sep 2009 09:18:01 -0400, "Todd O'Bryan" wrote: > I seem to have broken my documentation search. When I enter a search > term and hit enter, something happens, but instead of the search > results popping up, the same page pops back up. > > I've re-run setup-plt to no avail. What should I try next or where > should I look to identify the problem? You might need to delete a cookie with "PLT_Root" in its name. I had to do that once after I installed a Planet package, opened docs with `plt-help', and then removed the version-specific subdirectory in my ".plt-scheme" directory. Searching got confused because the index file had disappeared, and the "PLT_Root" cookie points to that index file. From mflatt at cs.utah.edu Tue Sep 1 10:21:49 2009 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Tue Sep 1 10:22:19 2009 Subject: [plt-scheme] Setting focus-ring of text-field controls programmatically In-Reply-To: <1251808708.21265.19.camel@darkstar> References: <1251808708.21265.19.camel@darkstar> Message-ID: <20090901142152.8E66A6500E7@mail-svr1.cs.utah.edu> It looks like the focus ring got lost in the v4.2 rewrite of the editor classes. I'll fix it... At Tue, 01 Sep 2009 13:38:28 +0100, Erich Rast wrote: > I'm switching between 4 text-field% instances in a tab-panel% by showing > the activated one and hiding the others using change-children. Switching > works fine, but I can't figure out how to make the text-field or its > editor or its editor's canvas draw a blue focus-ring like it is done > automatically when you allow switching between simple controls using the > tab key. > > Is it possible at all to make text-fields draw a blue focus-ring on OS X > when they are activated programmatically and get the keyboard focus? > What settings control the drawing of focus-rings on OS X? > > I've already tried lots of things like making the field's editor the > caret-owner, setting allow-tab-exit to #t in editor-canvas, using text% > instances instead of text-field%, changing border settings of text > %...those #"$?%?$ focus-rings just don't show up. > > Any help would be greatly appreciated! > > Best regards, > > Erich > > > > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From toddobryan at gmail.com Tue Sep 1 10:54:59 2009 From: toddobryan at gmail.com (Todd O'Bryan) Date: Tue Sep 1 10:55:18 2009 Subject: [plt-scheme] hosed doc search In-Reply-To: <20090901141757.F11236500A8@mail-svr1.cs.utah.edu> References: <904774730909010618t45763075we67d8e9f462e6d7b@mail.gmail.com> <20090901141757.F11236500A8@mail-svr1.cs.utah.edu> Message-ID: <904774730909010754j54590827u292cad6e8cef4435@mail.gmail.com> That did it. Thanks! On Tue, Sep 1, 2009 at 10:17 AM, Matthew Flatt wrote: > At Tue, 1 Sep 2009 09:18:01 -0400, "Todd O'Bryan" wrote: >> I seem to have broken my documentation search. When I enter a search >> term and hit enter, something happens, but instead of the search >> results popping up, the same page pops back up. >> >> I've re-run setup-plt to no avail. What should I try next or where >> should I look to identify the problem? > > You might need to delete a cookie with "PLT_Root" in its name. > > I had to do that once after I installed a Planet package, opened docs > with `plt-help', and then removed the version-specific subdirectory in > my ".plt-scheme" directory. Searching got confused because the index > file had disappeared, and the "PLT_Root" cookie points to that index > file. > > From andrew-scheme at areilly.bpc-users.org Tue Sep 1 21:17:53 2009 From: andrew-scheme at areilly.bpc-users.org (Andrew Reilly) Date: Tue Sep 1 21:18:18 2009 Subject: [plt-scheme] Odd slider% behaviour? Message-ID: <20090902011753.GA11135@duncan.reilly.home> Hi again, Please consider this simple GUI program that seems to be a minimal thing that demonstrates a problem that I'm having with the GUI that I'm working on: #lang scheme/gui (let ((f (new frame% (label "SLIDER TEST")))) (new slider% (parent f) (label "foo") (min-value 0) (max-value 400) (init-value 200) (style '(horizontal horizontal-label plain)) (min-height 50) (min-width 400) (callback (lambda (s e) (printf "~a ~a ~a~%" (send s get-label) (send s get-value) (send e get-event-type)) (flush-output)))) (send f show #t) (yield 'wait)) Without the callback, the slider pops up and one can wiggle the control tab (thumb?) back and forth exactly as one might expect. Motion is continuous and responds instantly when the mouse moves. This is what I want to happen! With the callback as shown (or the functionally similar thing in my main program), the tab does not track mouse movement. Instead, the tab will lurch from where it was to the location of the mouse when the button is released, in one step. Also, the printouts show that the callback is called only twice for any mouse-down/mouse-up pair. If this down/up click is a "click" on a location that isn't the tab, then the two events see a slider in the "before" position and then the "after" position. If the down/up click is a "hold-and-slide" on the thumb, then the slider value of both events reflects the "after" position. What I *really* want is a stream of events that correspond to the mouse movement in real-time, with the slider's thumb moving continuously while held. Just like it does without the callback. Is this possible? I suspect that what I'm doing wrong is somehow mixing up the GUI and standard-output event spaces, and running into interlocks and/or timeouts somehow: there seems to be a significant lag between the GUI activity and the log on the IDE console. Should I be putting the GUI into an indpendent thread, somehow? If I have a callback that just does (void) instead of (printf ...), then the thumb continues to move smoothly. I have yet to figure out an intermediate callback structure that allows me to *use* the real-time thumb movement... (I'm trying to control a device at the other end of a TCP/IP socket.) I understand that the MrEd (#scheme/gui) functionality is built on top of the WxWidgets library. I've had a look at the slider documentation in wxWidgets, and there seems to be a whole family of "event types" that a slider can emit. Do these show up somehow in the event object? The control-event% documentation only admits to get-event-type -> 'slider (which is obvious in this context), and get-time-stamp -> integer?, which I don't really care about, I think. Thanks in advance for any advice. Cheers, -- Andrew From andrew-scheme at areilly.bpc-users.org Tue Sep 1 21:37:33 2009 From: andrew-scheme at areilly.bpc-users.org (Andrew Reilly) Date: Tue Sep 1 21:37:55 2009 Subject: [plt-scheme] Odd slider% behaviour? In-Reply-To: <20090902011753.GA11135@duncan.reilly.home> References: <20090902011753.GA11135@duncan.reilly.home> Message-ID: <20090902013733.GA13420@duncan.reilly.home> Sorry for the followup-to-self. Just thought that I'd show another experiment that I've tried, that also didn't "work". This one uses an async-channel and a thread to try to decouple the slider and the "use the position" process, but the behaviour is the same "stuck slider" as before: #lang scheme/gui (require scheme/async-channel) (let ((c (make-async-channel))) (let ((t (thread (lambda () (let loop () (printf "~a~%" (async-channel-get c)) (flush-output) (loop))))) (f (new frame% (label "SLIDER TEST")))) (new slider% (parent f) (label "foo") (min-value 0) (max-value 400) (init-value 200) (style '(horizontal horizontal-label plain)) (min-height 50) (min-width 400) (callback (lambda (s e) (async-channel-put c (send s get-value))))) (send f show #t) (yield 'wait) (kill-thread t))) Cheers, -- Andrew From andrew-scheme at areilly.bpc-users.org Tue Sep 1 21:49:41 2009 From: andrew-scheme at areilly.bpc-users.org (Andrew Reilly) Date: Tue Sep 1 21:50:04 2009 Subject: [plt-scheme] Odd slider% behaviour? In-Reply-To: <20090902013733.GA13420@duncan.reilly.home> References: <20090902011753.GA11135@duncan.reilly.home> <20090902013733.GA13420@duncan.reilly.home> Message-ID: <20090902014941.GA13821@duncan.reilly.home> On Wed, Sep 02, 2009 at 11:37:33AM +1000, Andrew Reilly wrote: > Sorry for the followup-to-self, again. OK, a seemingly tiny variation on the previous version "works". Well, the actual output of the position sequence doesn't show up on the IDE console until the mouse lets go of the slider, but this is definite improvement: #lang scheme/gui (let ((t (thread (lambda () (let loop () (printf "~a~%" (thread-receive)) (flush-output) (loop))))) (f (new frame% (label "SLIDER TEST")))) (new slider% (parent f) (label "foo") (min-value 0) (max-value 400) (init-value 200) (style '(horizontal horizontal-label plain)) (min-height 50) (min-width 400) (callback (lambda (s e) (thread-send t (send s get-value))))) (send f show #t) (yield 'wait) (kill-thread t)) So, I guess that my question boils down to: what is different, here? The documentation seems to suggest that the thread message box that I'm using now is just one of the async-channels that I had in the previous attempt. Hmm. When run from the console with mred, the output still doesn't appear until the mouse button is released. That might not suit my purposes yet, but we'll see... Cheers, -- Andrew From mflatt at cs.utah.edu Wed Sep 2 01:23:52 2009 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Wed Sep 2 01:24:26 2009 Subject: [plt-scheme] Odd slider% behaviour? In-Reply-To: <20090902011753.GA11135@duncan.reilly.home> References: <20090902011753.GA11135@duncan.reilly.home> Message-ID: <20090902052359.470AD6500E1@mail-svr1.cs.utah.edu> There are indeed eventspace/thread limitations issues with sliders, at least under Mac OS X and Windows. Worse, interactions with the DrScheme eventspace can affect the results you get. If I run your original program at the command line, then it works better than the other two versions. The problem with the first version in DrScheme is that a printout blocks until it communicates with DrScheme, and a slider callback is limited to stay in the same eventspace (and thread). Running from the command line, though, there's no cross-eventspace communication for a printout, and so it appears immediately. You're probably aiming for something other than printouts, eventually, so the slider may work ok in the end. More generally, this is the sort of problem that we expect to fix with a new implementation of MrEd (which is currently stalled, but I hope to have more hacking time this fall than I had over the summer). Matthew At Wed, 2 Sep 2009 11:17:53 +1000, Andrew Reilly wrote: > Hi again, > > Please consider this simple GUI program that seems to be a > minimal thing that demonstrates a problem that I'm having with > the GUI that I'm working on: > > #lang scheme/gui > > (let ((f (new frame% (label "SLIDER TEST")))) > (new slider% > (parent f) > (label "foo") > (min-value 0) > (max-value 400) > (init-value 200) > (style '(horizontal horizontal-label plain)) > (min-height 50) > (min-width 400) > (callback > (lambda (s e) > (printf "~a ~a ~a~%" (send s get-label) (send s get-value) (send e > get-event-type)) > (flush-output)))) > (send f show #t) > (yield 'wait)) > > Without the callback, the slider pops up and one can wiggle > the control tab (thumb?) back and forth exactly as one might > expect. Motion is continuous and responds instantly when the > mouse moves. This is what I want to happen! > > With the callback as shown (or the functionally similar thing in > my main program), the tab does not track mouse movement. > Instead, the tab will lurch from where it was to the location of > the mouse when the button is released, in one step. Also, the > printouts show that the callback is called only twice for any > mouse-down/mouse-up pair. If this down/up click is a "click" on > a location that isn't the tab, then the two events see a slider > in the "before" position and then the "after" position. If the > down/up click is a "hold-and-slide" on the thumb, then the > slider value of both events reflects the "after" position. > > What I *really* want is a stream of events that correspond to > the mouse movement in real-time, with the slider's thumb moving > continuously while held. Just like it does without the > callback. Is this possible? > > I suspect that what I'm doing wrong is somehow mixing up the GUI > and standard-output event spaces, and running into interlocks > and/or timeouts somehow: there seems to be a significant lag > between the GUI activity and the log on the IDE console. Should > I be putting the GUI into an indpendent thread, somehow? If I > have a callback that just does (void) instead of (printf ...), > then the thumb continues to move smoothly. I have yet to figure > out an intermediate callback structure that allows me to *use* > the real-time thumb movement... (I'm trying to control a device > at the other end of a TCP/IP socket.) > > I understand that the MrEd (#scheme/gui) functionality is built > on top of the WxWidgets library. I've had a look at the slider > documentation in wxWidgets, and there seems to be a whole family > of "event types" that a slider can emit. Do these show up > somehow in the event object? The control-event% documentation > only admits to get-event-type -> 'slider (which is obvious in > this context), and get-time-stamp -> integer?, which I don't > really care about, I think. > > Thanks in advance for any advice. > > Cheers, > > -- > Andrew > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From matthias at ccs.neu.edu Wed Sep 2 03:30:14 2009 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed Sep 2 03:30:41 2009 Subject: [plt-scheme] Lexical Scoping, References and Side Effects In-Reply-To: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> Message-ID: <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> On Aug 30, 2009, at 7:42 PM, tbourdon wrote: > Hello - > > I'm currently teaching myself Scheme by working through "Teach > Yourself Scheme in Fixnum Days" and "The Little Schemer". As I was > working through the sources I decided to break off and implement some > stack data structures. So far I've implemented the stack functions > three different ways and I've noticed that I really can't (or haven't > found a way) to create a reference to a stack and pass it around to be > operated on. > > For example; I can't come up with an implementation for a stack-push > function where the following works: > > (define stack ()) > (stack-push stack 1) > (stack-top stack) => 1 You omitted the most important part of your quasi-spec? What should stack-push return? From gregg.asher at mnsu.edu Wed Sep 2 16:06:23 2009 From: gregg.asher at mnsu.edu (Asher, Gregg) Date: Wed Sep 2 16:11:48 2009 Subject: [plt-scheme] Test the Program Message-ID: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> I apologize if this question has been asked before. I checked the archives and couldn't find my problem listed. When I define a program in the definitions window and then enter the program name in the interactive window substituting a value for the parameter and then "Run" (my version of Dr. Scheme doesn't have an "Execute" button) the program I don't the results of the program but a message "This program should be tested. >" For example when I run this program (area-of-disk 3), I get the message "This program should be tested. >" When I run the same program (area-of-disk 3) in the definitions window I get the correct answer "28.26" in the interactive window. Any help would be appreciated. Dr. Scheme is running off of a flash drive if that makes any difference. I have 60 programming students and want them to run Dr. Scheme from the flash drive so that they can run the program from any computer. Gregg W. Asher, Ph.D. Associate professor Information Systems & Technology Minnesota State University, Mankato Mankato, MN. 56001 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090902/f3838a17/attachment.htm From rafkind at cs.utah.edu Wed Sep 2 16:18:07 2009 From: rafkind at cs.utah.edu (Jon Rafkind) Date: Wed Sep 2 16:20:10 2009 Subject: [plt-scheme] Test the Program In-Reply-To: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> References: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> Message-ID: <4A9ED2FF.4050704@cs.utah.edu> Asher, Gregg wrote: > I apologize if this question has been asked before. I checked the archives and couldn't find my problem listed. > > When I define a program in the definitions window and then enter the program name in the interactive window substituting a value for the parameter and then "Run" (my version of Dr. Scheme doesn't have an "Execute" button) the program I don't the results of the program but a message "This program should be tested. > >> " >> > > For example when I run this program (area-of-disk 3), I get the message "This program should be tested. > >> " >> > > When I run the same program (area-of-disk 3) in the definitions window > > I get the correct answer "28.26" in the interactive window. > > Any help would be appreciated. > > Dr. Scheme is running off of a flash drive if that makes any difference. I have 60 programming students and want them to run Dr. Scheme from the flash drive so that they can run the program from any computer. > > I think you just aren't pressing the run button after entering new definitions. Before you can use a new definition in the interactions pane you have to press run. If thats not the problem maybe you can post some more code? From rafkind at cs.utah.edu Wed Sep 2 16:27:11 2009 From: rafkind at cs.utah.edu (Jon Rafkind) Date: Wed Sep 2 16:29:14 2009 Subject: [plt-scheme] Test the Program In-Reply-To: <4A9ED2FF.4050704@cs.utah.edu> References: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> <4A9ED2FF.4050704@cs.utah.edu> Message-ID: <4A9ED51F.6080405@cs.utah.edu> Jon Rafkind wrote: > Asher, Gregg wrote: >> I apologize if this question has been asked before. I checked the >> archives and couldn't find my problem listed. >> >> When I define a program in the definitions window and then enter the >> program name in the interactive window substituting a value for the >> parameter and then "Run" (my version of Dr. Scheme doesn't have an >> "Execute" button) the program I don't the results of the program but >> a message "This program should be tested. >> >>> " >>> >> >> For example when I run this program (area-of-disk 3), I get the >> message "This program should be tested. >> >>> " >>> >> >> When I run the same program (area-of-disk 3) in the definitions window >> >> I get the correct answer "28.26" in the interactive window. >> >> Any help would be appreciated. >> >> Dr. Scheme is running off of a flash drive if that makes any >> difference. I have 60 programming students and want them to run Dr. >> Scheme from the flash drive so that they can run the program from any >> computer. >> >> > I think you just aren't pressing the run button after entering new > definitions. Before you can use a new definition in the interactions > pane you have to press run. > > If thats not the problem maybe you can post some more code? Ignore that, I you probably just need a 'check-expect' expression to test your function in the definitions window. (define (area-of-circle x) (* x x)) (check-expect (area-of-circle 3) 9) Produces The test passed! From tbourdon at gmail.com Wed Sep 2 10:42:18 2009 From: tbourdon at gmail.com (tbourdon) Date: Wed Sep 2 16:59:29 2009 Subject: [plt-scheme] Re: Lexical Scoping, References and Side Effects In-Reply-To: <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> Message-ID: <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> As I said, "For my second implementation I had the stack-push function just return the updated stack but as you can see this leads to successive set! calls" and that's the whole point. I don't want stack- push to return anything. I want it to change the state of the stack that's passed in so the caller can reference that stack's changed state later. In other words, is there a way for the following to work? (define stack ()) ; stack is defined as empty list. (stack-push stack 1) ; stack-push pushes 1 onto stack. (stack-top stack) => 1 ; stack-top returns 1. On Sep 2, 12:30?am, Matthias Felleisen wrote: > On Aug 30, 2009, at 7:42 PM, tbourdon wrote: > > > > > Hello - > > > I'm currently teaching myself ?Scheme by working through "Teach > > Yourself Scheme in Fixnum Days" and "The Little Schemer". As I was > > working through the sources I decided to break off and implement some > > stack data structures. So far I've implemented the stack functions > > three different ways and I've noticed that I really can't (or haven't > > found a way) to create a reference to a stack and pass it around to be > > operated on. > > > For example; I can't come up with an implementation for a stack-push > > function where the following works: > > > (define stack ()) > > (stack-push stack 1) > > (stack-top stack) => 1 > > You omitted the most important part of your quasi-spec? What should ? > stack-push return? > > _________________________________________________ > ? For list-related administrative tasks: > ?http://list.cs.brown.edu/mailman/listinfo/plt-scheme From lspector at hampshire.edu Wed Sep 2 17:09:10 2009 From: lspector at hampshire.edu (Lee Spector) Date: Wed Sep 2 17:14:31 2009 Subject: [plt-scheme] Re: Lexical Scoping, References and Side Effects In-Reply-To: <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> Message-ID: <56FD865E-814A-44E4-9958-31802CB9BF7A@hampshire.edu> Does this do what you want? ----- #lang scheme (define-syntax (stack-push stx) (syntax-case stx () ((_ name item) #`(set! name (cons item name))))) (define stack-top (lambda (s) (car s))) ----- Then in the interactions pane I can do: > (define stack '()) > (stack-push stack 1) > (stack-top stack) 1 Note that I do have to quote () in the first line, but I don't think that that was the focus of your question. Incidentally I've just been doing a lot of stack-based system development in DrScheme -- I work on a kind of genetic programming based on stack machines -- and I do a lot of destructive stack modification. I use different ideas than I presented here, but it's a messier context... -Lee On Sep 2, 2009, at 10:42 AM, tbourdon wrote: > As I said, "For my second implementation I had the stack-push function > just return the updated stack but as you can see this leads to > successive set! calls" and that's the whole point. I don't want stack- > push to return anything. I want it to change the state of the stack > that's passed in so the caller can reference that stack's changed > state later. In other words, is there a way for the following to work? > > (define stack ()) ; stack is defined as empty list. > (stack-push stack 1) ; stack-push pushes 1 onto stack. > (stack-top stack) => 1 ; stack-top returns 1. > > On Sep 2, 12:30 am, Matthias Felleisen wrote: >> On Aug 30, 2009, at 7:42 PM, tbourdon wrote: >> >> >> >>> Hello - >> >>> I'm currently teaching myself Scheme by working through "Teach >>> Yourself Scheme in Fixnum Days" and "The Little Schemer". As I was >>> working through the sources I decided to break off and implement >>> some >>> stack data structures. So far I've implemented the stack functions >>> three different ways and I've noticed that I really can't (or >>> haven't >>> found a way) to create a reference to a stack and pass it around >>> to be >>> operated on. >> >>> For example; I can't come up with an implementation for a stack-push >>> function where the following works: >> >>> (define stack ()) >>> (stack-push stack 1) >>> (stack-top stack) => 1 >> >> You omitted the most important part of your quasi-spec? What should >> stack-push return? >> >> _________________________________________________ >> For list-related administrative tasks: >> http://list.cs.brown.edu/mailman/listinfo/plt-scheme > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ From farr at MIT.EDU Wed Sep 2 17:31:18 2009 From: farr at MIT.EDU (Will M Farr) Date: Wed Sep 2 17:32:00 2009 Subject: [plt-scheme] Re: Lexical Scoping, References and Side Effects In-Reply-To: <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> Message-ID: <64FA9158-54B7-42E2-9F7F-6EBFE2E9BA7D@MIT.EDU> There's no way to make this work if you use a bare list as your stack data structure. However, if you make your own stack data structure which stores a list of the elements on the stack, then you can store a new list in the structure for every stack-push!/pop!. (By the way, it's customary in Scheme to name procedures that mutate their arguments with trailing "!".) Something like the following sounds like what you want: #lang scheme ;; A stack stores a list of the elements it contains ;; #:mutable needed to change the stored list on pop/push ;; #:transparent for easy printing and inspection. (define-struct stack (elements) #:mutable #:transparent) ;; Push obj onto the top of the stack. Return value is void (define (stack-push! stack obj) (set-stack-elements! stack (cons obj (stack-elements stack)))) ;; Pop the top object off the stack and return it (define (stack-pop! stack) (when (null? (stack-elements stack)) (error 'stack-pop! "empty stack: ~a" stack)) (let* ((elements (stack-elements stack)) (top (car elements))) (set-stack-elements! stack (cdr elements)) top)) ;; Look at the top element without changing it (define (stack-peek stack) (when (null? (stack-elements stack)) (error 'stack-peek "empty stack: ~a" stack)) (car (stack-elements stack))) #| ;; Tests. (define the-stack (make-stack '())) (stack-push! the-stack 1) (stack-push! the-stack 2) (stack-push! the-stack 3) (equal? (stack-peek the-stack) 3) ;; #t (equal? (stack-pop! the-stack) 3) ;; #t (equal? (stack-peek the-stack) 2) ;; #t (stack-push! the-stack 'a) (equal? (stack-pop! the-stack) 'a) ;; #t (equal? (stack-pop! the-stack) 2) ;; #t (equal? (stack-pop! the-stack) 1) ;; #t (stack-pop! the-stack) ;; Error! |# Enjoy! Will On Sep 2, 2009, at 10:42 AM, tbourdon wrote: > As I said, "For my second implementation I had the stack-push function > just return the updated stack but as you can see this leads to > successive set! calls" and that's the whole point. I don't want stack- > push to return anything. I want it to change the state of the stack > that's passed in so the caller can reference that stack's changed > state later. In other words, is there a way for the following to work? > > (define stack ()) ; stack is defined as empty list. > (stack-push stack 1) ; stack-push pushes 1 onto stack. > (stack-top stack) => 1 ; stack-top returns 1. > > On Sep 2, 12:30 am, Matthias Felleisen wrote: >> On Aug 30, 2009, at 7:42 PM, tbourdon wrote: >> >> >> >>> Hello - >> >>> I'm currently teaching myself Scheme by working through "Teach >>> Yourself Scheme in Fixnum Days" and "The Little Schemer". As I was >>> working through the sources I decided to break off and implement >>> some >>> stack data structures. So far I've implemented the stack functions >>> three different ways and I've noticed that I really can't (or >>> haven't >>> found a way) to create a reference to a stack and pass it around >>> to be >>> operated on. >> >>> For example; I can't come up with an implementation for a stack-push >>> function where the following works: >> >>> (define stack ()) >>> (stack-push stack 1) >>> (stack-top stack) => 1 >> >> You omitted the most important part of your quasi-spec? What should >> stack-push return? >> >> _________________________________________________ >> For list-related administrative tasks: >> http://list.cs.brown.edu/mailman/listinfo/plt-scheme > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 203 bytes Desc: This is a digitally signed message part Url : http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090902/250cce47/PGP-0001.pgp From lspector at hampshire.edu Wed Sep 2 17:34:28 2009 From: lspector at hampshire.edu (Lee Spector) Date: Wed Sep 2 17:39:50 2009 Subject: [plt-scheme] conditional module inclusion and compilation Message-ID: I've developed some code in DrScheme under Mac OS X that I also want to run sometimes under Linux -- it's computationally intensive stuff and I'll want to do development runs on my mac but then do lots of bigger runs on our Linux cluster. I have some graphics in the Mac OS X version that I don't know how to produce in my command-line/text-based Linux environment, but I don't need the graphics there anyway. The graphics are just plots of progress which are useful when I'm developing and watching a run, but the cluster runs produce text files of data which are good enough. So to get the code working on the cluster I just removed "(require plot)" and all of the code that called anything from the plot module. That worked but I don't want to have to do this kind of surgery on the code every time I move it to the cluster, which I'll be doing frequently. Ideally I'd like to be able to write my code in such a way that it knows where it's running and it includes the plot module and calls the plot code only if it's running somewhere appropriate. I do this in Common Lisp by using the #+: and #-: conditional compilation syntax and/or by looking for things in the variable *features*, which includes symbols that describe the environment. Is there anything similar in PLT? I wouldn't mind having to manually change a flag to indicate the environment, e.g. to change the value in something like: (define include-plots-in-reports #t) But this doesn't actually help for two reasons: - PLT won't let me wrap a call to "require" in a conditional expression -- it complains that it's not at the top level. - If I comment out the "require" PLT still won't compile a file containing calls to functions in the missing module, even if those calls are never executed. So whether my code knows where it's running or whether I have to tell it manually, I don't have a way of moving it to the Linux environment without manually editing out the "require" and all of the code that refers to the plot module. Is there a good way to deal with this kind of thing in PLT that I'm missing? Thanks, -Lee -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ From brian at mastenbrook.net Wed Sep 2 17:38:42 2009 From: brian at mastenbrook.net (Brian Mastenbrook) Date: Wed Sep 2 17:45:09 2009 Subject: [plt-scheme] Hang in macro stepper when macro expansion does not terminate Message-ID: Hello, When trying to use the macro stepper on a program whose macro expansion does not terminate, the macro stepper will hang, and clicking Stop in the editor window toolbar does not help. Sending a SIGINT to the DrScheme process resolves the issue. I'm not expecting it to not hang if a form on the right-hand side of a `define-syntax' or `let-syntax' recurses infinitely, but when the expansion process does not terminate, it would still be nice to be able to use the macro stepper to determine what's going on. Just for clarity, this is an example of the type of program I'm talking about: #lang r5rs (define-syntax foo (syntax-rules () ((_) (foo)))) (foo) -- Brian Mastenbrook brian@mastenbrook.net http://brian.mastenbrook.net/ From matthias at ccs.neu.edu Wed Sep 2 17:52:53 2009 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed Sep 2 17:53:37 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: References: Message-ID: Would > Welcome to MzScheme v4.2.1.7 [3m], Copyright (c) 2004-2009 PLT > Scheme Inc. > > (system-type) > macosx help you get started? If you can tolerate a call to void for plots on the cluster, I'd use an abstraction over the graphics. If you want to see the tracker, pass in draw-progress-report (or whatever you call the graphics function); otherwise pass in void instead. If the extra call costs too much, I'd write a macro that unfolds in one way on a mac and in a different way on a linux box. -- Matthias On Sep 2, 2009, at 5:34 PM, Lee Spector wrote: > > I've developed some code in DrScheme under Mac OS X that I also want > to run sometimes under Linux -- it's computationally intensive stuff > and I'll want to do development runs on my mac but then do lots of > bigger runs on our Linux cluster. > > I have some graphics in the Mac OS X version that I don't know how > to produce in my command-line/text-based Linux environment, but I > don't need the graphics there anyway. The graphics are just plots of > progress which are useful when I'm developing and watching a run, > but the cluster runs produce text files of data which are good > enough. So to get the code working on the cluster I just removed > "(require plot)" and all of the code that called anything from the > plot module. > > That worked but I don't want to have to do this kind of surgery on > the code every time I move it to the cluster, which I'll be doing > frequently. Ideally I'd like to be able to write my code in such a > way that it knows where it's running and it includes the plot module > and calls the plot code only if it's running somewhere appropriate. > I do this in Common Lisp by using the #+: and #-: conditional > compilation syntax and/or by looking for things in the variable > *features*, which includes symbols that describe the environment. Is > there anything similar in PLT? > > I wouldn't mind having to manually change a flag to indicate the > environment, e.g. to change the value in something like: > > (define include-plots-in-reports #t) > > But this doesn't actually help for two reasons: > > - PLT won't let me wrap a call to "require" in a conditional > expression -- it complains that it's not at the top level. > - If I comment out the "require" PLT still won't compile a file > containing calls to functions in the missing module, even if those > calls are never executed. > > So whether my code knows where it's running or whether I have to > tell it manually, I don't have a way of moving it to the Linux > environment without manually editing out the "require" and all of > the code that refers to the plot module. > > Is there a good way to deal with this kind of thing in PLT that I'm > missing? > > Thanks, > > -Lee > > -- > Lee Spector, Professor of Computer Science > School of Cognitive Science, Hampshire College > 893 West Street, Amherst, MA 01002-3359 > lspector@hampshire.edu, http://hampshire.edu/lspector/ > Phone: 413-559-5352, Fax: 413-559-5438 > > Check out Genetic Programming and Evolvable Machines: > http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ > > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From matthias at ccs.neu.edu Wed Sep 2 17:53:48 2009 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed Sep 2 17:54:19 2009 Subject: [plt-scheme] Hang in macro stepper when macro expansion does not terminate In-Reply-To: References: Message-ID: <2E993A05-6971-4B0F-9F27-41380E0639C1@ccs.neu.edu> Sadly Ryan thinks that the macro stepper should execute the code through which you step. I am hoping that everyone on this list can help me convince him that this shouldn't be the case ... Use STOP to kill the execution as normal. On Sep 2, 2009, at 5:38 PM, Brian Mastenbrook wrote: > Hello, > > When trying to use the macro stepper on a program whose macro > expansion does not terminate, the macro stepper will hang, and > clicking Stop in the editor window toolbar does not help. Sending a > SIGINT to the DrScheme process resolves the issue. I'm not expecting > it to not hang if a form on the right-hand side of a `define-syntax' > or `let-syntax' recurses infinitely, but when the expansion process > does not terminate, it would still be nice to be able to use the > macro stepper to determine what's going on. > > Just for clarity, this is an example of the type of program I'm > talking about: > > #lang r5rs > > (define-syntax foo > (syntax-rules () > ((_) (foo)))) > > (foo) > -- > Brian Mastenbrook > brian@mastenbrook.net > http://brian.mastenbrook.net/ > > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From matthias at ccs.neu.edu Wed Sep 2 17:57:29 2009 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed Sep 2 17:58:00 2009 Subject: [plt-scheme] Test the Program In-Reply-To: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> References: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> Message-ID: On Sep 2, 2009, at 4:06 PM, Asher, Gregg wrote: > I apologize if this question has been asked before. I checked the > archives and couldn?t find my problem listed. > > When I define a program in the definitions window and then enter the > program name in the interactive window substituting a value for the > parameter and then ?Run? (my version of Dr. Scheme doesn?t have an > ?Execute? button (It's sad enough that we execute people, so we thought we shouldn't execute programs, too.) > ) the program I don?t the results of the program but a message ?This > program should be tested. > >? This is the case for teaching languages because we want to remind the students that w/o testing a program isn't complete. Jon replied with the concrete answer. Students should write 'unit tests' such as (check-expect (area-of-disk 3) 123456789) (check-expect (area-of-disk 4) 0) and inspect the replies. They should also note that insufficient testing colors their program in weird ways. -- Matthias -------------- next part -------------- An HTML attachment was scrubbed... URL: http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090902/5f085062/attachment.htm From rmgolbec at cs.ubc.ca Wed Sep 2 17:52:48 2009 From: rmgolbec at cs.ubc.ca (Ryan Golbeck) Date: Wed Sep 2 17:58:21 2009 Subject: [plt-scheme] handin-server checker Message-ID: <308b1f130909021452n5fce2125sb48a62d29b23b3cf@mail.gmail.com> Has anyone started / tried using the handin-server checker framework to deal with assignents that use the new universe teachpack? Namely, how are people dealing with the big-bang expression which may not have a stop-when? clause to end the simulation in combination with the checker? Thanks, -ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090902/04ecc9c4/attachment.html From eli at barzilay.org Wed Sep 2 17:59:20 2009 From: eli at barzilay.org (Eli Barzilay) Date: Wed Sep 2 17:59:44 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: References: Message-ID: <19102.60088.538836.881674@winooski.ccs.neu.edu> On Sep 2, Lee Spector wrote: > I've developed some code in DrScheme under Mac OS X that I also want > to run sometimes under Linux -- it's computationally intensive stuff > and I'll want to do development runs on my mac but then do lots of > bigger runs on our Linux cluster. > > I have some graphics in the Mac OS X version that I don't know how > to produce in my command-line/text-based Linux environment, but I > don't need the graphics there anyway. The graphics are just plots of > progress which are useful when I'm developing and watching a run, > but the cluster runs produce text files of data which are good > enough. So to get the code working on the cluster I just removed > "(require plot)" and all of the code that called anything from the > plot module. > > That worked but I don't want to have to do this kind of surgery on > the code every time I move it to the cluster, which I'll be doing > frequently. Ideally I'd like to be able to write my code in such a > way that it knows where it's running and it includes the plot module > and calls the plot code only if it's running somewhere > appropriate. I do this in Common Lisp by using the #+: and #-: (You mean #+ and #-, which are usually followed by a keyword...) > conditional compilation syntax and/or by looking for things in the > variable *features*, which includes symbols that describe the > environment. Is there anything similar in PLT? Not in that way. More than that, the fact that there is no direct equivalent of this is an intnetional way of avoiding the mess you can easily get into with CL: `*features*' is a description of the "currently running system" but it is used for three separate roles: reading, compiling, and running. For example, if you were using something like: #+linux (require plot) and then compile the code and run it on the linux machine, then you *would* get it to run, since the reader already worked elsewhere. Now, there is (of course) some way to get a similar facility (and you can of course shoot your foot in various ways). One way would be: (define-syntax (foo stx) (if (eq? 'unix (system-type)) #'(printf "Running on a unix machine\n") #'(printf "Running on a non-unix machine\n"))) Having this kind of platform-dependent macro means that compiled files are now platform-dependent too, so things will work as long as you're careful to not move .zo files between machines. (Note that you can do the same with something like and environment variable and the `getenv' function, with exactly the same kind of problem.) A much better idea is to delay the decision to where it belongs more naturally -- in the runtime. But this runs into the problem you've seen: `require' is not an expression, so you can't put it in an `if'. The reason you can't do that is that `require' is used at compile-time to tell the compiler how to compile and link the code (think about requiring a module that provides some macro that you're using: you *need* it at compile time then). For such cases, there is `dynamic-require', which will require a module dynamically and pull out a value. In this case, you can just use: (dynamic-require 'plot 'plot) instead of `plot', and as long as that's not executed, the library will not be used. With a little more effort it's not too difficult to write an `autoload' macro. (But it is, of course, limited to functions.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From eli at barzilay.org Wed Sep 2 18:09:46 2009 From: eli at barzilay.org (Eli Barzilay) Date: Wed Sep 2 18:10:08 2009 Subject: [plt-scheme] handin-server checker In-Reply-To: <308b1f130909021452n5fce2125sb48a62d29b23b3cf@mail.gmail.com> References: <308b1f130909021452n5fce2125sb48a62d29b23b3cf@mail.gmail.com> Message-ID: <19102.60714.513273.863983@winooski.ccs.neu.edu> On Sep 2, Ryan Golbeck wrote: > Has anyone started / tried using the handin-server checker framework > to deal with assignents that use the new universe teachpack? > Namely, how are people dealing with the big-bang expression which > may not have a stop-when? clause to end the simulation in > combination with the checker? A sandboxed evaluator runs in its own thread, and you can kill it whenever. However, it will be difficult to programmatically test that the window is up, that the graphics is showing what it should etc. And that reminds me of an additional item I forgot to mention in my last email: there is no way currently to have `check-expect' raise an error for test failures (and it's very difficult to even tell if a sandbox had test failures at all). -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From lspector at hampshire.edu Wed Sep 2 18:08:11 2009 From: lspector at hampshire.edu (Lee Spector) Date: Wed Sep 2 18:13:34 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: References: Message-ID: <23B24FEF-0008-45BA-8F15-7C19BC3AA7C7@hampshire.edu> Ah -- (system-type) is nice, and I'm not at all worried about the cost of a few calls to void. But I still don't see how to make this work because I have to have (require plot) in the file to make the plots work in macosx, (require plot) breaks under Linux ("dynamic-require: unknown module: '#%mred- kernel; need to run in mred instead of mzscheme"), and I can't wrap (require plot) in a conditional ("require: not at module level or top level in: (require plot)"). While I could comment out and uncomment the (require plot) I'd have a similar problem with the calls to the functions in the plot module, even if they are wrapped in conditions that prevent them from being executed in the wrong (system-type). Just saw that Eli sent some additional info... -Lee On Sep 2, 2009, at 5:52 PM, Matthias Felleisen wrote: > > Would > >> Welcome to MzScheme v4.2.1.7 [3m], Copyright (c) 2004-2009 PLT >> Scheme Inc. >> > (system-type) >> macosx > > help you get started? If you can tolerate a call to void for plots > on the cluster, I'd use an abstraction over the graphics. If you > want to see the tracker, pass in draw-progress-report (or whatever > you call the graphics function); otherwise pass in void instead. > > If the extra call costs too much, I'd write a macro that unfolds in > one way on a mac and in a different way on a linux box. > > -- Matthias > > > > > > > > On Sep 2, 2009, at 5:34 PM, Lee Spector wrote: > >> >> I've developed some code in DrScheme under Mac OS X that I also >> want to run sometimes under Linux -- it's computationally intensive >> stuff and I'll want to do development runs on my mac but then do >> lots of bigger runs on our Linux cluster. >> >> I have some graphics in the Mac OS X version that I don't know how >> to produce in my command-line/text-based Linux environment, but I >> don't need the graphics there anyway. The graphics are just plots >> of progress which are useful when I'm developing and watching a >> run, but the cluster runs produce text files of data which are good >> enough. So to get the code working on the cluster I just removed >> "(require plot)" and all of the code that called anything from the >> plot module. >> >> That worked but I don't want to have to do this kind of surgery on >> the code every time I move it to the cluster, which I'll be doing >> frequently. Ideally I'd like to be able to write my code in such a >> way that it knows where it's running and it includes the plot >> module and calls the plot code only if it's running somewhere >> appropriate. I do this in Common Lisp by using the #+: and #-: >> conditional compilation syntax and/or by looking for things in the >> variable *features*, which includes symbols that describe the >> environment. Is there anything similar in PLT? >> >> I wouldn't mind having to manually change a flag to indicate the >> environment, e.g. to change the value in something like: >> >> (define include-plots-in-reports #t) >> >> But this doesn't actually help for two reasons: >> >> - PLT won't let me wrap a call to "require" in a conditional >> expression -- it complains that it's not at the top level. >> - If I comment out the "require" PLT still won't compile a file >> containing calls to functions in the missing module, even if those >> calls are never executed. >> >> So whether my code knows where it's running or whether I have to >> tell it manually, I don't have a way of moving it to the Linux >> environment without manually editing out the "require" and all of >> the code that refers to the plot module. >> >> Is there a good way to deal with this kind of thing in PLT that I'm >> missing? >> >> Thanks, >> >> -Lee >> >> -- >> Lee Spector, Professor of Computer Science >> School of Cognitive Science, Hampshire College >> 893 West Street, Amherst, MA 01002-3359 >> lspector@hampshire.edu, http://hampshire.edu/lspector/ >> Phone: 413-559-5352, Fax: 413-559-5438 >> >> Check out Genetic Programming and Evolvable Machines: >> http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ >> >> _________________________________________________ >> For list-related administrative tasks: >> http://list.cs.brown.edu/mailman/listinfo/plt-scheme -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ From tbourdon at gmail.com Wed Sep 2 18:13:28 2009 From: tbourdon at gmail.com (tbourdon) Date: Wed Sep 2 18:14:01 2009 Subject: [plt-scheme] Re: Lexical Scoping, References and Side Effects In-Reply-To: <64FA9158-54B7-42E2-9F7F-6EBFE2E9BA7D@MIT.EDU> References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> <64FA9158-54B7-42E2-9F7F-6EBFE2E9BA7D@MIT.EDU> Message-ID: Will - This is actually pretty close to what I came up with my implementation where I used (define-struct list-pointer (value)). And thanks for the tip about the ! for procedure names that will mutate their arguments. I'm guessing that one of the object systems would support this type of behavior as well. Would this be a correct assumption and if so would you have any recommendations on which one to use? Like I said, I'm just getting into Scheme and I'm pretty green. Thanks; - Troy On Sep 2, 2:31?pm, Will M Farr wrote: > There's no way to make this work if you use a bare list as your stack ? > data structure. ?However, if you make your own stack data structure ? > which stores a list of the elements on the stack, then you can store a ? > new list in the structure for every stack-push!/pop!. ?(By the way, ? > it's customary in Scheme to name procedures that mutate their ? > arguments with trailing "!".) ?Something like the following sounds ? > like what you want: > > #lang scheme > > ;; A stack stores a list of the elements it contains > ;; #:mutable needed to change the stored list on pop/push > ;; #:transparent for easy printing and inspection. > (define-struct stack (elements) #:mutable #:transparent) > > ;; Push obj onto the top of the stack. Return value is void > (define (stack-push! stack obj) > ? ?(set-stack-elements! stack (cons obj (stack-elements stack)))) > > ;; Pop the top object off the stack and return it > (define (stack-pop! stack) > ? ?(when (null? (stack-elements stack)) > ? ? ?(error 'stack-pop! "empty stack: ~a" stack)) > ? ?(let* ((elements (stack-elements stack)) > ? ? ? ? ? (top (car elements))) > ? ? ?(set-stack-elements! stack (cdr elements)) > ? ? ?top)) > > ;; Look at the top element without changing it > (define (stack-peek stack) > ? ?(when (null? (stack-elements stack)) > ? ? ?(error 'stack-peek "empty stack: ~a" stack)) > ? ?(car (stack-elements stack))) > > #| > ;; Tests. > > (define the-stack (make-stack '())) > > (stack-push! the-stack 1) > (stack-push! the-stack 2) > (stack-push! the-stack 3) > > (equal? (stack-peek the-stack) 3) > ;; #t > > (equal? (stack-pop! the-stack) 3) > ;; #t > > (equal? (stack-peek the-stack) 2) > ;; #t > > (stack-push! the-stack 'a) > > (equal? (stack-pop! the-stack) 'a) > ;; #t > > (equal? (stack-pop! the-stack) 2) > ;; #t > > (equal? (stack-pop! the-stack) 1) > ;; #t > > (stack-pop! the-stack) > ;; Error! > > |# > > Enjoy! > > Will > > On Sep 2, 2009, at 10:42 AM, tbourdon wrote: > > > As I said, "For my second implementation I had the stack-push function > > just return the updated stack but as you can see this leads to > > successive set! calls" and that's the whole point. I don't want stack- > > push to return anything. I want it to change the state of the stack > > that's passed in so the caller can reference that stack's changed > > state later. In other words, is there a way for the following to work? > > > (define stack ()) ; stack is defined as empty list. > > (stack-push stack 1) ; stack-push pushes 1 onto stack. > > (stack-top stack) => 1 ; stack-top returns 1. > > > On Sep 2, 12:30 am, Matthias Felleisen wrote: > >> On Aug 30, 2009, at 7:42 PM, tbourdon wrote: > > >>> Hello - > > >>> I'm currently teaching myself ?Scheme by working through "Teach > >>> Yourself Scheme in Fixnum Days" and "The Little Schemer". As I was > >>> working through the sources I decided to break off and implement ? > >>> some > >>> stack data structures. So far I've implemented the stack functions > >>> three different ways and I've noticed that I really can't (or ? > >>> haven't > >>> found a way) to create a reference to a stack and pass it around ? > >>> to be > >>> operated on. > > >>> For example; I can't come up with an implementation for a stack-push > >>> function where the following works: > > >>> (define stack ()) > >>> (stack-push stack 1) > >>> (stack-top stack) => 1 > > >> You omitted the most important part of your quasi-spec? What should > >> stack-push return? > > >> _________________________________________________ > >> ? For list-related administrative tasks: > >> ?http://list.cs.brown.edu/mailman/listinfo/plt-scheme > > _________________________________________________ > > ?For list-related administrative tasks: > > ?http://list.cs.brown.edu/mailman/listinfo/plt-scheme > > > > ?PGP.sig > < 1KViewDownload > > _________________________________________________ > ? For list-related administrative tasks: > ?http://list.cs.brown.edu/mailman/listinfo/plt-scheme From matthias at ccs.neu.edu Wed Sep 2 18:13:51 2009 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed Sep 2 18:14:34 2009 Subject: [plt-scheme] handin-server checker In-Reply-To: <19102.60714.513273.863983@winooski.ccs.neu.edu> References: <308b1f130909021452n5fce2125sb48a62d29b23b3cf@mail.gmail.com> <19102.60714.513273.863983@winooski.ccs.neu.edu> Message-ID: I think Ryan is asking for a programmatic way to time-out sandboxes. As for the universe teachpack, we should probably provide a stub that is 'graphics' less and instead admits a reply of events, including message events from the server. On Sep 2, 2009, at 6:09 PM, Eli Barzilay wrote: > On Sep 2, Ryan Golbeck wrote: >> Has anyone started / tried using the handin-server checker framework >> to deal with assignents that use the new universe teachpack? >> Namely, how are people dealing with the big-bang expression which >> may not have a stop-when? clause to end the simulation in >> combination with the checker? > > A sandboxed evaluator runs in its own thread, and you can kill it > whenever. However, it will be difficult to programmatically test that > the window is up, that the graphics is showing what it should etc. > > > And that reminds me of an additional item I forgot to mention in my > last email: there is no way currently to have `check-expect' raise an > error for test failures (and it's very difficult to even tell if a > sandbox had test failures at all). > > -- > ((lambda (x) (x x)) (lambda (x) (x x))) Eli > Barzilay: > http://barzilay.org/ Maze is > Life! > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From matthias at ccs.neu.edu Wed Sep 2 18:15:14 2009 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed Sep 2 18:15:51 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <23B24FEF-0008-45BA-8F15-7C19BC3AA7C7@hampshire.edu> References: <23B24FEF-0008-45BA-8F15-7C19BC3AA7C7@hampshire.edu> Message-ID: Just run the program in mred on linux. You will be fine -- Matthias On Sep 2, 2009, at 6:08 PM, Lee Spector wrote: > > Ah -- (system-type) is nice, and I'm not at all worried about the > cost of a few calls to void. > > But I still don't see how to make this work because I have to have > (require plot) in the file to make the plots work in macosx, > (require plot) breaks under Linux ("dynamic-require: unknown module: > '#%mred-kernel; need to run in mred instead of mzscheme"), and I > can't wrap (require plot) in a conditional ("require: not at module > level or top level in: (require plot)"). While I could comment out > and uncomment the (require plot) I'd have a similar problem with the > calls to the functions in the plot module, even if they are wrapped > in conditions that prevent them from being executed in the wrong > (system-type). > > Just saw that Eli sent some additional info... > > -Lee > > On Sep 2, 2009, at 5:52 PM, Matthias Felleisen wrote: > >> >> Would >> >>> Welcome to MzScheme v4.2.1.7 [3m], Copyright (c) 2004-2009 PLT >>> Scheme Inc. >>> > (system-type) >>> macosx >> >> help you get started? If you can tolerate a call to void for plots >> on the cluster, I'd use an abstraction over the graphics. If you >> want to see the tracker, pass in draw-progress-report (or whatever >> you call the graphics function); otherwise pass in void instead. >> >> If the extra call costs too much, I'd write a macro that unfolds in >> one way on a mac and in a different way on a linux box. >> >> -- Matthias >> >> >> >> >> >> >> >> On Sep 2, 2009, at 5:34 PM, Lee Spector wrote: >> >>> >>> I've developed some code in DrScheme under Mac OS X that I also >>> want to run sometimes under Linux -- it's computationally >>> intensive stuff and I'll want to do development runs on my mac but >>> then do lots of bigger runs on our Linux cluster. >>> >>> I have some graphics in the Mac OS X version that I don't know how >>> to produce in my command-line/text-based Linux environment, but I >>> don't need the graphics there anyway. The graphics are just plots >>> of progress which are useful when I'm developing and watching a >>> run, but the cluster runs produce text files of data which are >>> good enough. So to get the code working on the cluster I just >>> removed "(require plot)" and all of the code that called anything >>> from the plot module. >>> >>> That worked but I don't want to have to do this kind of surgery on >>> the code every time I move it to the cluster, which I'll be doing >>> frequently. Ideally I'd like to be able to write my code in such a >>> way that it knows where it's running and it includes the plot >>> module and calls the plot code only if it's running somewhere >>> appropriate. I do this in Common Lisp by using the #+: and #-: >>> conditional compilation syntax and/or by looking for things in the >>> variable *features*, which includes symbols that describe the >>> environment. Is there anything similar in PLT? >>> >>> I wouldn't mind having to manually change a flag to indicate the >>> environment, e.g. to change the value in something like: >>> >>> (define include-plots-in-reports #t) >>> >>> But this doesn't actually help for two reasons: >>> >>> - PLT won't let me wrap a call to "require" in a conditional >>> expression -- it complains that it's not at the top level. >>> - If I comment out the "require" PLT still won't compile a file >>> containing calls to functions in the missing module, even if those >>> calls are never executed. >>> >>> So whether my code knows where it's running or whether I have to >>> tell it manually, I don't have a way of moving it to the Linux >>> environment without manually editing out the "require" and all of >>> the code that refers to the plot module. >>> >>> Is there a good way to deal with this kind of thing in PLT that >>> I'm missing? >>> >>> Thanks, >>> >>> -Lee >>> >>> -- >>> Lee Spector, Professor of Computer Science >>> School of Cognitive Science, Hampshire College >>> 893 West Street, Amherst, MA 01002-3359 >>> lspector@hampshire.edu, http://hampshire.edu/lspector/ >>> Phone: 413-559-5352, Fax: 413-559-5438 >>> >>> Check out Genetic Programming and Evolvable Machines: >>> http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ >>> >>> _________________________________________________ >>> For list-related administrative tasks: >>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme > > -- > Lee Spector, Professor of Computer Science > School of Cognitive Science, Hampshire College > 893 West Street, Amherst, MA 01002-3359 > lspector@hampshire.edu, http://hampshire.edu/lspector/ > Phone: 413-559-5352, Fax: 413-559-5438 > > Check out Genetic Programming and Evolvable Machines: > http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ > > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From eli at barzilay.org Wed Sep 2 18:20:02 2009 From: eli at barzilay.org (Eli Barzilay) Date: Wed Sep 2 18:20:24 2009 Subject: [plt-scheme] handin-server checker In-Reply-To: References: <308b1f130909021452n5fce2125sb48a62d29b23b3cf@mail.gmail.com> <19102.60714.513273.863983@winooski.ccs.neu.edu> Message-ID: <19102.61330.208540.872092@winooski.ccs.neu.edu> On Sep 2, Matthias Felleisen wrote: > I think Ryan is asking for a programmatic way to time-out sandboxes. If that's the case, then it's easy like every other situation where you want to terminate a computation after a delay: (let ([e (make-evaluator ...)]) (sleep 2) (kill-evaluator e)) > As for the universe teachpack, we should probably provide a stub that > is 'graphics' less and instead admits a reply of events, including > message events from the server. [Right -- and my guess is that this is going to take a little effort...] -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From farr at MIT.EDU Wed Sep 2 18:26:52 2009 From: farr at MIT.EDU (Will M Farr) Date: Wed Sep 2 18:27:16 2009 Subject: [plt-scheme] Re: Lexical Scoping, References and Side Effects In-Reply-To: References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> <64FA9158-54B7-42E2-9F7F-6EBFE2E9BA7D@MIT.EDU> Message-ID: Troy, I don't really have much experience with object systems in PLT Scheme, but if you're coming from the Java/C/C++ world, I think the native object system (see http://docs.plt-scheme.org/guide/classes.html ) is pretty close to what you're used to in terms of objects. There is also the "swindle" object system (see http://docs.plt-scheme.org/swindle/index.html ), which will feel more natural if you're used to CLOS. Finally, there's a poor-man's object system built into the structs of PLT Scheme: (define-struct (my-struct super) field ...) will define a new structure type, my-struct, which contains the given fields, and also all the fields of super. (super? my-struct-instance) will return #t, and (super-field my-struct-instance) will access the fields in the super structure type in instances of my-struct. This is (more or less) the functionality you get from representing objects as C structs, and including a copy of the super object at the beginning of "sub classes": typedef struct { void *super_field1; ...; } super; typedef struct { super super; void *my_struct_field1; ...; } my_struct; Hope that's helpful. Will On Sep 2, 2009, at 6:13 PM, tbourdon wrote: > Will - > > This is actually pretty close to what I came up with my implementation > where I used (define-struct list-pointer (value)). And thanks for the > tip about the ! for procedure names that will mutate their arguments. > I'm guessing that one of the object systems would support this type of > behavior as well. Would this be a correct assumption and if so would > you have any recommendations on which one to use? Like I said, I'm > just getting into Scheme and I'm pretty green. > > Thanks; > > - Troy > > On Sep 2, 2:31 pm, Will M Farr wrote: >> There's no way to make this work if you use a bare list as your stack >> data structure. However, if you make your own stack data structure >> which stores a list of the elements on the stack, then you can >> store a >> new list in the structure for every stack-push!/pop!. (By the way, >> it's customary in Scheme to name procedures that mutate their >> arguments with trailing "!".) Something like the following sounds >> like what you want: >> >> #lang scheme >> >> ;; A stack stores a list of the elements it contains >> ;; #:mutable needed to change the stored list on pop/push >> ;; #:transparent for easy printing and inspection. >> (define-struct stack (elements) #:mutable #:transparent) >> >> ;; Push obj onto the top of the stack. Return value is void >> (define (stack-push! stack obj) >> (set-stack-elements! stack (cons obj (stack-elements stack)))) >> >> ;; Pop the top object off the stack and return it >> (define (stack-pop! stack) >> (when (null? (stack-elements stack)) >> (error 'stack-pop! "empty stack: ~a" stack)) >> (let* ((elements (stack-elements stack)) >> (top (car elements))) >> (set-stack-elements! stack (cdr elements)) >> top)) >> >> ;; Look at the top element without changing it >> (define (stack-peek stack) >> (when (null? (stack-elements stack)) >> (error 'stack-peek "empty stack: ~a" stack)) >> (car (stack-elements stack))) >> >> #| >> ;; Tests. >> >> (define the-stack (make-stack '())) >> >> (stack-push! the-stack 1) >> (stack-push! the-stack 2) >> (stack-push! the-stack 3) >> >> (equal? (stack-peek the-stack) 3) >> ;; #t >> >> (equal? (stack-pop! the-stack) 3) >> ;; #t >> >> (equal? (stack-peek the-stack) 2) >> ;; #t >> >> (stack-push! the-stack 'a) >> >> (equal? (stack-pop! the-stack) 'a) >> ;; #t >> >> (equal? (stack-pop! the-stack) 2) >> ;; #t >> >> (equal? (stack-pop! the-stack) 1) >> ;; #t >> >> (stack-pop! the-stack) >> ;; Error! >> >> |# >> >> Enjoy! >> >> Will >> >> On Sep 2, 2009, at 10:42 AM, tbourdon wrote: >> >>> As I said, "For my second implementation I had the stack-push >>> function >>> just return the updated stack but as you can see this leads to >>> successive set! calls" and that's the whole point. I don't want >>> stack- >>> push to return anything. I want it to change the state of the stack >>> that's passed in so the caller can reference that stack's changed >>> state later. In other words, is there a way for the following to >>> work? >> >>> (define stack ()) ; stack is defined as empty list. >>> (stack-push stack 1) ; stack-push pushes 1 onto stack. >>> (stack-top stack) => 1 ; stack-top returns 1. >> >>> On Sep 2, 12:30 am, Matthias Felleisen wrote: >>>> On Aug 30, 2009, at 7:42 PM, tbourdon wrote: >> >>>>> Hello - >> >>>>> I'm currently teaching myself Scheme by working through "Teach >>>>> Yourself Scheme in Fixnum Days" and "The Little Schemer". As I was >>>>> working through the sources I decided to break off and implement >>>>> some >>>>> stack data structures. So far I've implemented the stack functions >>>>> three different ways and I've noticed that I really can't (or >>>>> haven't >>>>> found a way) to create a reference to a stack and pass it around >>>>> to be >>>>> operated on. >> >>>>> For example; I can't come up with an implementation for a stack- >>>>> push >>>>> function where the following works: >> >>>>> (define stack ()) >>>>> (stack-push stack 1) >>>>> (stack-top stack) => 1 >> >>>> You omitted the most important part of your quasi-spec? What should >>>> stack-push return? >> >>>> _________________________________________________ >>>> For list-related administrative tasks: >>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme >>> _________________________________________________ >>> For list-related administrative tasks: >>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme >> >> >> >> PGP.sig >> < 1KViewDownload >> >> _________________________________________________ >> For list-related administrative tasks: >> http://list.cs.brown.edu/mailman/listinfo/plt-scheme > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 203 bytes Desc: This is a digitally signed message part Url : http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090902/b8eff638/PGP.pgp From eli at barzilay.org Wed Sep 2 18:33:46 2009 From: eli at barzilay.org (Eli Barzilay) Date: Wed Sep 2 18:34:19 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: References: <23B24FEF-0008-45BA-8F15-7C19BC3AA7C7@hampshire.edu> Message-ID: <19102.62154.267056.790293@winooski.ccs.neu.edu> On Sep 2, Matthias Felleisen wrote: > Just run the program in mred on linux. You will be fine -- Matthias There are several problems with that, and my guess is that Lee is trying to avoid such problems: 1. `mred-text' still requires a connection to a DISPLAY, and if you're running lots of processes on a cluster that can add up to some overhead. (But not a big one.) 2. Loading mred takes more time, which adds some more overhead, and that can be a problem if there are many programs that run for a short while (eg, if every randomly generated program runs in a new process). (But this is also not too big.) 3. If, for example, you ssh from an OSX machine to a linux machine, then you don't have an X display to connect to -- you need to run the OSX X server, and you need to make sure that ssh will do X forwarding (IIRC, it's off by default on OSX). Alternatively, you can run it all on VNC servers on each machine in the cluster. No runtime overhead here, but a mental one in the form of a hassle. 4. The biggest problem with this is that mred-text requires a working X connection -- if you have 40 machines running off of ssh jobs that forward the X connections to your machine, then they all depend on your machine to go on running. If you're machine dies, all of the remote runs will die immediately. I just had some eqperience with running jobs on a 40-machine cluster; if you're very careful then it's great to see all those cycles fly around, but if you're not, you end up with a whole bunch of problems to deal with -- even seemingly small ones like the fact that 40 terminal windows are not really manageable. (`screen' works better, but Emacs is really irreplaceable for these things -- you can start 40 shells, and do everything with keyboard macros.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From ryanc at ccs.neu.edu Wed Sep 2 18:34:51 2009 From: ryanc at ccs.neu.edu (Ryan Culpepper) Date: Wed Sep 2 18:35:20 2009 Subject: [plt-scheme] Hang in macro stepper when macro expansion does not terminate In-Reply-To: <2E993A05-6971-4B0F-9F27-41380E0639C1@ccs.neu.edu> References: <2E993A05-6971-4B0F-9F27-41380E0639C1@ccs.neu.edu> Message-ID: <23885FE6-13CC-4565-A5A5-C611BF7CD4BF@ccs.neu.edu> On Sep 2, 2009, at 5:53 PM, Matthias Felleisen wrote: > Sadly Ryan thinks that the macro stepper should execute the code > through which you step. I am hoping that everyone on this list can > help me convince him that this shouldn't be the case ... > > Use STOP to kill the execution as normal. Matthias: This is not about nonterminating execution. It is about nonterminating expansion. Brian: Clicking Stop is supposed to interrupt expansion. I'll try to see why it isn't working. BTW, what platform do you see the problem on? Ryan > On Sep 2, 2009, at 5:38 PM, Brian Mastenbrook wrote: > >> Hello, >> >> When trying to use the macro stepper on a program whose macro >> expansion does not terminate, the macro stepper will hang, and >> clicking Stop in the editor window toolbar does not help. Sending a >> SIGINT to the DrScheme process resolves the issue. I'm not >> expecting it to not hang if a form on the right-hand side of a >> `define-syntax' or `let-syntax' recurses infinitely, but when the >> expansion process does not terminate, it would still be nice to be >> able to use the macro stepper to determine what's going on. >> >> Just for clarity, this is an example of the type of program I'm >> talking about: >> >> #lang r5rs >> >> (define-syntax foo >> (syntax-rules () >> ((_) (foo)))) >> >> (foo) >> -- >> Brian Mastenbrook >> brian@mastenbrook.net >> http://brian.mastenbrook.net/ >> >> _________________________________________________ >> For list-related administrative tasks: >> http://list.cs.brown.edu/mailman/listinfo/plt-scheme > > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From eli at barzilay.org Wed Sep 2 18:36:05 2009 From: eli at barzilay.org (Eli Barzilay) Date: Wed Sep 2 18:36:27 2009 Subject: [plt-scheme] Re: Lexical Scoping, References and Side Effects In-Reply-To: References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> <64FA9158-54B7-42E2-9F7F-6EBFE2E9BA7D@MIT.EDU> Message-ID: <19102.62293.41653.555769@winooski.ccs.neu.edu> On Sep 2, tbourdon wrote: > > This is actually pretty close to what I came up with my > implementation where I used (define-struct list-pointer > (value)). And thanks for the tip about the ! for procedure names > that will mutate their arguments. I'm guessing that one of the > object systems would support this type of behavior as well. Would > this be a correct assumption and if so would you have any > recommendations on which one to use? Like I said, I'm just getting > into Scheme and I'm pretty green. See also `box' and `unbox' -- boxes are generic mutable containers that can be used roughly like pointers. (This is still not great, and misses the point of Matthias's original comment, but much better than a macro that `set!' a variable.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From lspector at hampshire.edu Wed Sep 2 18:55:24 2009 From: lspector at hampshire.edu (Lee Spector) Date: Wed Sep 2 19:00:50 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <19102.60088.538836.881674@winooski.ccs.neu.edu> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> Message-ID: <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> On Sep 2, 2009, at 5:59 PM, Eli Barzilay wrote: >> appropriate. I do this in Common Lisp by using the #+: and #-: > > (You mean #+ and #-, which are usually followed by a keyword...) Yes indeed -- I had forgotten where the ":" came from. > Not in that way. More than that, the fact that there is no direct > equivalent of this is an intnetional way of avoiding the mess you can > easily get into with CL: `*features*' is a description of the > "currently running system" but it is used for three separate roles: > reading, compiling, and running. For example, if you were using I'm going to get myself into needless trouble by saying this, and it's not even directly related to my question here, but one of the things I've always liked about CL is that I can decide when it's worth it to me to risk getting into such messes... > A much better idea is to delay the decision to where it belongs more > naturally -- in the runtime. But this runs into the problem you've > seen: `require' is not an expression, so you can't put it in an `if'. > The reason you can't do that is that `require' is used at compile-time > to tell the compiler how to compile and link the code (think about > requiring a module that provides some macro that you're using: you > *need* it at compile time then). Actually, I think that everything I want to do here belongs most naturally at compile time. I have a single source file that I want to be able to compile and run in two different environments. In one environment I'd like the compiler to skip (require plot) and I'd also like it to compile one definition instead of another. So in CL I might do: #+:MACOSX(require plot) #+:MACOSX(defun report-plot () ) #-:MACOSX(defun report () (values)) ;; just do nothing if I'm not in macosx, which also means I don't have the plot module All of this would most naturally be done at compile time -- under macosx the require would be done at compile time and the first definition of report-plot would be compiled, while in other environments the require would be skipped and the second definition of report-plot would be compiled. SO -- looking back at something else in your message I saw that you had actually shown me how to do this! This may not be the most elegant implementation but it works: (define-syntax (in-macosx stx) (if (eq? 'macosx (system-type)) (syntax-case stx () ((_ form) #`form)) #`(void))) (define-syntax (in-unix stx) (if (eq? 'unix (system-type)) (syntax-case stx () ((_ form) #`form)) #`(void))) (in-macosx (require plot)) (in-macosx (define plot-data (lambda (data x-label y-label) (plot (points (for/list ((i (number-list (length data)))) (vector i (list-ref data i))) #:sym 'oplus) #:x-min 0 #:x-max (length data) #:y-min 0 #:y-max (+ 1 (apply max data)) #:x-label x-label #:y-label y-label)))) (in-unix (define plot-data (lambda x (void)))) So my problem is solved! Thanks so much. -Lee PS Thanks also to Matthias for the suggestion of using mred and thanks to Eli for explaining the problems I was having in trying it! -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ From eli at barzilay.org Wed Sep 2 19:20:06 2009 From: eli at barzilay.org (Eli Barzilay) Date: Wed Sep 2 19:20:31 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> Message-ID: <19102.64934.651118.632445@winooski.ccs.neu.edu> On Sep 2, Lee Spector wrote: > On Sep 2, 2009, at 5:59 PM, Eli Barzilay wrote: > > > Not in that way. More than that, the fact that there is no direct > > equivalent of this is an intnetional way of avoiding the mess you > > can easily get into with CL: `*features*' is a description of the > > "currently running system" but it is used for three separate > > roles: reading, compiling, and running. For example, if you were > > using > > I'm going to get myself into needless trouble by saying this, and > it's not even directly related to my question here, but one of the > things I've always liked about CL is that I can decide when it's > worth it to me to risk getting into such messes... Well, in PLT you can *decide* when to get into a mess -- in CL it's easy to get into it by accident -- and that's where the problems start. [To avoid potential flames: I'm saying this because the default mode in CL is to have almost everything available at almost any phase, whereas the default in PLT is to have protection against accidental bugs. Also relevant: http://fare.livejournal.com/146698.html] In fact, by using the conditional syntax approach, you demonstrate nicely how to get (a part of) this mess. > > A much better idea is to delay the decision to where it belongs > > more naturally -- in the runtime. But this runs into the problem > > you've seen: `require' is not an expression, so you can't put it > > in an `if'. The reason you can't do that is that `require' is > > used at compile-time to tell the compiler how to compile and link > > the code (think about requiring a module that provides some macro > > that you're using: you *need* it at compile time then). > > Actually, I think that everything I want to do here belongs most > naturally at compile time. I have a single source file that I want > to be able to compile and run in two different environments. > [...] > > (define-syntax (in-unix stx) > (if (eq? 'unix (system-type)) > (syntax-case stx () > ((_ form) > #`form)) > #`(void))) Just in case it wasn't clear: 1. By doing this, you *must* be careful to copy only source files between the machines -- if you copy the whole directory with the .zo files, you will get to use the wrong version of the code since it was compiled on OSX. 2. Again, I recommend the `dynamic-require' solution -- it is a *function* rather than a declaration like `require', so by using it inside a function as the code below, you have no runtime overhead, but now it doesn't matter where you compile the code (IOW, your .zo file will be portable with this). (define plot-data (if (eq 'unix (system-type)) void (lambda (data x-label y-label) ((dynamic-require 'plot 'plot) (points (for/list ((i (number-list (length data)))) (vector i (list-ref data i))) #:sym 'oplus) #:x-min 0 #:x-max (length data) #:y-min 0 #:y-max (+ 1 (apply max data)) #:x-label x-label #:y-label y-label)))) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From robby at eecs.northwestern.edu Wed Sep 2 19:26:30 2009 From: robby at eecs.northwestern.edu (Robby Findler) Date: Wed Sep 2 19:26:51 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <19102.64934.651118.632445@winooski.ccs.neu.edu> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> Message-ID: <932b2f1f0909021626w626416b8n5b7de45e0978b8e2@mail.gmail.com> While I agree with Eli that dynamic-require is probably the right choice here, one thing to keep is mind is that .zo compilation can't track that the file corresponding to the code below depends on plot, so it won't include it in an executable you create (maybe this doesn't matter, tho). Robby On Wed, Sep 2, 2009 at 6:20 PM, Eli Barzilay wrote: > On Sep ?2, Lee Spector wrote: >> On Sep 2, 2009, at 5:59 PM, Eli Barzilay wrote: >> >> > Not in that way. ?More than that, the fact that there is no direct >> > equivalent of this is an intnetional way of avoiding the mess you >> > can easily get into with CL: `*features*' is a description of the >> > "currently running system" but it is used for three separate >> > roles: reading, compiling, and running. ?For example, if you were >> > using >> >> I'm going to get myself into needless trouble by saying this, and >> it's not even directly related to my question here, but one of the >> things I've always liked about CL is that I can decide when it's >> worth it to me to risk getting into such messes... > > Well, in PLT you can *decide* when to get into a mess -- in CL it's > easy to get into it by accident -- and that's where the problems > start. ?[To avoid potential flames: I'm saying this because the > default mode in CL is to have almost everything available at almost > any phase, whereas the default in PLT is to have protection against > accidental bugs. ?Also relevant: > http://fare.livejournal.com/146698.html] > > In fact, by using the conditional syntax approach, you demonstrate > nicely how to get (a part of) this mess. > > >> > A much better idea is to delay the decision to where it belongs >> > more naturally -- in the runtime. ?But this runs into the problem >> > you've seen: `require' is not an expression, so you can't put it >> > in an `if'. ?The reason you can't do that is that `require' is >> > used at compile-time to tell the compiler how to compile and link >> > the code (think about requiring a module that provides some macro >> > that you're using: you *need* it at compile time then). >> >> Actually, I think that everything I want to do here belongs most >> naturally at compile time. I have a single source file that I want >> to be able to compile and run in two different environments. >> [...] >> >> (define-syntax (in-unix stx) >> ? ?(if (eq? 'unix (system-type)) >> ? ? ? (syntax-case stx () >> ? ? ? ? ((_ form) >> ? ? ? ? ?#`form)) >> ? ? ? #`(void))) > > Just in case it wasn't clear: > > 1. By doing this, you *must* be careful to copy only source files > ? between the machines -- if you copy the whole directory with the > ? .zo files, you will get to use the wrong version of the code since > ? it was compiled on OSX. > > 2. Again, I recommend the `dynamic-require' solution -- it is a > ? *function* rather than a declaration like `require', so by using it > ? inside a function as the code below, you have no runtime overhead, > ? but now it doesn't matter where you compile the code (IOW, your .zo > ? file will be portable with this). > > ? ? (define plot-data > ? ? ? (if (eq 'unix (system-type)) > ? ? ? ? void > ? ? ? ? (lambda (data x-label y-label) > ? ? ? ? ? ((dynamic-require 'plot 'plot) > ? ? ? ? ? ?(points (for/list ((i (number-list (length data)))) > ? ? ? ? ? ? ? ? ? ? ?(vector i (list-ref data i))) > ? ? ? ? ? ? ? ? ? ?#:sym 'oplus) > ? ? ? ? ? ?#:x-min 0 > ? ? ? ? ? ?#:x-max (length data) > ? ? ? ? ? ?#:y-min 0 > ? ? ? ? ? ?#:y-max (+ 1 (apply max data)) > ? ? ? ? ? ?#:x-label x-label > ? ? ? ? ? ?#:y-label y-label)))) > > -- > ? ? ? ? ?((lambda (x) (x x)) (lambda (x) (x x))) ? ? ? ? ?Eli Barzilay: > ? ? ? ? ? ? ? ? ? ?http://barzilay.org/ ? ? ? ? ? ? ? ? ? Maze is Life! > _________________________________________________ > ?For list-related administrative tasks: > ?http://list.cs.brown.edu/mailman/listinfo/plt-scheme > From lspector at hampshire.edu Wed Sep 2 19:32:40 2009 From: lspector at hampshire.edu (Lee Spector) Date: Wed Sep 2 19:38:02 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <19102.64934.651118.632445@winooski.ccs.neu.edu> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> Message-ID: <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> Now that I see the fully-spelled-out solution with dynamic-require I agree that that is quite nice and probably preferable even on purely aesthetic grounds. For what it's worth, however, I certainly won't be moving .zo files (which I'm not even creating -- should I be?) or creating executables of any sort, at least in this project. Thanks so much (and while I'd generally rather have freedom than protection we can continue that debate at another time :-). -Lee On Sep 2, 2009, at 7:20 PM, Eli Barzilay wrote: > On Sep 2, Lee Spector wrote: >> On Sep 2, 2009, at 5:59 PM, Eli Barzilay wrote: >> >>> Not in that way. More than that, the fact that there is no direct >>> equivalent of this is an intnetional way of avoiding the mess you >>> can easily get into with CL: `*features*' is a description of the >>> "currently running system" but it is used for three separate >>> roles: reading, compiling, and running. For example, if you were >>> using >> >> I'm going to get myself into needless trouble by saying this, and >> it's not even directly related to my question here, but one of the >> things I've always liked about CL is that I can decide when it's >> worth it to me to risk getting into such messes... > > Well, in PLT you can *decide* when to get into a mess -- in CL it's > easy to get into it by accident -- and that's where the problems > start. [To avoid potential flames: I'm saying this because the > default mode in CL is to have almost everything available at almost > any phase, whereas the default in PLT is to have protection against > accidental bugs. Also relevant: > http://fare.livejournal.com/146698.html] > > In fact, by using the conditional syntax approach, you demonstrate > nicely how to get (a part of) this mess. > > >>> A much better idea is to delay the decision to where it belongs >>> more naturally -- in the runtime. But this runs into the problem >>> you've seen: `require' is not an expression, so you can't put it >>> in an `if'. The reason you can't do that is that `require' is >>> used at compile-time to tell the compiler how to compile and link >>> the code (think about requiring a module that provides some macro >>> that you're using: you *need* it at compile time then). >> >> Actually, I think that everything I want to do here belongs most >> naturally at compile time. I have a single source file that I want >> to be able to compile and run in two different environments. >> [...] >> >> (define-syntax (in-unix stx) >> (if (eq? 'unix (system-type)) >> (syntax-case stx () >> ((_ form) >> #`form)) >> #`(void))) > > Just in case it wasn't clear: > > 1. By doing this, you *must* be careful to copy only source files > between the machines -- if you copy the whole directory with the > .zo files, you will get to use the wrong version of the code since > it was compiled on OSX. > > 2. Again, I recommend the `dynamic-require' solution -- it is a > *function* rather than a declaration like `require', so by using it > inside a function as the code below, you have no runtime overhead, > but now it doesn't matter where you compile the code (IOW, your .zo > file will be portable with this). > > (define plot-data > (if (eq 'unix (system-type)) > void > (lambda (data x-label y-label) > ((dynamic-require 'plot 'plot) > (points (for/list ((i (number-list (length data)))) > (vector i (list-ref data i))) > #:sym 'oplus) > #:x-min 0 > #:x-max (length data) > #:y-min 0 > #:y-max (+ 1 (apply max data)) > #:x-label x-label > #:y-label y-label)))) > > -- > ((lambda (x) (x x)) (lambda (x) (x x))) Eli > Barzilay: > http://barzilay.org/ Maze is > Life! -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ From brian at mastenbrook.net Wed Sep 2 19:39:28 2009 From: brian at mastenbrook.net (Brian Mastenbrook) Date: Wed Sep 2 19:39:51 2009 Subject: [plt-scheme] Hang in macro stepper when macro expansion does not terminate In-Reply-To: <23885FE6-13CC-4565-A5A5-C611BF7CD4BF@ccs.neu.edu> References: <2E993A05-6971-4B0F-9F27-41380E0639C1@ccs.neu.edu> <23885FE6-13CC-4565-A5A5-C611BF7CD4BF@ccs.neu.edu> Message-ID: <5E1ED2CE-31A1-437A-84AD-52504FFC64CF@mastenbrook.net> On Sep 2, 2009, at 5:34 PM, Ryan Culpepper wrote: > On Sep 2, 2009, at 5:53 PM, Matthias Felleisen wrote: > >> Sadly Ryan thinks that the macro stepper should execute the code >> through which you step. I am hoping that everyone on this list can >> help me convince him that this shouldn't be the case ... >> >> Use STOP to kill the execution as normal. > > Matthias: This is not about nonterminating execution. It is about > nonterminating expansion. > > Brian: Clicking Stop is supposed to interrupt expansion. I'll try to > see why it isn't working. BTW, what platform do you see the problem > on? Sorry, I forgot to include those details in my original message. I'm using PLT 4.2.1 on OS X. When I click Stop the first time, the macro stepper appears, but then it hangs again for a long time. It seems that the longer I let it go before clicking "Stop", the longer it takes for the stepper to appear. When I first tried this, I had let it run for a while, and so when I clicked Stop I thought it had hung entirely. -- Brian Mastenbrook brian@mastenbrook.net http://brian.mastenbrook.net/ From eli at barzilay.org Wed Sep 2 19:52:51 2009 From: eli at barzilay.org (Eli Barzilay) Date: Wed Sep 2 19:53:11 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> Message-ID: <19103.1363.410647.706690@winooski.ccs.neu.edu> On Sep 2, Lee Spector wrote: > Now that I see the fully-spelled-out solution with dynamic-require I > agree that that is quite nice and probably preferable even on purely > aesthetic grounds. For what it's worth, however, I certainly won't > be moving .zo files (which I'm not even creating -- should I be?) or > creating executables of any sort, at least in this project. Compiling files will save you the compilation cost so if you run long processes there's no real difference. > Thanks so much (and while I'd generally rather have freedom than > protection we can continue that debate at another time :-). You have the freedom -- you can even do a reader thing similar to the CL #+ -- but the default makes it harder to trip on these bugs (which can get very nasty). -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From robby at eecs.northwestern.edu Wed Sep 2 20:00:58 2009 From: robby at eecs.northwestern.edu (Robby Findler) Date: Wed Sep 2 20:01:16 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <19103.1363.410647.706690@winooski.ccs.neu.edu> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> <19103.1363.410647.706690@winooski.ccs.neu.edu> Message-ID: <932b2f1f0909021700p5185e603ra4d2c9ca3ca4d32@mail.gmail.com> On Wed, Sep 2, 2009 at 6:52 PM, Eli Barzilay wrote: >> Thanks so much (and while I'd generally rather have freedom than >> protection we can continue that debate at another time :-). > > You have the freedom -- you can even do a reader thing similar to the > CL #+ -- but the default makes it harder to trip on these bugs (which > can get very nasty). Also, when your program is visible at compile time then various tools (check syntax, module browser, compiler, etc) work better. Robby From lspector at hampshire.edu Wed Sep 2 20:23:18 2009 From: lspector at hampshire.edu (Lee Spector) Date: Wed Sep 2 20:28:40 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <19103.1363.410647.706690@winooski.ccs.neu.edu> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> <19103.1363.410647.706690@winooski.ccs.neu.edu> Message-ID: On Sep 2, 2009, at 7:52 PM, Eli Barzilay wrote: > Compiling files will save you the compilation cost so if you run long > processes there's no real difference. Good -- that's what I thought and the same as compilation in CL, but I didn't know if there was some other reason for creating .zo files. In the case of my current project compilation takes less than a second and runtimes will often be hours, so it's not an issue. > You have the freedom -- you can even do a reader thing similar to the > CL #+ -- but the default makes it harder to trip on these bugs (which > can get very nasty). Understood. Part of my attitude is probably just from being a newcomer and feeling, probably often out of ignorance, like it's harder to do some things I'm used to doing in CL (e.g. in areas like writing macros with arbitrary expansions, using eval, and splitting code over multiple files without having to think about modules). In many such cases I'm probably just wrong, but I do think there's more of a focus on safety in this community. This is probably for the good in most situations, particularly when people are developing large software systems that will be used by others, but it can also sometimes feel constraining, particularly when developing small experimental systems for one's own use. -Lee PS Just to clear up something really minor from a previous post, my description of a CL solutionwould only really have made sense if both of these functions had the same name: > #+:MACOSX(defun report-plot () using stuff in the plot module>) > > #-:MACOSX(defun report () (values)) ;; just do nothing if I'm not in > macosx, which also means I don't have the plot module -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ From ryanc at ccs.neu.edu Wed Sep 2 20:33:09 2009 From: ryanc at ccs.neu.edu (Ryan Culpepper) Date: Wed Sep 2 20:34:46 2009 Subject: [plt-scheme] Hang in macro stepper when macro expansion does not terminate In-Reply-To: <5E1ED2CE-31A1-437A-84AD-52504FFC64CF@mastenbrook.net> References: <2E993A05-6971-4B0F-9F27-41380E0639C1@ccs.neu.edu> <23885FE6-13CC-4565-A5A5-C611BF7CD4BF@ccs.neu.edu> <5E1ED2CE-31A1-437A-84AD-52504FFC64CF@mastenbrook.net> Message-ID: <4A9F0EC5.4030509@ccs.neu.edu> Brian Mastenbrook wrote: > On Sep 2, 2009, at 5:34 PM, Ryan Culpepper wrote: > >> On Sep 2, 2009, at 5:53 PM, Matthias Felleisen wrote: >> >>> Sadly Ryan thinks that the macro stepper should execute the code >>> through which you step. I am hoping that everyone on this list can >>> help me convince him that this shouldn't be the case ... >>> >>> Use STOP to kill the execution as normal. >> >> Matthias: This is not about nonterminating execution. It is about >> nonterminating expansion. >> >> Brian: Clicking Stop is supposed to interrupt expansion. I'll try to >> see why it isn't working. BTW, what platform do you see the problem on? > > Sorry, I forgot to include those details in my original message. I'm > using PLT 4.2.1 on OS X. When I click Stop the first time, the macro > stepper appears, but then it hangs again for a long time. It seems that > the longer I let it go before clicking "Stop", the longer it takes for > the stepper to appear. When I first tried this, I had let it run for a > while, and so when I clicked Stop I thought it had hung entirely. Thanks for the details. Here's what seems to be going on. When you click Stop, macro expansion is interrupted, and the macro stepper starts constructing its report of macro expansion. That takes a long time in this case, and it can't be interrupted using Stop again. I think that making the second process asynchronous would fix the problem with DrScheme becoming unresponsive. I'll give that a try. Ryan From rafkind at cs.utah.edu Wed Sep 2 20:44:09 2009 From: rafkind at cs.utah.edu (Jon Rafkind) Date: Wed Sep 2 20:46:18 2009 Subject: [plt-scheme] match single symbol Message-ID: <4A9F1159.5010303@cs.utah.edu> I was trying to match a single symbol but I didn't see a match pattern for it. This code seems to do what I want (define (match-symbol sym) (match sym [x (=> f) (if (not (symbol? x)) (f) 'ok)] [else 'bad])) (match-symbol 'a) (match-symbol 23) (match-symbol '(1 2 3)) --> ok bad bad Can something like this be added to scheme/match or is there an existing/simpler way to do it? From ryanc at ccs.neu.edu Wed Sep 2 20:49:12 2009 From: ryanc at ccs.neu.edu (Ryan Culpepper) Date: Wed Sep 2 20:50:26 2009 Subject: [plt-scheme] match single symbol In-Reply-To: <4A9F1159.5010303@cs.utah.edu> References: <4A9F1159.5010303@cs.utah.edu> Message-ID: <4A9F1288.20508@ccs.neu.edu> Jon Rafkind wrote: > I was trying to match a single symbol but I didn't see a match pattern > for it. This code seems to do what I want > > (define (match-symbol sym) > (match sym > [x (=> f) (if (not (symbol? x)) (f) 'ok)] > [else 'bad])) (define (match-symbol sym) (match sym [(? symbol?) 'ok] [_ 'bad])) Ryan > (match-symbol 'a) > (match-symbol 23) > (match-symbol '(1 2 3)) > > --> > ok > bad > bad > > Can something like this be added to scheme/match or is there an > existing/simpler way to do it? > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme From lspector at hampshire.edu Wed Sep 2 21:25:26 2009 From: lspector at hampshire.edu (Lee Spector) Date: Wed Sep 2 21:30:47 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <932b2f1f0909021700p5185e603ra4d2c9ca3ca4d32@mail.gmail.com> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> <19103.1363.410647.706690@winooski.ccs.neu.edu> <932b2f1f0909021700p5185e603ra4d2c9ca3ca4d32@mail.gmail.com> Message-ID: On Sep 2, 2009, at 8:00 PM, Robby Findler wrote: > Also, when your program is visible at compile time then various tools > (check syntax, module browser, compiler, etc) work better. My first thought in reading this was "then maybe it should make it easier to implement arglist-on-space"! When I brought this up recently several of you pointed to some related utilities (helpful but not the same as having arglist-on-space right in DrScheme) and Eli pointed out that in PLT the whole concept is somewhat problematic because of definitions with case-lambda and multiple possible arglists of different arities. Fair enough. But after working in DrScheme for about a month this is still the #1 thing I miss from my favorite CL environments, and I'd walk a mile even for an imperfect version that just punted on the weird cases and said something like "see source code." BTW the ideal version of this in the DrScheme context would also keep the arglist information from the most recent compile (as in MCL for example), so that you can get the arglists for functions defined in the same file if you've already compiled it once (and if they're wrong because you subsequently edited the definitions I could live with that too). BTW the #2 thing I'm missing is the ability to see local variables from the context of an error condition, all the way up the activation record stack. And evaluate expressions in that context. As far as I can see one can't even do either of these things from the graphical debugger, although that seems to run too slowly for me to use it on my current application anyway. In every CL I've used one can do both of these things in some way, whether graphically (very nice in MCL and on some Lisp machines I used long ago) or textually (awkward but you could at least explore the context in which the error occurred). Maybe this is somehow incompatible with the whole PLT compilation model or something... but if not I'd love to be able to do it! Thanks, -Lee -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com From toddobryan at gmail.com Wed Sep 2 22:06:25 2009 From: toddobryan at gmail.com (Todd O'Bryan) Date: Wed Sep 2 22:15:02 2009 Subject: [plt-scheme] Test the Program In-Reply-To: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> References: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> Message-ID: <904774730909021906q198572edifb6a313c2efefec0@mail.gmail.com> Actually, I think I know what you're doing and it's an easy mistake to make... The "Run" button runs the *Definitions* pane and erases everything in the Interactions pane. If you want to evaluate something in the Interactions pane, DON'T CLICK RUN! Just press the enter key. You have no idea how many students get really frustrated by this experience--"I keep typing something and clicking Run and it just disappears."--so you're not alone. Todd On Wed, Sep 2, 2009 at 4:06 PM, Asher, Gregg wrote: > I apologize if this question has been asked before. I checked the archives > and couldn?t find my problem listed. > > > > When I define a program in the definitions window and then enter the program > name in the interactive window substituting a value for the parameter and > then ?Run? (my version of Dr. Scheme doesn?t have an ?Execute? button) the > program I don?t the results of the program but a message ?This program > should be tested. > >>? > > > > For example when I run this program (area-of-disk 3), I get the message > ?This program should be tested. > >>? > > > > When I run the same program (area-of-disk 3) in the definitions window > > > > I get the correct answer ?28.26? in the interactive window. > > > > Any help would be appreciated. > > > > Dr. Scheme is running off of a flash drive if that makes any difference. I > have 60 programming students and want them to run Dr. Scheme from the flash > drive so that they can run the program from any computer. > > > > Gregg W. Asher, Ph.D. > > Associate professor > > Information Systems & Technology > > Minnesota State University, Mankato > > Mankato, MN. 56001 > > > > _________________________________________________ > ?For list-related administrative tasks: > ?http://list.cs.brown.edu/mailman/listinfo/plt-scheme > > From yinso.chen at gmail.com Wed Sep 2 22:33:53 2009 From: yinso.chen at gmail.com (YC) Date: Wed Sep 2 22:34:13 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> <19103.1363.410647.706690@winooski.ccs.neu.edu> Message-ID: <779bf2730909021933i7f29d295ka96e90f169f767c8@mail.gmail.com> On Wed, Sep 2, 2009 at 5:23 PM, Lee Spector wrote: > > On Sep 2, 2009, at 7:52 PM, Eli Barzilay wrote: > >> Compiling files will save you the compilation cost so if you run long >> processes there's no real difference. >> > > Good -- that's what I thought and the same as compilation in CL, but I > didn't know if there was some other reason for creating .zo files. In the > case of my current project compilation takes less than a second and runtimes > will often be hours, so it's not an issue. When you deliver the code via planet, the code gets compiled for you. > > You have the freedom -- you can even do a reader thing similar to the >> CL #+ -- but the default makes it harder to trip on these bugs (which >> can get very nasty). >> > > Understood. Part of my attitude is probably just from being a newcomer and > feeling, probably often out of ignorance, like it's harder to do some things > I'm used to doing in CL (e.g. in areas like writing macros with arbitrary > expansions, using eval, and splitting code over multiple files without > having to think about modules). In many such cases I'm probably just wrong, > but I do think there's more of a focus on safety in this community. This is > probably for the good in most situations, particularly when people are > developing large software systems that will be used by others, but it can > also sometimes feel constraining, particularly when developing small > experimental systems for one's own use. > It seems that if you have taken the care to abstract your OS dependent code to separate OS specific modules (which all export the same module signature), than conditionally requiring the modules during compile time makes sense. I've hacked up a planet package to support this particular usage - if you are interested just load it via (require (planet bzlib/os)) Which will give you macros to conditionally requiring modules, provide modules, and evaluate arbitrary code. See the package homepage for more details. Cheers, yc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090902/5ecd2761/attachment.htm From lspector at hampshire.edu Wed Sep 2 23:58:05 2009 From: lspector at hampshire.edu (Lee Spector) Date: Thu Sep 3 00:03:27 2009 Subject: [plt-scheme] conditional module inclusion and compilation In-Reply-To: <779bf2730909021933i7f29d295ka96e90f169f767c8@mail.gmail.com> References: <19102.60088.538836.881674@winooski.ccs.neu.edu> <8089CB62-1174-4E60-99E0-F9F34C022ACD@hampshire.edu> <19102.64934.651118.632445@winooski.ccs.neu.edu> <38588EB7-AF46-4277-BCF2-56F0E8DCBFAF@hampshire.edu> <19103.1363.410647.706690@winooski.ccs.neu.edu> <779bf2730909021933i7f29d295ka96e90f169f767c8@mail.gmail.com> Message-ID: Very nice -- I had no idea this existed. Thanks, -Lee On Sep 2, 2009, at 10:33 PM, YC wrote: > > I've hacked up a planet package to support this particular usage - > if you are interested just load it via > > (require (planet bzlib/os)) > > Which will give you macros to conditionally requiring modules, > provide modules, and evaluate arbitrary code. > > See the package homepage for more details. > > Cheers, > yc > -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspector@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ From rafkind at cs.utah.edu Thu Sep 3 00:20:03 2009 From: rafkind at cs.utah.edu (Jon Rafkind) Date: Thu Sep 3 00:22:17 2009 Subject: [plt-scheme] match single symbol In-Reply-To: <4A9F1288.20508@ccs.neu.edu> References: <4A9F1159.5010303@cs.utah.edu> <4A9F1288.20508@ccs.neu.edu> Message-ID: <4A9F43F3.8070205@cs.utah.edu> Ryan Culpepper wrote: > Jon Rafkind wrote: >> I was trying to match a single symbol but I didn't see a match >> pattern for it. This code seems to do what I want >> >> (define (match-symbol sym) >> (match sym >> [x (=> f) (if (not (symbol? x)) (f) 'ok)] >> [else 'bad])) > > (define (match-symbol sym) > (match sym > [(? symbol?) 'ok] > [_ 'bad])) > Ah right, good call. It seems like predicates could be used for other literals too, like char?, string?, etc. So is there a good reason for the current set of literals that can be used in a pattern? From carl.eastlund at gmail.com Thu Sep 3 00:26:10 2009 From: carl.eastlund at gmail.com (Carl Eastlund) Date: Thu Sep 3 00:26:48 2009 Subject: [plt-scheme] match single symbol In-Reply-To: <4A9F43F3.8070205@cs.utah.edu> References: <4A9F1159.5010303@cs.utah.edu> <4A9F1288.20508@ccs.neu.edu> <4A9F43F3.8070205@cs.utah.edu> Message-ID: <990e0c030909022126x3e706b01of002ecad15807c84@mail.gmail.com> On Thu, Sep 3, 2009 at 12:20 AM, Jon Rafkind wrote: > Ryan Culpepper wrote: >> >> Jon Rafkind wrote: >>> >>> I was trying to match a single symbol but I didn't see a match pattern >>> for it. This code seems to do what I want >>> >>> (define (match-symbol sym) >>> ?(match sym >>> ? [x (=> f) (if (not (symbol? x)) (f) 'ok)] >>> ? [else 'bad])) >> >> (define (match-symbol sym) >> ?(match sym >> ? ?[(? symbol?) 'ok] >> ? ?[_ 'bad])) >> > Ah right, good call. It seems like predicates could be used for other > literals too, like char?, string?, etc. So is there a good reason for the > current set of literals that can be used in a pattern? What have literals (which compare against a single value) got to do with predicates (which often match a whole class of values)? --Carl From sshickey at qwest.net Thu Sep 3 00:26:51 2009 From: sshickey at qwest.net (Scott Hickey) Date: Thu Sep 3 00:27:12 2009 Subject: [plt-scheme] programmaticly change display of rationals Message-ID: <819474.70454.qm@web62507.mail.re1.yahoo.com> In DrScheme, right clicking on a rational gives three options: * view decimal expansion * view as mixed fraction * view as improper fraction I know the function (read-decimal-as-inexact #f) will let me type rationals such as 1.1. Is there function like that for displaying them as well. I'd like (* 1.1 0.1) to display as 0.11 instead of 11/100 by default. Scott Hickey Senior Consultant Object Partners, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090902/eaaac24a/attachment.html From rafkind at cs.utah.edu Thu Sep 3 00:28:03 2009 From: rafkind at cs.utah.edu (Jon Rafkind) Date: Thu Sep 3 00:30:06 2009 Subject: [plt-scheme] match single symbol In-Reply-To: <990e0c030909022126x3e706b01of002ecad15807c84@mail.gmail.com> References: <4A9F1159.5010303@cs.utah.edu> <4A9F1288.20508@ccs.neu.edu> <4A9F43F3.8070205@cs.utah.edu> <990e0c030909022126x3e706b01of002ecad15807c84@mail.gmail.com> Message-ID: <4A9F45D3.4050105@cs.utah.edu> > What have literals (which compare against a single value) got to do > with predicates (which often match a whole class of values)? > > --Carl > Er yea, sorry I was totally confused for a second. I'll just write my own matchers with define-match-expander. From samth at ccs.neu.edu Thu Sep 3 03:47:04 2009 From: samth at ccs.neu.edu (Sam TH) Date: Thu Sep 3 03:53:05 2009 Subject: [plt-scheme] match single symbol In-Reply-To: <4A9F45D3.4050105@cs.utah.edu> References: <4A9F1159.5010303@cs.utah.edu> <4A9F1288.20508@ccs.neu.edu> <4A9F43F3.8070205@cs.utah.edu> <990e0c030909022126x3e706b01of002ecad15807c84@mail.gmail.com> <4A9F45D3.4050105@cs.utah.edu> Message-ID: <63bb19ae0909030047t30e3429o5485f50bd35ab8c@mail.gmail.com> On Thu, Sep 3, 2009 at 12:28 AM, Jon Rafkind wrote: > >> What have literals (which compare against a single value) got to do >> with predicates (which often match a whole class of values)? >> >> --Carl >> > > Er yea, sorry I was totally confused for a second. I'll just write my own > matchers with define-match-expander. For literals, 'foo, 7, "hello", and such all work fine. What doesn't exist at the moment that you need? -- sam th samth@ccs.neu.edu From robby at eecs.northwestern.edu Thu Sep 3 06:06:21 2009 From: robby at eecs.northwestern.edu (Robby Findler) Date: Thu Sep 3 06:06:43 2009 Subject: [plt-scheme] programmaticly change display of rationals In-Reply-To: <819474.70454.qm@web62507.mail.re1.yahoo.com> References: <819474.70454.qm@web62507.mail.re1.yahoo.com> Message-ID: <932b2f1f0909030306w4299d771tef38a45cbf480e58@mail.gmail.com> DrScheme should have remembered your most recent choice in the preferences system, but it wasn't doing that right for the fraction style. I've committed a fix in SVN for that just now. Robby On Wed, Sep 2, 2009 at 11:26 PM, Scott Hickey wrote: > In DrScheme, right clicking on a rational gives three options: > > * view decimal expansion > * view as mixed fraction > * view as improper fraction > > I know the function (read-decimal-as-inexact #f) will let me type rationals > such as 1.1. Is there function like that for displaying them as well. > > I'd like (* 1.1 0.1) to display as 0.11 instead of 11/100 by default. > > Scott Hickey > Senior Consultant > Object Partners, Inc. > > _________________________________________________ > ?For list-related administrative tasks: > ?http://list.cs.brown.edu/mailman/listinfo/plt-scheme > > From plt-scheme at dirichs.fastmail.fm Thu Sep 3 06:20:35 2009 From: plt-scheme at dirichs.fastmail.fm (Martin Dirichs) Date: Thu Sep 3 06:50:23 2009 Subject: [plt-scheme] Large file support in PLT Scheme Message-ID: Hello, does PLT Scheme allow handling of large files >2GiB on 32bit systems? I am using a manually compiled 4.2.1-version under Linux and noticed that while large files are no problem with 64bit Linux, operating with those file under 32bit Linux doesn't work. Trying to recompile with gcc compiler flag -D_FILE_OFFSET_BITS=64 seems to make no difference. For example, (file-size "large-file") results in file not found error, (file-exists? "large-file") yields #f, (fold-files ...) reports "path disappeared". Is there a way to enable large file support for 32bit systems? Regards, Martin Dirichs. From erich at snafu.de Thu Sep 3 08:09:19 2009 From: erich at snafu.de (Erich Rast) Date: Thu Sep 3 08:09:25 2009 Subject: [plt-scheme] Re: Lexical Scoping, References and Side Effects In-Reply-To: References: <6af48c6b-39dc-4003-9da6-4bbb6582f299@j9g2000vbp.googlegroups.com> <14E667FC-CA96-4DD8-9C66-05E153BE715E@ccs.neu.edu> <2194d865-51a9-4c70-8254-75de06869d9b@v36g2000yqv.googlegroups.com> <64FA9158-54B7-42E2-9F7F-6EBFE2E9BA7D@MIT.EDU> Message-ID: <1251979759.8422.10.camel@darkstar> > Like I said, I'm > just getting into Scheme and I'm pretty green. Take a look at this version: (define make-stack (lambda () (let ((li null)) (lambda (selector . rest) (case selector ((push!) (set! li (append rest li))) ((pop!) (begin0 (car li) (set! li (cdr li)))) ((empty?) (empty? li)) (else (error 'stack "unknown function '~s'" selector))))))) (define a (make-stack)) (a 'push! 10 20 30) (a 'pop!) ==> 10 (a 'pop!) ==> 20 You probably shouldn't use these kind of self-made object systems in real life but it's good if you understand how the above example works. Best, Erich From rafkind at cs.utah.edu Thu Sep 3 11:58:07 2009 From: rafkind at cs.utah.edu (Jon Rafkind) Date: Thu Sep 3 12:00:23 2009 Subject: [plt-scheme] match single symbol In-Reply-To: <63bb19ae0909030047t30e3429o5485f50bd35ab8c@mail.gmail.com> References: <4A9F1159.5010303@cs.utah.edu> <4A9F1288.20508@ccs.neu.edu> <4A9F43F3.8070205@cs.utah.edu> <990e0c030909022126x3e706b01of002ecad15807c84@mail.gmail.com> <4A9F45D3.4050105@cs.utah.edu> <63bb19ae0909030047t30e3429o5485f50bd35ab8c@mail.gmail.com> Message-ID: <4A9FE78F.8090501@cs.utah.edu> Sam TH wrote: > On Thu, Sep 3, 2009 at 12:28 AM, Jon Rafkind wrote: > >>> What have literals (which compare against a single value) got to do >>> with predicates (which often match a whole class of values)? >>> >>> --Carl >>> >>> >> Er yea, sorry I was totally confused for a second. I'll just write my own >> matchers with define-match-expander. >> > > For literals, 'foo, 7, "hello", and such all work fine. What doesn't > exist at the moment that you need? > > I need to match any single symbol and got momentarily confused about the literal patterns. I thought there was a pattern for matching any string, but its just a literal string. This is essentially what I need: (define-match-expander symbol (lambda (stx) #'(? symbol?))) (match 'x [symbol 'ok] [else 'bad]) From carl.eastlund at gmail.com Thu Sep 3 12:03:17 2009 From: carl.eastlund at gmail.com (Carl Eastlund) Date: Thu Sep 3 12:04:01 2009 Subject: [plt-scheme] match single symbol In-Reply-To: <4A9FE78F.8090501@cs.utah.edu> References: <4A9F1159.5010303@cs.utah.edu> <4A9F1288.20508@ccs.neu.edu> <4A9F43F3.8070205@cs.utah.edu> <990e0c030909022126x3e706b01of002ecad15807c84@mail.gmail.com> <4A9F45D3.4050105@cs.utah.edu> <63bb19ae0909030047t30e3429o5485f50bd35ab8c@mail.gmail.com> <4A9FE78F.8090501@cs.utah.edu> Message-ID: <990e0c030909030903k3299a60ey5661a59088f6d769@mail.gmail.com> On Thu, Sep 3, 2009 at 11:58 AM, Jon Rafkind wrote: > > I need to match any single symbol and got momentarily confused about the > literal patterns. I thought there was a pattern for matching any string, but > its just a literal string. > > This is essentially what I need: > > (define-match-expander symbol (lambda (stx) #'(? symbol?))) > > (match 'x > ? ? ?[symbol 'ok] > ? ? ?[else 'bad]) Bear in mind you will have to use (symbol), not symbol, to refer to that pattern. If you just use an unadorned identifier, match will treat it as a variable, treat it as a match against any value, and bind it to that value in the right hand side. All custom patterns must have the form of macro applications with parentheses. Honestly, for this case, you're probably best off just using (? symbol?) for uniformity with every other match-using program out there. It's only 3 extra characters beyond (symbol). But that's just my opinion. --Carl From rafkind at cs.utah.edu Thu Sep 3 13:09:06 2009 From: rafkind at cs.utah.edu (Jon Rafkind) Date: Thu Sep 3 13:11:12 2009 Subject: [plt-scheme] generators with sequences In-Reply-To: <932b2f1f0908271630s279dd33dh2a5541e058b6f6ed@mail.gmail.com> References: <4A94C836.7090608@cs.utah.edu> <31441A25-7C63-49FB-AED2-48967B201F7F@ccs.neu.edu> <932b2f1f0908271630s279dd33dh2a5541e058b6f6ed@mail.gmail.com> Message-ID: <4A9FF832.5020100@cs.utah.edu> Robby Findler wrote: > One other thought: did your explorations with the call/cc variant > suggest ways that Ruby might be broken? Did you try to confirm that? > It may shed some light on the Scheme version. > > Initially I was inspired by python but I tested Ruby and Python and found them both to be ok. It doesn't seem possible in either language to capture a generator's yield function and call it in a separate place. Of course this also means you can't call yield from a helper function and have it do what you expect (pointed out to me by a few people). From plt at synx.us.to Thu Sep 3 15:29:45 2009 From: plt at synx.us.to (Synx) Date: Thu Sep 3 15:30:28 2009 Subject: [plt-scheme] Can't make any executables Message-ID: <4AA01929.7050409@synx.us.to> $ mz ./something.ss OK MAN $ mzc --exe ./something ./something.ss $ ./something cdddr: expects argument of type ; given ("synx" "log.ss") I have (require (planet synx/log)) somewhere in the source of course. From sbloch at adelphi.edu Thu Sep 3 15:33:00 2009 From: sbloch at adelphi.edu (Stephen Bloch) Date: Thu Sep 3 15:33:00 2009 Subject: [plt-scheme] Test the Program In-Reply-To: <4A9ED51F.6080405@cs.utah.edu> References: <952A68B66688454D8590CDA397C966D10131A8CD0C29@EX1.Campus.mnsu.edu> <4A9ED2FF.4050704@cs.utah.edu> <4A9ED51F.6080405@cs.utah.edu> Message-ID: >> Asher, Gregg wrote: >>> When I define a program in the definitions window and then enter >>> the program name in the interactive window substituting a value >>> for the parameter and then "Run" (my version of Dr. Scheme >>> doesn't have an "Execute" button) the program I don't the results >>> of the program but a message "This program should be tested. You've gotten several different correct answers to this, each addressing a different aspect of what's going on. Let me try to put them all together in context. 1) You're not seeing the results of the expression you typed in the Interactions pane. This is because you hit "Run" . The "Run" button starts by throwing away everything in the Interactions pane, then evaluating everything in the Definitions pane. To solve this, type an expression in Interactions and then just hit the "Enter" or "Return" key on your keyboard rather than clicking the "Run" button. (However, whenever you change languages, change language preferences, add or remove a teachpack, or edit anything in the Definitions pane, you'll need to click the "Run" button in order for it to take effect.) 2) You're getting a message that says "This program should be tested." This happens when you "Run" a Definitions pane that doesn't contain any test cases written with "check-expect" (or its friends). To solve this, write test cases in the Definitions pane, preferably for each function you define. For example, the Definitions pane might look like this: ; area-of-disk : number(radius) -> number (check-expect (area-of-disk 0) 0) (check-within (area-of-disk 1) 3.14 .01) ; the third parameter is a "close enough" criterion, since this function does inexact computations (check-within (area-of-disk 2) 12.56 .01) (define (area-of-disk radius) (* pi radius radius)) ; cube : number -> number (define (cube num) (* num num num)) (check-expect (cube 0) 0) (check-expect (cube 4) 64) (check-expect (cube -5) -125) Note that "check-expect", "check-within", etc. can appear either before or after the definition of the function they're supposed to test; you can decide for yourself which fits your pedagogical style better. The advantage of "before the definition" is that students can follow the design recipe without "backing up" in the Definitions pane: contract, test cases, skeleton becoming a definition. From sk at cs.brown.edu Thu Sep 3 16:29:03 2009 From: sk at cs.brown.edu (Shriram Krishnamurthi) Date: Thu Sep 3 16:36:58 2009 Subject: [plt-scheme] mis-behavior Message-ID: Continental has a new in-flight entertainment system. When listening to music, at the top-right it has a little display saying "Time to destination: