[plt-scheme] RE: MrEd Learning

From: mike (mh983 at netscape.net)
Date: Thu Aug 21 13:35:47 EDT 2003

Hello Alex.  As far as the first example, assuming you copied/pasted the 
example so there are no typos, then clicking on the canvas first, then 
pressing a keyboard key worked for me.  I'm using plt on a Mandrake 
Linux/Gnome machine.


> From: "Alex Peake" <apeake at comac.com>
> To: <plt-scheme at list.cs.brown.edu>
> Date: Sat, 16 Aug 2003 21:48:19 -0700
> Subject: [plt-scheme] MrEd Learning
> I am trying out MrEd - following the manual.
> In 2. Windowing Toolbox Overview, the example is:
> ;; Make a frame by instantiating the frame% class
> (define frame (instantiate frame% ("Example")))
> ;; Make a static text message in the frame
> (define msg (instantiate message% ("No events so far..." frame)))
> ;; Make a button in the frame (using keyword-based arguments, for demonstration)
> (instantiate button% () (label "Click Me") (parent frame)
> ;; Callback procedure for a button click
> (callback (lambda (button event) (send msg set-label "Button click"))))
> ;; Show the frame by calling its show method
> (send frame show #t)
> ;; Derive a new canvas (a generic drawing window) class to handle events
> (define my-canvas%
>   (class canvas% ; The base class is canvas%
> ;; Declare overrides:
> (override on-event on-char)
> ;; Define overriding method to handle mouse events
> (define on-event (lambda (event) (send msg set-label "Canvas mouse")))
> ;; Define overriding method to handle keyboard events
> (define on-char (lambda (event) (send msg set-label "Canvas keyboard")))
> ;; Call the superclass initialization (and pass on all init args)
> (super-instantiate ())))
> ;; Make a canvas that handles events in the frame
> (instantiate my-canvas% (frame))
> The following text says: Clicking on the canvas calls on-event. While the canvas has the keyboard
> focus, typing on the keyboard invokes the canvas’s on-char method.
> However, this never happens - the message never gets changed to "Canvas keyboard"?
> In 8. Editor Toolbox, the example is:
> (define f (instantiate frame% ("Simple Edit" #f 200 200)))
> (define c (instantiate editor-canvas% (f )))
> (define t (instantiate text% ()))
> (send c set-editor t)
> (send f show #t)
> (define mb (instantiate menu-bar% (f )))
> (define m-edit (instantiate menu% ("Edit" mb)))
> (define m-font (instantiate menu% ("Font" mb)))
> (append-editor-operation-menu-items m-edit)
> (append-editor-font-menu-items m-font)
> The following text says: The user can also insert an embedded editor by selecting Insert Text from
> the Edit menu;
> However, there is no  Insert Text choice?
> --__--__--
> Message: 2
> From: Carlos Eduardo Scheidegger <carlos.scheidegger at terra.com.br>
> To: plt-scheme at list.cs.brown.edu
> Date: 17 Aug 2003 22:10:54 -0300
> Subject: [plt-scheme] Scheme-Check: Randomized Unit Testing for PLT Scheme
> --=-NnwbaF8lydKVUU8TYSqK
> Content-Type: text/plain
> Content-Transfer-Encoding: quoted-printable
> Hello folks.
>     I am sending this message to announce the release of a library I put
> together that may be useful to some of you. Scheme-Check is basically a
> PLT Scheme port of the Haskell QuickCheck module [1], by Koen Classen
> and John Hughes.
>     Scheme-Check, like QuickCheck, allows specification-based testing of
> programs and functions. Instead of defining individual test cases to
> massage the functions, the programmer defines properties that must be
> satisfied by the code, and Scheme-Check generates a large amount of test
> data, hopefully performing a more thorough verification of the code.
> QuickCheck has been found to work extremely well, and my experiences
> with Scheme-Check are similar.
>     Scheme-Check is available for download at
> http://www.inf.ufrgs.br/~carlossch/scheme-check/
>     Some info about the design/implementation:
>     I have tried to stay very close to the original library in this first
> release. I had no idea if the lack of a type and class system would help
> me or hinder me, and so I decided to walk the traveled roads first.
>     Since we do not have a class system like Haskell's to help with the
> definition of the random data generators, Scheme-Check reimplements a
> part of the type-based dispatch system to achieve the same effect. One
> disadvantage of this approach is that Scheme-Check must be given the
> types of the parameters that are expected by the property.
>     Scheme-Check comes with generators for the following types: Boolean,
> Integer, Char, Real, Rational, Complex, String, Symbol, lists of other
> types, functions of other types of arbitrary arity, and a generator that
> chooses randomly between values of arbitrary types ("choice").
>     Scheme-Check uses a monad exactly like QuickCheck's to generate the
> random data. In Haskell, complex monads find easy expression because of
> the "'do' notation". Scheme-Check also provides syntax extensions that
> reproduce the Haskell syntactic sugar.
>     Scheme-Check, like QuickCheck, can generate random functions.
> QuickCheck was able to do this because the default Haskell random number
> generator is purely functional, and the technique to generate the random
> function depends critically on being able to store the state of the
> generator. This functionaly could perhaps be implemented using the
> current-pseudo-random-number-generator function and friends but, on the
> other hand, the Haskell library has another major advantage: it provides
> the ability to split a random generator into two independent ones. This
> is useful to store a specific RNG to be used by a random function. So,
> Scheme-Check also includes a port of the Haskell RNG library.
>     Current limitations:=20
>     - QuickCheck did not have to deal with impure functions, as Haskell is
> purely functional. Scheme, on the other side, is not, and so we need a
> way to test impure functions. There is currently no "official" way to do
> this, but a possible workaround is to set the global variables on which
> the functions depend inside the property, and then testing the property
> itself. (Maybe I should do nothing and leave a warning to the
> set!-addicted folks :)
>     - The random data generation DSL has a distinctly Haskellish feel
> (obviously). This can be a turn-off to some users. However, I am not
> quite sure how to do better.
>     I tested Scheme-Check with PLT Scheme 204 and 205. Don't know about
> earlier versions, but I see no reason not to work.
> Suggestions, comments, critiques and contributions are all largely
> welcome.
> Thank you,
> Carlos Eduardo Scheidegger
> [1] QuickCheck: Automatic Specification-based Testing.
> http://www.math.chalmers.se/~rjmh/QuickCheck/
> --=20
> I just think that the (...) flight from and hatred of technology is
> self-defeating. The Buddha, the Godhead, resides quite as comfortably
> in the circuits of a digital computer or the gears of a cycle
> transmission as he does at the top of a mountain or in the petals of a
> flower.
> - Robert M. Pirsig, Zen and the Art of Motorcycle Maintenance
> --=-NnwbaF8lydKVUU8TYSqK
> Content-Type: application/pgp-signature; name=signature.asc
> Content-Description: This is a digitally signed message part
> Version: GnuPG v1.0.7 (GNU/Linux)
> iD8DBQA/QCeeISmqd4q+P48RAv9rAJ9HcC/CeaO6qi83+8iPXF5dQlJtAACfZIS9
> AI4dT6d/i5xuVwEoBx9Urq0=
> =yLDE
> --=-NnwbaF8lydKVUU8TYSqK--
> End of plt-scheme Digest

Posted on the users mailing list.