Coder Social home page Coder Social logo

htdp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

htdp's Issues

Need better error messages for ridiculous font sizes

On the v6.6 release,

if I try to make the font size negative using ctrl+-, I get the message:

editor:set-current-preferred-font-size: contract violation
  expected: exact-nonnegative-integer?
  given: -1
  in: the 1st argument of
      (-> exact-nonnegative-integer? void?)
  contract from: 
      <pkgs>/gui-lib/framework/main.rkt
  blaming: <pkgs>/drracket/drracket/private/unit.rkt
   (assuming the contract is correct)
  at: <pkgs>/gui-lib/framework/main.rkt:1556.2
  context...:
   /Applications/Racket v6.6/collects/racket/contract/private/blame.rkt:159:0: raise-blame-error16
   /Applications/Racket v6.6/collects/racket/contract/private/arrow-val-first.rkt:357:18
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:736:2: core502
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:508:2: chain-handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:496:4: for-loop
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:508:2: chain-handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:496:4: for-loop
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:508:2: chain-handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:459:2: handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxmenu.rkt:54:22
   /Applications/Racket v6.6/collects/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   /Applications/Racket v6.6/collects/ffi/unsafe/atomic.rkt:72:13
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/mrtop.rkt:182:24: on-subwindow-char method in frame%
   /Applications/Racket v6.6/collects/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   /Applications/Racket v6.6/collects/ffi/unsafe/atomic.rkt:72:13
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wx/cocoa/window.rkt:821:4: call-pre-on-char method in window%
   ...

and if I try to go very very positive, I get a different error:

