- The most complete reference I can find for the
2htdplanguage is [here][htdp2ereference]. - The tips outlined here will not result in files that can be submitted for the peer-assessment assignments
- See [here][assessments] for details.
- In the
racketrepl, by default named* Racket REPL *, you can use,enter lang/htdp-beginnerto put it into the restrictedhtdp-beginnerlanguage mode. (NOTE: I'm not yet sure if this refers to the first or second edition of HtDP BSL.) (NOTE: This doesn't really give you all the restrictions)- Alternatively, use
M-: (switch-to-geiser-module "lang/htdp-beginner") RETto havegeiserdo it for you. - This will allow you to play around within the BSL; be aware that this means a lot of functions will not be available.
- Use this as an opportunity to see what is actually provided by BSL, in combination with the [BSL language reference][htdp2ereference].
- Alternatively, use
- Make the first line of your program script this:
#lang htdp/bsl- This sets the top-level module as
htdp/bslwhich is the language we are working with. This is not necessary when working withdrracketbecause we chose the language for our programs interactively with the user interface.
- This sets the top-level module as
[htdp2ereference]: http://docs.racket-lang.org/htdp-langs/beginner.html "HtDP/2e language reference" [assessments]: https://class.coursera.org/programdesign-002/forum/thread?thread_id=58#comment-145 "Details about requirements for submissions"
- As of yet, I have not found a way to enable test messages; you can see what I mean [here][testmessages].
- Solution: Near the top of your script, put
(require test-engine/racket-tests). At the end of your script, put(test).- To evaluate the script in
geiser, save it with C-x C-s, then press C-c C-a. You must save the file every time. - You will see the
racketrepl prompt change to include the name of your script file; this shouldn't be a problem, and in fact could be considered a blessing! This means that further invocations within the repl will occur within the exact same context as your actual script, meaning you can test functions there and then copy them freely to the "Definitions area" (asdrracketcalls it), aka the buffer storing your script.
- To evaluate the script in
- Solution: Near the top of your script, put
- Making
htdp/bslthe top-level module really does restrict the environment from everything thatdrracketprovides. This will be a learning process to figure out what modules we need torequirefor our scripts. I don't view this as a downside, necessarily, because discovering modules and libraries is an important aspect of programming known as code reuse, but your mileage may vary.- Solution:
requirethe necessary libraries or modules in your script file.- Putting
(require math)in my script enabled functions such assqragain.
- Putting
- NOTE: the
htdp/bslnamespace does not impose restrictions on list abbreviations, demonstrated [here][listabbrevs]
- Solution:
[testmessages]: https://class.coursera.org/programdesign-002/forum/thread?thread_id=58#comment-118 "Christopher D. Walborn's post demonstrating the output from DrRacket after evaluating a test" [listabbrevs]: https://class.coursera.org/programdesign-002/forum/thread?thread_id=58#post-248 "Expected results when list abbreviations are not in use"
- As of yet, I have not found a way to emulate the
stepperthat we will be using. I've found references to amacrostepperin variousgeiserdocs, but I haven't tried it out yet, and I'm afraid it refers to macros themselves.- It's common in
schemeand other various Lisps tomacroexpandamacroin order to see the procedures it would generate when used live. Macros are not only beyond the scope of this course (I suspect, anyway), but they are also one of those concepts that are difficult to initially grasp and even harder to master. - It appears to me that the
stepperindrracketis exclusive to thehtdpstudent-language family, and more disheartening, to the GUI itself; there seems to be no implementation beyond that.- The
stepperwould be available (rather trivially) from the commandline repl if a generic interface for it was designed, which the GUI implementation could then wrap up inside its click-button oriented interface. Unfortunately, the stepper was designed explicitly and solely for use only fromdrracket.- I've got an itch to scratch, here, so will be trying to redesign the backend implementation with a generic
interface sometime after I grasp
racket. For now, all we can do is launch our programs indrracketinstead, step through them, and see the results.
- I've got an itch to scratch, here, so will be trying to redesign the backend implementation with a generic
interface sometime after I grasp
- The
- The [racket/trace][rackettrace] library may stand in for this; the catch is that it is not interactive, and it cannot step backwards through an execution. Further evaluation is required before I can tag this as an actual Solution.
- This [errortrace][errortrace] library may come even closer.
- It's common in
- There is a discrepancy between
htpd-beginnerandhtpd/bslthat I have not worked out yet; I can't tell if they are functionally equivalent, or if one refers to HtPD2e and the other to the original HtPD version. - Emacs doesn't appear to support Comment Boxes like the one used in
pythag-starter.rktor the homework files to display examples and assignment questions.- I am trying to see if these can be exported or converted to regular images or text/ascii (or a combination).
- This is WXME-format data.
racketprovides a library for encoding and decoding these files.
[rackettrace]: http://docs.racket-lang.org/reference/debugging.html "Execution tracing library for racket" [errortrace]: http://docs.racket-lang.org/errortrace/ "more powerful ErrorTrace library for Racket"