[racket-users] Re: A (long) question regarding parameters and scope
Parameters don't keep their values across threads, and since the plot library needs to re-draw the plot when it is rotated or zoomed, it saves parameters for later use in a different thread, where the drawing actually happpens. There is an explicit list of parameters that are saved and restored, they are listed in https://github.com/racket/plot/blob/8dcfd7745e2595b8d517fd8cd7c59510efab84a9/plot-lib/plot/private/common/parameter-groups.rkt Could you post some code illustrating what you are trying to do and does not work? Alex. On Thursday, August 2, 2018 at 10:58:35 AM UTC+8, Carlos Lopez wrote: > > Hello Racket friends, > > I was playing with the plot module (which is very nice, btw) and > discovered that the parameter plot-decorations? is ignored when plotting to > a new window. > > The file plot3d.rkt (plot\plot-gui-lib\plot\private\gui) is where > plot-new-window? makes a distinction of the cases and this is where I got > rather confused. > > Inside plot3d.rkt, the function plot3d-snip has an internal helper > function make-bm, preceded by curious step that stores the values of the > plot-parameters in a variable that the helper function then uses to recall > them. This is the gist of it: > > (define (plot3d-snip renderer-tree ...) > ... > > (parameterize ([plot-title title] > ...) > (define saved-plot-parameters (plot-parameters)) ; <- store parameters > ... > > (define (make-bm anim? ...) > (parameterize/group ([plot-parameters saved-plot-parameters] ; <- > recall parameters, why? >...) > ...)) > ...) > > > The function for plotting into a frame did not have such a step but has > the same structure with make-snip as the helper function so I added the > store/recall step, and with it, plot does respect the value of the > parameter. > > (define (plot3d-frame renderer-tree ...) > ... > > (define saved-plot-parameters (plot-parameters)) ; <- store parameters > > (define (make-snip width height) > (parameterize/group ([plot-parameters saved-plot-parameters]) ;<- > recall parameters > (plot3d-snip renderer-tree ...)) > ) > > A quick printf also showed that the parameters have a different value > between the outside and the inside of the helper functions. > > Now, this behavior is expected, otherwise the solution would not have been > present in the same file; my question is why is it behaving this way? how > is the helper function seeing the value of the parameter from the initial > definition and not the one being set before invoking plot3d? > > To add to my confusion, I made this simple test in which I tried to copy > the previous behavior, and it behaves as I expect, but differently to the > plot3d case. > > #lang racket > > (module m racket > (provide (all-defined-out)) > > (define test-param (make-parameter #t)) > > (define (f) > (define (g) > (test-param)) > (g))) > > (require 'm) > > (f) > > (test-param #f) > > (f) > - > #t > #f > > Thanks for reaching the end of this long question :) > > Carlos > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] A (long) question regarding parameters and scope
Hello Racket friends, I was playing with the plot module (which is very nice, btw) and discovered that the parameter plot-decorations? is ignored when plotting to a new window. The file plot3d.rkt (plot\plot-gui-lib\plot\private\gui) is where plot-new-window? makes a distinction of the cases and this is where I got rather confused. Inside plot3d.rkt, the function plot3d-snip has an internal helper function make-bm, preceded by curious step that stores the values of the plot-parameters in a variable that the helper function then uses to recall them. This is the gist of it: (define (plot3d-snip renderer-tree ...) ... (parameterize ([plot-title title] ...) (define saved-plot-parameters (plot-parameters)) ; <- store parameters ... (define (make-bm anim? ...) (parameterize/group ([plot-parameters saved-plot-parameters] ; <- recall parameters, why? ...) ...)) ...) The function for plotting into a frame did not have such a step but has the same structure with make-snip as the helper function so I added the store/recall step, and with it, plot does respect the value of the parameter. (define (plot3d-frame renderer-tree ...) ... (define saved-plot-parameters (plot-parameters)) ; <- store parameters (define (make-snip width height) (parameterize/group ([plot-parameters saved-plot-parameters]) ;<- recall parameters (plot3d-snip renderer-tree ...)) ) A quick printf also showed that the parameters have a different value between the outside and the inside of the helper functions. Now, this behavior is expected, otherwise the solution would not have been present in the same file; my question is why is it behaving this way? how is the helper function seeing the value of the parameter from the initial definition and not the one being set before invoking plot3d? To add to my confusion, I made this simple test in which I tried to copy the previous behavior, and it behaves as I expect, but differently to the plot3d case. #lang racket (module m racket (provide (all-defined-out)) (define test-param (make-parameter #t)) (define (f) (define (g) (test-param)) (g))) (require 'm) (f) (test-param #f) (f) - #t #f Thanks for reaching the end of this long question :) Carlos -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
RE: [racket-users] How is define-values defined?
Matthias, Thanks, for the pointer. I am studying the article, which at first look seems very well readable. I did not mean to 'propose' my odd idea. Jos -Original Message- From: Matthias Felleisen [mailto:matth...@felleisen.org] Sent: 01 August 2018 16:26 To: Jos Koot Cc: Racket Users Subject: Re: [racket-users] How is define-values defined? > On Jul 31, 2018, at 2:17 PM, Jos Koot wrote: > > It even is possible to implement a multiple value as a single value such as > to allow: > > (define x (values 1 2 3)) > (define-values (a b c) x) > (call-with-values (lambda () x) list) > > Somewhere I must have an interpreter that allows this, > but for the moment I can't find it without long searching. > IIRC it is/was a very odd (and probably bad) interpreter. I don't think this proposal denotes. The 'values' idea is to deal with several values in parallel. The 'define x' idea is that x is bound to a single value. ;; - - - I don't know too many publications about the implementation of 'values'. The one I'd always start with is Ashley and Dybvig's: https://www.cs.indiana.edu/~dyb/pubs/mrvs.pdf For CL, I'd look in CL2. - Matthias -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] difficult to package library
> I want to package my library for https://pkgs.racket-lang.org but I can't > figure out how to do the info.rkt file. > > I would like my repo to be like this: > > * repo/peg/codehere.rkt like main.rkt peg.rkt etc. > * repo/tests/ my tests > * repo/scribblings/peg.scrbl the documentation > > is this directory structure OK? That structure is OK if you have a `repo/info.rkt` file that points to the documentation. You'll probably also want a file `repo/main.rkt` to reprovide things from `repo/peg/main.rkt`, because `(require peg)` will import the `repo/main.rkt` file. To import `repo/peg/main.rkt`, a user needs to write `(require peg/peg/main)`. > I have not been able to make it work so I have moved everything from > repo/peg/ into repo/. but I am getting "dependency problems" and > documentation is not built: > http://pkg-build.racket-lang.org/server/built/deps/peg.txt > > I can't figure out how to make the correct info.rkt file either way, and it > is difficult to test because I have to update the pkgs page and wait. So > some advice would be very helpful. Running `raco setup --check-pkg-deps peg` will check that the: - `info.rkt` file makes sense - code compiles - documentation renders - dependencies are correct There's also a `--fix-pkg-deps` flag that will edit your info.rkt -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] You Are a Programmer Now HtDP2e
The idea that we need to deal with software systems as if we were natural scientists shows up time and again. Gerry is correct about this but this does not mean we should not teach good attitudes about code and coding etc. ;; - - - As far as I am concerned, SiCP never served the purpose that Gerry advertises in his quote. Let me start out by praising SiCP first: it is one of those introductory texts that does not belong to the 99.99% of the syntax-focused pile of XXX. Having said that, I also don’t think that SiCP teaches (or 6.001 taught) programming or sw dev. SiCP presents important ideas in computer science, sketched out in Scheme, the way you sketch out your dream house to an architect on a napkin. (Well perhaps more than a napkin.) As such, it was doomed to fail as a “programming text”. HtDP explicitly teaches systematic program design. This means two things: — its goal is to teach systematic program design — and it does so by explicitly spelling out how to go about program design. All of this is spelled out in some detail in https://www2.ccs.neu.edu/racket/pubs/#jfp2004-fffk ;; - - - One semester does not make good coders and does not generate good attitudes about code. I have therefore created a core curriculum of five courses at Northeastern that reinforce this lesson again and again. The goal is to get students to see that, if code survives, the cost of code is distributed over a long period of time. They will rotate into positions where they take on someone else’s code — possibly their own from N months or years ago — and that when they create code, they owe the future developers “well designed code.” How to go from a blank page and a bunch of APIs to well-designed code isn’t a solved problem, so creating this curriculum was and remains research — it’s just that nobody recognizes that this is a central open problem for CS. So I dress up my research results as text books. The details of this curriculum development are spelled out in http://felleisen.org/matthias/Thoughts/Developing_Developers.html >From what I can tell, the curriculum is a success story — though possibly I am >a victim of confirmation bias here, like many scientists. So let me say what I >see: — our co-op department routinely reports that our students are considered some of the best student-developers by (large) sw companies (our co-op department isn’t all that good about tracking our co-op students in small or midsize companies) — students routinely tell me that they get through co-op interviews by falling back on the design recipe when they encounter hard questions — they also tell me that they get credit when they work with the design recipe during co-op (even if things don’t work out) — they report praise for developing good code. For all I know though, all those who don’t report to me (or aren’t covered by our co-op reports) produce the same kind of bad code that all other devs develop :-) ;; - - - Here is what’s missing. In a world where APIs are like hardware (proprietary, opaque) we need to teach students how to study such APIs and how to extract useful knowledge from these APIs. Again, most schools who switch to this new MIT approach don’t teach this explicitly. They do not provide students with the intellectual tools that help them discover the meaning of an API. I will also admit that I am _not_ tackling this question. As far as I know Shriram Krishnamurthi is the only one who is aware of and working on this question for API = PL. (See his PLAI v2.0 course at Brown.) ;; - - - So in the meantime, I am happy to teach our students systematic design and instill a message of “code quality matters”. I think it helps them get started in many cases. When someone figures out how to deliver the tools of “programming/sw dev is partly a natural science” to students, then I* will be able to combine “systematic design” with “API modeling” approaches and we will produce the best devs ever. Your milage will vary, but I won’t give up on teaching good programming well — Matthias -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] You Are a Programmer Now HtDP2e
(Actually, I bought the book and was just working through the Prologue today. And didn't turn the page, it appears. ) Thank you for your response. More specifically, what I was referring to was a response that has gotten a fair bit of circulation given by Gerry Sussman when asked why SICP was no longer taught by him at MIT. You can read more about this here: http://lambda-the-ultimate.org/node/5335 Personally, I have tried to learn programming (self-teaching) via how, as you state, 99.9% of texts teach it - syntax and hacking first, and I have just about given up. I find it pure torture (and I found working through the Prologue torture, but was expecting that since I believe that was your point). Hence, I purchased your book (2e) and also SICP. However, since finding that quote by Sussman I feel more lost than ever. He seems to be stating that what made SICP so relevant 20 to 30 years ago has gone. So it is great I have an author of HtDP in this thread! I understand programming by poking as the process of researching APIs and hacking together libraries until something works, similar in essence I think to the Prologue of HtDP. And perhaps this hacking and sewing together and ensuing code bloat is aided by ever expanding hardware capacities in storage and speed, I don't know. So, Matthias, if you are still there, how do you understand Sussman's reasoning for quitting SICP (other than he was bored with it)? Is he right? How does HtDP stand up in the face of Sussman's perspective? Does one need the lessons of HtDP if all one is doing is stitching together libraries and APIs? On Wednesday, August 1, 2018 at 3:43:59 PM UTC-4, Matthias Felleisen wrote: > > > > On Aug 1, 2018, at 2:52 PM, Scott > > wrote: > > > > The end of the Prologue to HtDP2e ends with a section titled You Are a > Programmer Now. If you have read it you know what it contains (if you > haven't read it then you are not likely able to respond intelligently to > this question). > > > This is incorrect. The Prologue ends with “Not!”. See > > https://htdp.org/2018-01-06/Book/part_prologue.html > > > > My question is: in that section are the authors describing "programming > by poking”? > > > Yes. The Prologue describes how 99.99% of the text books teach programming > to contrast it with “good programming” as taught by HtDP. > > — Matthias > > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] You Are a Programmer Now HtDP2e
> On Aug 1, 2018, at 2:52 PM, Scott wrote: > > The end of the Prologue to HtDP2e ends with a section titled You Are a > Programmer Now. If you have read it you know what it contains (if you haven't > read it then you are not likely able to respond intelligently to this > question). This is incorrect. The Prologue ends with “Not!”. See https://htdp.org/2018-01-06/Book/part_prologue.html > My question is: in that section are the authors describing "programming by > poking”? Yes. The Prologue describes how 99.99% of the text books teach programming to contrast it with “good programming” as taught by HtDP. — Matthias -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Some Scribble links not redirecting to docs.racket-lang.org
On Wednesday, August 1, 2018 at 8:15:58 AM UTC-5, Matthew Flatt wrote: > > Are the other packages installed in installation scope or user scope? > That was indeed the problem. I was able to find out the installed packages’ scope through the Package Manager in DrRacket. Removing the packages, changing the default scope from user to installation, and reinstalling then fixed the problem. It looks like I can't migrate packages from older versions of Racket when they aren’t in user scope, which is sad. But that isn’t often needed, and I’ll probably be sticking with 6.12 for a while anyway. Thanks! -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] You Are a Programmer Now HtDP2e
The end of the Prologue to HtDP2e ends with a section titled You Are a Programmer Now. If you have read it you know what it contains (if you haven't read it then you are not likely able to respond intelligently to this question). My question is: in that section are the authors describing "programming by poking"? -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] difficult to package library
Hi. I want to package my library for https://pkgs.racket-lang.org but I can't figure out how to do the info.rkt file. I would like my repo to be like this: * repo/peg/codehere.rkt like main.rkt peg.rkt etc. * repo/tests/ my tests * repo/scribblings/peg.scrbl the documentation is this directory structure OK? I have not been able to make it work so I have moved everything from repo/peg/ into repo/. but I am getting "dependency problems" and documentation is not built: http://pkg-build.racket-lang.org/server/built/deps/peg.txt I can't figure out how to make the correct info.rkt file either way, and it is difficult to test because I have to update the pkgs page and wait. So some advice would be very helpful. Thanks. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.