[plt-scheme] Compile error help

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Nov 15 20:56:22 EST 2009

You could just pass the class. Classes are values (ie, can be passed
to and returned from functions) in PLT.

Robby

On Sun, Nov 15, 2009 at 7:22 PM, Tim Marchbank <tjm_22 at hotmail.com> wrote:
>
> Thanks for replying.
>
> The reason I am doing it this way, is because it is the only way I could
> find to convert a string of a class into an input for new / make-object etc.
> (Probably comes back to the way I would have done it or something similar in
> VisualLISP.)
> Why do I want to do that? Well, I was wanting a common way of creating any
> class of object by passing its class (and other initialisation variables) to
> a common function, and sending it as a string seemed the most useful means
> (as I can then use it dialogs etc..)
> As I said, this is only a simplified version of what I am working on.
>
> If there is a better way to do it, I'm all ears.
>
> But..
> Why does it not work, and then work?
>
> Still learning..
>
> Tim.
>
>
>> Date: Sun, 15 Nov 2009 17:08:48 -0700
>> From: czhu at cs.utah.edu
>> To: tjm_22 at hotmail.com
>> CC: plt-scheme at list.cs.brown.edu
>> Subject: Re: [plt-scheme] Compile error help
>>
>> Could I ask why you use `eval' here? The error is related to the way you
>> use `eval'. Most of the time, people misuse `eval' (i.e., use eval when
>> they shouldn't).
>>
>> Chongkai
>>
>> Tim Marchbank wrote:
>> > Hi,
>> >
>> > Here is a simplified example of the problem I am having:
>> > I open the following in DrScheme:
>> >
>> >
>> > #lang scheme
>> > (define (string-eval str) (eval (read (open-input-string str))))
>> > (define (:Object-new c)
>> > (new (string-eval c))
>> > )
>> > (define entity% (class object%
>> > (field (Colour: "Red"))
>> > (super-new)
>> > )
>> > )
>> > (define point% (class entity%
>> > (field (X: 0.0))
>> > (field (Y: 0.0))
>> > (field (Z: 0.0))
>> > (super-new)
>> > )
>> > )
>> > (define aa (:Object-new "point%"))
>> > (define ab (:Object-new "entity%"))
>> >
>> >
>> > When I run it, it comes up with the following error:
>> >
>> > compile: unbound identifier (and no #%top syntax transformer is bound)
>> > in: point%
>> >
>> > but then when I enter the last two lines into the interactions window,
>> > directly after the error, it works:
>> >
>> > > (define aa (:Object-new "point%"))
>> > (define ab (:Object-new "entity%"))
>> > > aa
>> > #(struct:object:point% ...)
>> > > ab
>> > #(struct:object:entity% ..
>> >
>> > Why does it work one time & not the other??
>> >
>> > Any help would be appreciated.
>> >
>> > Thanks
>> >
>> > Tim.
>> >
>> >
>> > ------------------------------------------------------------------------
>> > With all the lastest places, searching has never been easier. Look
>> > now! Looking to move this spring?
>> > <http://clk.atdmt.com/NMN/go/157631292/direct/01/>
>> > ------------------------------------------------------------------------
>> >
>> > _________________________________________________
>> > For list-related administrative tasks:
>> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> >
>>
>
> ________________________________
> Check out The Great Australian Pay Check now Want to know what your boss is
> paid?
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.