[plt-scheme] Compile error help

From: Tim Marchbank (tjm_22 at hotmail.com)
Date: Sun Nov 15 20:22:11 EST 2009

 

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
> > 
> 
 		 	   		  
_________________________________________________________________
Want to know what your boss is paid? Check out The Great Australian Pay Check now
http://clk.atdmt.com/NMN/go/157639755/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091116/979f42bd/attachment.html>

Posted on the users mailing list.