[racket] Racket newbie questions

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue May 7 00:01:36 EDT 2013

On Mon, May 6, 2013 at 10:46 PM, John Gateley <racket at jfoo.org> wrote:

> Here's a summary of the responses. Thanks to everyone who
> replied. My comments are in [ and ]. Not much new though.
>
>
>
> On 5/5/2013 9: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)
>>    ...)
>>
>
> You can use internal names to make this work:
>
>   (class object%
>     (super-new)
>     (init ([internal-size size]))
>     (define size internal-size))
>
> I use a macro that encodes this pattern:
>
>   (define-syntax-rule (init-private field-name)
>     (begin (init ([internal field-name]))
>            (define field-name internal)))
>
>   (class object%
>     (super-new)
>     (init-private size))
>
> [Thanks!]
>
>
>
>
>> 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?
>>
>
> I agree that a 'Save all' item is missing.
> You can bind keyboard shortcuts for that.
> http://docs.racket-lang.org/**drracket/Keyboard_Shortcuts.**html<http://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html>
>
> [also]
>
> This might work:
>
> http://planet.plt-scheme.org/**display.ss?package=drsync.plt&**
> owner=grettke<http://planet.plt-scheme.org/display.ss?package=drsync.plt&owner=grettke>
>
> [Looks close, but clicking Run/Debug or anything similar should save
> by default, or at least be configurable to do that. You don't want to
> run code, verify that it is correct, and exit and with a single slip
> of the fingers lose the changes that you just tested.]
>
>
>
Well, this scenario would require multiple slips, as you have to first slip
to try to exit and then slip to say "don't save" in the dialog asking you
"are you sure you want to exit without saving?".

And also there are autosave files (whose existence DrRacket detects when it
starts up).

That's not to say that this shouldn't be configurable. Even better, it
seems to me, would be to use mac os x's "auto save" functionality (not the
same thing as the auto save I mentioned in the previous sentence).

Robby


>
>> 3) Are there Eclipse, NetBeans or Visual Studio plugins for Racket?
>>
>
> [No responses here. I didn't get to try the debugger environment last
> night due to the crash, but I suspect there's a lot of mileage to be
> had in exploiting existing debugging environments over creating the
> functionality in DrRacket]
>
>
>
>> 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.
>
> [Interesting! I hadn't thought of that, but it seems real. Do you have
> any examples?]
>
>
>
>> 5) Is there an implementation of vectors that can change in size?
>> Like C++'s std::vector?
>>
>
>
> http://docs.racket-lang.org/**data/gvector.html<http://docs.racket-lang.org/data/gvector.html>
>
> [This is close, but I don't see an operation to explicitly grow the
> vector, other than adding one element at the end. For some algorithms,
> you want to grow the vector exponentially - doubling the size instead
> of adding one element.]
>
>
>
>> 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.
>>
>
> Assuming that you're using v5.3.3, can you check whether the crash
> happen the current candidate for the next release?:
>
>    http://pre.racket-lang.org/**release/installers/<http://pre.racket-lang.org/release/installers/>
>
> [Indeed, it seems to be fixed.]
>
>
> [Thanks again everyone. No time tonight for much testing, but I will
> have more question later. -- j]
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/**users <http://lists.racket-lang.org/users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130506/7a495053/attachment.html>

Posted on the users mailing list.