preferences:set: new value doesn't satisfy preferences:set-default predicate
  pref sym: 'framework:standard-style-list:font-size
  given: '#(#hash((((1366 745) (2556 1417)) . 24) (((1362 745)) . 256)) 256)
  predicate: (vector/c (hash/c (non-empty-listof (list/c exact-nonnegative-integer? exact-nonnegative-integer?)) (integer-in 0 255) #:flat? #t) (integer-in 0 255) #:flat? #t)
  context...:
   /Applications/Racket v6.6/share/pkgs/gui-lib/framework/preferences.rkt:137:6
   /Applications/Racket v6.6/collects/racket/private/map.rkt:47:13: for-each
   /Applications/Racket v6.6/share/pkgs/gui-lib/framework/preferences.rkt:135:3
   /Applications/Racket v6.6/collects/racket/contract/private/arrow-val-first.rkt:357:18
   /Applications/Racket v6.6/collects/racket/contract/private/arrow-val-first.rkt:357:18
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:736:2: core502
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:508:2: chain-handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:496:4: for-loop
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:508:2: chain-handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:496:4: for-loop
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:508:2: chain-handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxme/keymap.rkt:459:2: handle-key-event method in keymap%
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/wxmenu.rkt:54:22
   /Applications/Racket v6.6/collects/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   /Applications/Racket v6.6/collects/ffi/unsafe/atomic.rkt:72:13
   /Applications/Racket v6.6/share/pkgs/gui-lib/mred/private/mrtop.rkt:182:24: on-subwindow-char method in frame%
   ...

I would prefer these gave shorter error messages & did not print to stderr (stderr prints always confuse the Windows students).

Stepper doesn't respect Color Schemes

I have a visually-impaired student who needs to use the high-contrast color scheme. The White on Black scheme works great for this. Unfortunately, the Stepper doesn't respect this preference:

image

Inconsistent signatures for varaiable arity HOFs in ISL (and above)

There are some inconsistencies with the signatures given for HOFs with variable arity in ISL (and above). For example:

(andmap p? [l]) → boolean
p? : (X ... -> boolean)
l : (listof X) = ...

(ormap p? l) → boolean
p? : (X -> boolean)
l : (listof X)

(map f l ...) → (listof Z)
f : (X ... -> Z)
l : (listof X)

andmap should use the map style notation and ormap should be revised to reflect its variable arity.

Jump-to-selected-expression doesn't work for many locations

  1. enter this program in the 'beginning student' language:
(define (f x)
  (if (= x 0) 1
      (* x (f (- x 1)))))

(f 3)
(f 2)
(f 4)
  1. highlight the '(- x 1)' expression
  2. Start the stepper
  3. click the "jump to current expression" button.
  4. nothing happens.

Bleah.

clarify error message for nested defines

Inspiration:

https://groups.google.com/d/msg/racket-users/j9Gri7M6i9E/LggwDfveCwAJ

TLDR:

  1. Programmer A posted BSL-like code that used > as an infix operator, got confused by the error message
  2. Programmer B suggested trying BSL because BSL gives much better error messages for that sort of thing
  3. Programmer A pasted his code into a BSL window. The code happened to use a nested helper function. Programmer A saw the error message "define: expected only one expression for the function body but found 1 extra part" and got confused.

Proposal:

Given code like

(define (f x)
  (define y (+ x 1))
  y)
  • BSL should say something like "nested definitions not supported"
  • ISL should mention local

check-expect mis-blamed for error outside testing

Steps to reproduce: In the Beginning Student Language (or Intermediate Student Language), run the following program:

(check-expect (g 30) "goodbye")
(f 40)
(define (f x) "hello")
(define (g y) "goodbye")

Expected:

f is used here before its definition
The test passed!

Actual:

f is used here before its definition
Ran 1 test.
0 tests passed.
No signature violations.

Check failures:
	check-expect encountered the following error instead of the expected value, "goodbye". 
   :: g is used here before its definition
in slattery.rkt, line 1, column 0 caused by expression in slattery.rkt, line 1, column 15 

Bug found by Austin Slattery.

Environment: DrRacket, version 7.4, english; Installed tools:

  • Algol 60
  • Signatures
  • DeinProgramm
  • DeinProgramm
  • Browser
  • Check Syntax
  • Graphical Debugger
  • Macro Stepper
  • Repository Time Stamp
  • Version
  • FrTime Language
  • How to Design Programs
  • The Stepper
  • Test Engine
  • Text Box
  • Lazy Racket
  • Optimization Coach
  • Quickscript
  • RackUnit DrRacket integration
  • Slideshow
  • Swindle

macOS High Sierra, Version 10.13.6, MacBook Pro (Retina, 13-inch, Early 2015)

Error highlight sometimes disappears after a period of time

It's a bit non-deterministic, but I can get it fairly reliably on Mac OS with: ISL previous chosen, launch DrRacket

Welcome to DrRacket, version 7.0 [3m].
Language: Intermediate Student; memory limit: 2000 MB.

click in the Definitions and type (=), then either click Run or type Command-R and wait while doing nothing for twenty seconds.

Stepper showing implementation details of HtDP templates in *SL

When stepping through programs that have templates, the stepper is revealing some implementation details about templates that are likely confusing to beginning students.

For example, stepping through this BSL program:

(define (temp x)
  (... x ...))

(add1 7)

transforms the program into:

(define lifted.0 1)
(define (temp x)
  (error
   '...
   "expected a finished expression, but found a template"))
(add1 7)

Stepper shows different error than "Run" for use-before-definition

In BSL, running this program:

(define a (list b))
(define b "don't care")

prints the error message, b is used here before its definition.

However, the Stepper shows the #lang racket error message on the right-hand side:

b: undefined;
 cannot reference an identifier before its definition

(text ...) in scaled images grows and shrinks according only to x-factor

It appears that the text in a scaled image is rendered according to the x-factor of the scaling, and without regard to the y-factor. To reproduce:

(define normal-o (overlay (text "O" 12 "black") (square 20 255 "pink")))
(define wide-o   (scale/xy 2 1 normal-o))
(define tall-o   (scale/xy 1 2 normal-o))

In wide-o, the O is made bigger in both dimensions, causing the top to be cut off. In tall-o, the O is left small. See below:

screen shot 2018-04-27 at 8 37 21 pm

Thanks :-)

Handin rejecting code which modifies a DrRacket-modified image

Steps to reproduce:

  1. Run (require 2htdp/image)
  2. Paste an image (drracket.png, for example) from clipboard into the Interactions window
  3. Apply scale 1 to this image and hit enter.
  4. Copy and paste the result to the Definitions window.
  5. Apply scale 1 to the result in the Definitions window. The Definitions window should now contain (require 2htdp/image)
    (scale 1 ...)
    where ... is replaced with the DrRacket-modified image.
  6. Submit the file to a Handin server configured with a checker script which evaluates the submission.

The code runs as expected in DrRacket, but submission to a Handin server will give an error:

submit error: Error in your code --
scale: expects an image as second argument, given '(instantiate (class ...) ...)

Provide better string operations in *SL

*SL includes string-lower-case? and string-upper-case?, but no functions for actually downcasing or upcasing strings. OTOH, it includes char-upper-case? and char-upcase, char-lower-case? and char-downcase.

It includes string=? and string-ci=?, and string<? and string-ci<? etc, but then it includes string-contains? but not string-contains-ci?.

This mishmash means that students can't use string-contains-ci? until they've learned about lists and map and characters, and can implement it themselves....

stepper: allow language designers to control printed representation of values

This is a (very reasonable) feature request from Mike Sperber. Email pasted (without permission, I'm guessing that's okay):

I've got a minor stepper problem, namely this pair of definitions:

(define real-make-pair
 (procedure-rename
  (lambda (f r)
    (when (and (not (null? r))
		(not (pair? r)))
      (raise
	(make-exn:fail:contract
	 (string->immutable-string
	  (format "Zweites Argument zu make-pair ist keine Liste, sondern ~e" r))
	 (current-continuation-marks))))
    (cons f r))
  'make-pair))

(define-syntax make-pair
 (let ()
   ;; make it work with match
   (define-struct pair-info ()
     #:super struct:struct-info
     #:property
     prop:procedure
     (lambda (_ stx)
	(syntax-case stx ()
	  ((self . args) (syntax/loc stx (real-make-pair . args)))
	  (else (syntax/loc stx real-make-pair)))))
   (make-pair-info (lambda ()
		      (list #f
			    #'real-make-pair
			    #'pair?
			    (list #'cdr #'car)
			    '(#f #f)
			    #f)))))

So make-pair is a macro that looks like the name of a procedure, and
behaves that way in all ways but one - the stepper prints it as
"real-make-pair". Can I change that somehow? Help would be much
appreciated!

Error message for pre-defined values should mention built-ins

The BSL program: (define car 5) produces the error message car: this name was defined previously and cannot be re-defined. Of course, the previous definition is part of the language, not in the student program. If the error message mentioned that things could be built-in to the language, that would be helpful.

I suggest: "this name is already defined in this file or is part of the language and cannot be re-defined". I'm happy to make the change if that sounds good to people.

Universe canvas is partly hidden by Windows task bar, can't move or resize it

The very first examples (rocket animation) from How To Design Programs, 2nd ed., do not fully work on Windows 10:

  • the window created with animate is partly covered by Windows task bar on the left side of the screen
  • even if I can move the task bar away and see the window in full, there is no way I can drag or resize it

I tested the same example on a Linux station and everything works fine: the window is displayed at the top left corner, then I can drag and resize the window as usual.

Stepper exposes internal error "supposed to be skipped"

I am helping a friend who is working through HtDP 2e, and his (incomplete and still buggy) attempt to work through 3.6 Designing World Programs is exposing an internal error in the Stepper.

Given the following program in Beginning Student language (i.e. no #lang):

(require 2htdp/image)
(require 2htdp/universe)

(define CAR-FINAL
  ; I have replaced the car with a rectangle for simplicity
  (rectangle 30 15 'solid 'black))

(define BACKGROUND
  (rectangle (* 8 (image-width CAR-FINAL))
             (* 2 (image-height CAR-FINAL))
             "outline"
             "black"))

(define Y-CAR
  (- (image-height BACKGROUND)
     (* .5 (image-height CAR-FINAL))))

(define (render ws)
  (place-image CAR-FINAL ws Y-CAR BACKGROUND))

(define (tock ws)
  (+ 3 ws))

(check-expect (tock 20) 23)
(check-expect (tock 78) 81)


(define (end? ws)
  (= ws (+ (image-width BACKGROUND)
           (* .5 (image-width CAR-FINAL)))))

(define (main ws)
  (big-bang ws
    [on-tick tock]
    [to-draw render]
    [stop-when end?]))

(main 5)

running the Stepper produces the following error message on the right-hand side in step 15/19:

skip-step?: contract violation
  expected: (or/c (listof procedure?) #f)
  given: (cons (lambda () ...) (cons "supposed to be skipped" (cons (lambda () ...) '())))
  in: the 2nd argument of
      (->
       (or/c
        'normal-break
        'normal-break/values
        'result-exp-break
        'result-value-break
        'double-break
        'late-let-break
        'expr-finished-break
        'define-struct-break)
       (or/c (listof procedure?) #f)
       render-settings?
       boolean?)
  contract from: 
      <pkgs>/htdp-lib/stepper/private/reconstruct.rkt
  blaming: <pkgs>/htdp-lib/stepper/private/model.rkt
   (assuming the contract is correct)
  at: <pkgs>/htdp-lib/stepper/private/reconstruct.rkt:48.2

ISL HOF docs use lambda expressions in examples

Many of the higher-order functions in the docs for ISL use examples that involve lambda, which is only available (as an expression form) starting in ISL+. This is sure to confuse students and means copy/pasting examples will result in errors (lambda: found a lambda that is not a function definition).

lambda expressions are used in: andmap, build-list, build-string, compose, filter, foldl, foldr, for-each, map, ormap, and procedure?.

Need check-random-within

Consider the following function:

Exercise 4 Design a function between that takes two Posns as input and returns a Posn that is almost their midpoint, but randomly moved a little bit. The distance of random movement must be proportional to the distance between the two inputs, so use (drift (* 0.2 (dist ... ...))) twice, once to move the x coordinate and once to move the y coordinate. Here dist is from Assignment 6. So use dist, drift, and midpoint. For testing, remember to use check-random.

This is taken from https://cs.indiana.edu/classes/c211/lab14.html

Testing this function requires check-random, but if the tested Posns don't form a pythagorean triple, then you end up with inexact numbers and check-random refuses to compare. Similarly, you can't use check-within because it doesn't do randomness determinization.

I plan to write a PR to fix this.

No highlighting when struct accessors crash

Misusing user-defined structure accessors does not highlight any expression in red when a crash occurs:

(define-struct s (x))
(s-x '())

This makes tracking down errors in larger programs really difficult for students.

Note that this is not a problem for built-in structures; this highlights the relevant expression:

(posn-x '())

‘check-satisfied’ documentation

  1. The docs for each of the teaching languages explicitly say that check-satisfied takes a truthy predicate. But the test actually requires an (Any -> Boolean) predicate.

  2. The error message when using a truthy predicate has a bug.

  3. For ISL+lambda and ASL: the docs don't remove the restriction that the predicate be a “named” one.

(check-satisfied expression predicate)

Checks that the first expression satisfies the named predicate (function of one argument). Recall that “satisfies” means “the function produces a value other than false.”

Actual behaviour:

(define (f x) x)
(check-satisfied 0 f)

format: format string requires 0 arguments, given 1; arguments were: "expected a boolean" "f"

Large Matrix's overflow into next expression.

Large Matrix's overflow into next expression. This is obvious if I make a 20x20 matrix (when using 27 point, menio font). I suspect that there is an off by one error somewhere that compounds when getting the snip extent of larger matrices.

screen shot 2018-05-23 at 1 30 35 pm

stepper: X UI makes stepper 'jump to' unusable

In the X windows (/ gnome?) UI, re-selecting a pull-down doesn't apparently trigger a message, meaning that when using one of these platforms, it's not possible to (e.g.) repeatedly step forward by an s-expression using the stepper. The obvious fix is to redesign the UI to make this a button click rather than a menu. Reported by several folks whose name I don't currently recall... apologies if it was you.

Stepper doesn't show steps for some programs

In the stepper for "Intermediate Student with lambda", the program:

((lambda (x) (x x)) (lambda (x) (x x)))

doesn't show any steps, even though this program takes infinitely many evaluation steps. The stepper appears to run forever without finding the first step.

On the other hand, the program:

((lambda (x) (x x)) (lambda (x) ((x x) (x x))))

shows infinitely many steps like it should.

(This behavior seems to be sensitive to alpha-renaming, so my guess at a cause is that the stepper is suppressing steps that yield a syntactically identical program.)

check-expect on Large Values

Code:
In the "Intermediate Student with Lambda" language, run the following program:
(check-expect (range 0 9999 1) 0)

Expected Result:
An error message.

Actual Result:
DrRacket freezes, and the stop button doesn't work.

batch-io limitations

read_file mentions file-exists? but it's not provided. Is there any specific reason for this?

Furthermore, the file operations are very limited currently. Apart from the lack of file-exists? there's also no way to

  • delete files
  • create folders
  • list folder contents

Being a student myself, I wanted to use batch-io for creating save files for an application using the universe teachpack.

Stepper produces error when stepping through world program

The teaching languages stepper produces an error when the next step would be to expand a big-bang form.

To Reproduce

Use the HtDP BSL language, and have a file that contains the big-bang form open. MWE below:

(require 2htdp/image)
(require 2htdp/universe)

(define MTS (empty-scene 500 500))

(define (square/blue n)
  (overlay (square n "solid" "blue")
           MTS))

(big-bang 0
  (on-tick add1)
  (to-draw square/blue))

Attempt to run the stepper on the big-bang.
When the next step would be the big-bang, it instead produces an error:

skip-step?: contract violation
  expected: (or/c (listof procedure?) #f)
  given: (cons (lambda () ...) (cons "supposed to be skipped" (cons (lambda () ...) '())))
  in: the 2nd argument of
      (->
       (or/c
        'normal-break
        'normal-break/values
        'result-exp-break
        'result-value-break
        'double-break
        'late-let-break
        'expr-finished-break
        'define-struct-break)
       (or/c (listof procedure?) #f)
       render-settings?
       boolean?)
  contract from: 
      <pkgs>/htdp-lib/stepper/private/reconstruct.rkt
  blaming: <pkgs>/htdp-lib/stepper/private/model.rkt
   (assuming the contract is correct)
  at: <pkgs>/htdp-lib/stepper/private/reconstruct.rkt:48.2

Expected Behavior

The stepper should either completely ignore the big-bang form, and treat it as if it didn't exist in the file, or it should treat the big-bang form like a define form, and skip expanding it.

Environment Details

OS: Linux and Windows
Racket Version: 7.2 and 7.0

I believe this is either a bug in the stepper itself, or a bug in the definition of big-bang in the teaching language. But since the bug seems to be in stepper/private, I think it is more likely to be a bug in the stepper itself.

in ASL `(void)` doesn't print as `(void)`

This also manifests itself (I think) as whens not printing anything.

Example:

> (void)
> (when false (void))
> (when true (void))
> (define x 0)
> (when true (set! x 1))
(void)
> (when false (set! x 1))
> 

I would expect every line (except the (define x 0)) to print (void).

stepper + big bang broken since 2014, sigh.

Shriram points out that the stepper is broken on this simplest big-bang program:

(require 2htdp/image)
(require 2htdp/universe)
(define (f2 w) (text "hi" 30 "red"))
(big-bang "dummy" [to-draw f2])

Specifically, it produces the error

skip-step?: contract violation
  expected: (or/c (listof procedure?) #f)
  given: (cons (lambda () ...) (cons "supposed to be skipped" (cons (lambda () ...) empty)))
  in: (->
       (or/c
        'normal-break
        'normal-break/values
        'result-exp-break
        'result-value-break
        'double-break
        'late-let-break
        'expr-finished-break
        'define-struct-break)
       (or/c (listof procedure?) #f)
       render-settings?
       boolean?)
  contract from: 
      <pkgs>/htdp-lib/stepper/private/reconstruct.rkt
  blaming: <pkgs>/htdp-lib/stepper/private/model.rkt
   (assuming the contract is correct)
  at: <pkgs>/htdp-lib/stepper/private/reconstruct.rkt:46.2

... in racket 6.1.1, and an essentially equivalent error in all more recent versions.

Why is 2htdp/planetcute so complicated?

For whatever reason, 2htdp/planetcute exports everything as set! transformers. I'm honestly not sure why it does this in the first place, but furthermore, this doesn't play nice with require/typed in Typed Racket (trying to require these seems to trigger an infinite loop in TR).

This itself might be a bug in Typed Racket, but even so, the implementation of planetcute.rkt seems much too complicated for a relatively simple task. Why exactly is it implemented the way it is?

Keys in Steppers

Resubmission of PR15200 in github.

It would be very nice if M-left/M-right was navigating the steps in both
steppers. It fits well enough that I keep using it and expect it to
work.

(As a side note, it's pretty hard to find the GH place to submit stepper
bugs...)

`check-expect` does not work as the only form in a `lang/htdp-beginner` module`

This program:

(module m lang/htdp-beginner (check-expect 1 1))

produces the error check-expect: found a test that is not at the top level.

This isn't a problem directly in Beginning Student et al, but it does manifest with the handin server, meaning that submitting files with just one check-expect in them fails with an error that students can't understand.

cc @pnwamk

stepper scrolling behavior still not really right

Notes for myself, sigh:

Run this program:
(define (f x)
(if (equal? x 0) 1
(* x (f (- x 1)))))

(f 30)

Step forward a bunch. Things look great! step backward a bunch ... ooh, now it keeps popping up to the top, and in many cases, the highlights appear to be missing or misplaced. A resize of the window fixes it, but it doesn't look right.

Placeholders break function calls in interactions window

With these BSL definitions:

(define (f x)
  ...)

(define (g x)
  x)

entering either (g 5) or (f 5) in the interactions pane results in a nasty ambiguous binding error for #%app:

#%app: identifier's binding is ambiguous
  context...:
   #(-967113051640681897 module) #(-967113051640681896 module teach 0)
   #(-967113051640681890 use-site) #(44611 module) #(44612 module #%htdp 0)
   #(44615 macro) #(50001 module) #(50002 module #%htdp 0) #(55328 module)
   #(55329 module #%htdp 0) #(60669 module) #(60670 module #%htdp 0)
   #(66014 module) #(66015 module #%htdp 0) #(69516 macro)
  matching binding...:
   #<module-path-index:((lib "lang/htdp-beginner.ss"))>
   #(44611 module) #(44612 module #%htdp 0) #(50001 module)
   #(50002 module #%htdp 0) #(55328 module) #(55329 module #%htdp 0)
  matching binding...:
   #<module-path-index:((lib "lang/htdp-beginner.ss"))>
   #(44611 module) #(44612 module #%htdp 0) #(50001 module)
   #(50002 module #%htdp 0)
  matching binding...:
   #<module-path-index:(mzscheme)>
   #(-967113051640681897 module) #(-967113051640681896 module teach 0)
  matching binding...:
   #<module-path-index:((lib "lang/htdp-beginner.ss"))>
   #(44611 module) #(44612 module #%htdp 0)
  matching binding...:
   #<module-path-index:((lib "lang/htdp-beginner.ss"))>
   #(44611 module) #(44612 module #%htdp 0) #(50001 module)
   #(50002 module #%htdp 0) #(55328 module) #(55329 module #%htdp 0)
   #(60669 module) #(60670 module #%htdp 0)
  matching binding...:
   #<module-path-index:((lib "lang/htdp-beginner.ss"))>
   #(44611 module) #(44612 module #%htdp 0) #(50001 module)
   #(50002 module #%htdp 0) #(55328 module) #(55329 module #%htdp 0)
   #(60669 module) #(60670 module #%htdp 0) #(66014 module)
   #(66015 module #%htdp 0)
  context at layer 1...:
   #(-967113051640681897 module) #(-967113051640681896 module teach 0)
   #(-967113051640681890 use-site) #(44611 module) #(44612 module #%htdp 0)
   #(44615 macro) #(50001 module) #(50002 module #%htdp 0) #(55328 module)
   #(60669 module) #(66014 module) #(69516 macro)
  matching binding at layer 1...:
   #<module-path-index:((lib "lang/htdp-beginner.ss"))>
   #(44611 module) #(44612 module #%htdp 0) #(50001 module)
   #(50002 module #%htdp 0)
  matching binding at layer 1...:
   #<module-path-index:(mzscheme)>
   #(-967113051640681897 module) #(-967113051640681896 module teach 0)
  matching binding at layer 1...:
   #<module-path-index:((lib "lang/htdp-beginner.ss"))>
   #(44611 module) #(44612 module #%htdp 0)

Tested in 6.10.1 and 6.11.

Random last image in animated gifs

I've had problems using big-bangs "record"-option in my Racket Turtle lib (https://github.com/tyynetyyne/racket_turtle). Sometime the last image of the generated animated gif is one of the earlier images instead of the image corresponding to the final world state.
Here are two animated gifs created by running the exact same code: first one is correct and the second one has a wrong last image: http://1drv.ms/1MQxHLg . The wrong last image appeared about 50% of the time in my testing. These images where produced by running the "bug_hunting.rkt" from this package: https://github.com/tyynetyyne/racket_turtle/archive/master.zip.
I suppose there is something in my Racket Turtle package that triggers this since I was not able to produce it with a simpler animation. Racket Turtle uses only 2htdp/image and 2htdp/universe libs. Tested with DrRacket 6.0.1 and 6.2.

Canvas window cannot be closed with keyboard on OS X

I am reading through HtDP/2e and find it annoying that pressing Cmd+W or Esc can't close the canvas windows that appears while using the animate from 2htdp/universe. Cmd+Q, of course, tries to close the whole DrRacket IDE. The only way it seems is to use the mouse pointer to press the red close button.

(previously reported as racket/drracket#6)

check-expect stops evaluating tests after errors

I have a code snippet with two failing check-expect tests, where the second failure is hidden by the first failing — test evaluation simply stops silently, without warnings. I argue there's a bug (at least usability-wise):

  • I don't see that even documented (in, e.g., http://docs.racket-lang.org/test-engine/).
  • I'm not convinced that's appropriate, except for critical errors, but one can argue about it. In particular, there are downsides to resuming testing after failure where mutations and side effects are involved, for tests with accidental effect leaks, but such tests are bad even when they're possible (in the advanced student languages), and they're impossible in BSL and ISL.
  • More importantly, it's clearly important to warn users clearly that later tests weren't run, in case one assumes otherwise. That's especially easy since tests are first registered and then run, so it should be easy to check the total test count.

This is distilled from a first-year student problem: she reached the conclusion (through otherwise sensible deductions) that the second test was working, when it wasn't even run. Overall, she appears here an intelligent student who got stuck, also because of confusing tools. Since the tools confused me for a while too, I think this is a clear bug.
The examples below are not as confusing, but just because I've oversimplified the tests during minimization.

(define (f x)
  (cond
    [#false 0]))
(check-expect (f 0) 0)
(check-expect 1 0)
1 Test gelaufen.
0 Tests bestanden.
Keine Signaturverletzungen.

Check-Fehler:
    check-expect bekam den folgenden Fehler statt des erwarteten Werts, 5.
   :: cond: all question results were false
in Zeile 4, Spalte 0

Here you can notice that the Racket only reports that one test run, so here the problem is obvious. But my student had 40 tests, and I noticed by sheer luck: I added a failing test, the test count didn’t change, and I happened to be paying attention because she had reported something was amiss.

Contracts in BSL and ISL Documentation.

I have a student who extracted all the contracts from the BSL and ISL documentation (using https://gist.github.com/adhameer/542cc3728081d2f95085ad61f3920fa8 ). The contracts, listed below, seem to be a mixture of various styles and conventions, so taking a cue from the HtDP2e Teachpacks documentation she's updating them to the current contract system.

Let me know if you think something else should be done with them, and anything non-obvious to consider while updating them. We'll submit a pull request when done.

(X -> Y)

(X -> Z)

(X -> any)

(X -> real)

(X-1 ... X-N -> Y)

(Y -> Z)

(any ... -> any)

(list X-i+1 ... X-N)

(listof X)

(listof any)

(listof char)

(nat -> X)

(or/c #f list)

(union #f (listof X))

(union #f cons?)

(union (listof any) #f)

(union 1 1.0 0 0.0 -1 -1.0)

(union number #f)

X

X-1

Y

any

any/c

boolean?

char

complex

eof-object?

exact-integer?

image

integer

list

list?

nat

natural-number

natural-number?

natural?

number

posn

range

rational?

real

signature

string

string?

symbol

void?

Bad error message for foldl

foldl's error report all of its arguments one position off.

> (foldl + 0  5)
foldl : 2th argument must be a list, given 5

but 5 is the 3rd argument.

image composition functions (overlay, beside, above) inconsistent with arithmetic (+) in ISL

In BSL, overlay, beside, above, act similar to + -- they act as different types of sums on images, and all are multi-arity with a minimum argument count of 2 (if you provide fewer than 2 arguments, they all error).

In ISL, + (and *) can be given one argument, in which case it acts as an identity, and zero arguments, in which case it returns an identity. This is really useful since ISL has apply, and this means you can (apply + some-list), without worrying about the case that some-list has one or zero elements.

It seems like the image library functions should act in the same way in ISL -- with one argument, they should act as an identity and with zero arguments, they should return an identity (an empty image). This would retain the consistency with +, which seems important. Obviously I can implement these functions in a few lines of my own code, but I don't want to have these little library shims that I have to explain to students to require & use!

The documentation of 2htdpimage should have illustrations for each option

Various options like mode?, x-place?, y-place? should have complete illustrations in their own section. With this way, users don't need to:

  • Search the entire documentation to see examples of the option that they want (e.g., mode? is only illustrated in circle but not triangle)
  • Experiment in Racket on their own (e.g., are "center" and "middle" in y-place? the same?)

No matching clause for `(make-skipped-step ...)`

In BSL on Racket v6.5 and v6.6, I try to run:

(check-expect 0 (sqrt 2))
;; Note: (check-expect (sqrt 2) 0) is alright

And get this error:

exception raised by error display handler: match: no matching clause for (make-skipped-step ...); original exception raised: check-expect cannot compare inexact numbers. Try (check-within test 1.4142135623730951 range).

dc<%> error for (make-circle 8675309)

If I try to make a very large image with 2htdp/image, I get an error from the dc<%> interface.
I wish the error came from the 2htdp/imagefunction & told me the size limit for my machine.

Here's an example program. Your size for "too large" may vary -- I had a student with a Dell laptop that could draw this circle.

(require 2htdp/image)
(circle 20000 "solid" "HotPink")
;; erase in dc<%>: drawing context is not ok: (instantiate (class ...) ...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.