Skip to content

Instantly share code, notes, and snippets.

@zendeavor
Created September 6, 2013 06:27
Show Gist options
  • Save zendeavor/6460219 to your computer and use it in GitHub Desktop.
Save zendeavor/6460219 to your computer and use it in GitHub Desktop.

Troubleshooting

  • The most complete reference I can find for the 2htdp language 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 racket repl, by default named * Racket REPL *, you can use ,enter lang/htdp-beginner to put it into the restricted htdp-beginner language 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") RET to have geiser do 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].
  • Make the first line of your program script this: #lang htdp/bsl
    • This sets the top-level module as htdp/bsl which is the language we are working with. This is not necessary when working with drracket because we chose the language for our programs interactively with the user interface.

[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"

Solved Problems

  • 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 racket repl 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" (as drracket calls it), aka the buffer storing your script.
  • Making htdp/bsl the top-level module really does restrict the environment from everything that drracket provides. This will be a learning process to figure out what modules we need to require for 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: require the necessary libraries or modules in your script file.
      • Putting (require math) in my script enabled functions such as sqr again.
    • NOTE: the htdp/bsl namespace does not impose restrictions on list abbreviations, demonstrated [here][listabbrevs]

[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"

Unsolved Problems

  • As of yet, I have not found a way to emulate the stepper that we will be using. I've found references to a macrostepper in various geiser docs, but I haven't tried it out yet, and I'm afraid it refers to macros themselves.
    • It's common in scheme and other various Lisps to macroexpand a macro in 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 stepper in drracket is exclusive to the htdp student-language family, and more disheartening, to the GUI itself; there seems to be no implementation beyond that.
      • The stepper would 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 from drracket.
        • 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 in drracket instead, step through them, and see the results.
    • 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.
  • There is a discrepancy between htpd-beginner and htpd/bsl that 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.rkt or 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. racket provides 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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment