[racket] Racket newbie questions
On 05/05/2013 10:45 PM, John Gateley wrote:
> Lots of newbie questions:
>
> 1) If I am creating a new class that has a "size" field, what is the
> convention for naming the initialization argument? "size" doesn't
> work! This name must be known by all class creators.
> (class object %
> (init init-size) ;; init-size cannot be size
> (define size init-size)
> ...)
(init-field size) declares an init argument and field both named size;
the field is initialized with the init argument's value.
If you don't want size to be a public field, you can also do this:
(init ((init-size size)))
(define size init-size)
The first line declares an init arg named size to the outside world but
init-size within the class.
> 2) In DrRacket, where is the "save all" menu item? Can I configure
> DrRacket so that when I "Run" (by clicking the Run button) the
> files in the definitions area are automatically saved?
>
> 3) Are there Eclipse, NetBeans or Visual Studio plugins for Racket?
>
> 4) Do you have real-world examples of why (super-new) would not be
> called before anything else in a class?
You might want to compute some values to pass as init arguments to the
super class. If the computations are big and/or you need to keep
references to the values yourself, you might define them as fields
before calling super-new. Or they might depend on your own init args, so
you would at least declare those first.
> 5) Is there an implementation of vectors that can change in size?
> Like C++'s std::vector?
See data/gvector.
Ryan
> 6) Finally, for tonight, here's a way to crash DrRacket in 64
> bit Windows 7. I've attached two files, main.rkt and manuscript.rkt.
> Start DrRacket, open "main.rkt", open "manuscript.rkt" (which
> opens a second window), switch to the "main.rkt" window, press
> the "Run" button, then press the "Debug" button. You get the dreaded
> "DrRacket has stopped working" dialog.
>
> Thanks,
>
> John