<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
<BR>
Thanks for replying.<BR>
<BR>
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.)<BR>
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..)<BR>
As I said, this is only a simplified version of what I am working on.<BR>
<BR>
If there is a better way to do it, I'm all ears.<BR>
<BR>
But.. <BR>
Why does it not work, and then work?<BR>
<BR>
Still learning..<BR>
<BR>
Tim.<BR>
<BR> <BR>> Date: Sun, 15 Nov 2009 17:08:48 -0700<BR>> From: czhu@cs.utah.edu<BR>> To: tjm_22@hotmail.com<BR>> CC: plt-scheme@list.cs.brown.edu<BR>> Subject: Re: [plt-scheme] Compile error help<BR>> <BR>> Could I ask why you use `eval' here? The error is related to the way you <BR>> use `eval'. Most of the time, people misuse `eval' (i.e., use eval when <BR>> they shouldn't).<BR>> <BR>> Chongkai<BR>> <BR>> Tim Marchbank wrote:<BR>> > Hi,<BR>> > <BR>> > Here is a simplified example of the problem I am having:<BR>> > I open the following in DrScheme:<BR>> > <BR>> > <BR>> > #lang scheme<BR>> > (define (string-eval str) (eval (read (open-input-string str))))<BR>> > (define (:Object-new c)<BR>> > (new (string-eval c))<BR>> > )<BR>> > (define entity% (class object%<BR>> > (field (Colour: "Red"))<BR>> > (super-new)<BR>> > )<BR>> > )<BR>> > (define point% (class entity%<BR>> > (field (X: 0.0))<BR>> > (field (Y: 0.0))<BR>> > (field (Z: 0.0))<BR>> > (super-new)<BR>> > )<BR>> > )<BR>> > (define aa (:Object-new "point%"))<BR>> > (define ab (:Object-new "entity%"))<BR>> > <BR>> > <BR>> > When I run it, it comes up with the following error:<BR>> > <BR>> > compile: unbound identifier (and no #%top syntax transformer is bound) <BR>> > in: point%<BR>> > <BR>> > but then when I enter the last two lines into the interactions window, <BR>> > directly after the error, it works:<BR>> > <BR>> > > (define aa (:Object-new "point%"))<BR>> > (define ab (:Object-new "entity%"))<BR>> > > aa<BR>> > #(struct:object:point% ...)<BR>> > > ab<BR>> > #(struct:object:entity% ..<BR>> > <BR>> > Why does it work one time & not the other??<BR>> > <BR>> > Any help would be appreciated.<BR>> > <BR>> > Thanks<BR>> > <BR>> > Tim.<BR>> > <BR>> ><BR>> > ------------------------------------------------------------------------<BR>> > With all the lastest places, searching has never been easier. Look <BR>> > now! Looking to move this spring? <BR>> > <http://clk.atdmt.com/NMN/go/157631292/direct/01/><BR>> > ------------------------------------------------------------------------<BR>> ><BR>> > _________________________________________________<BR>> > For list-related administrative tasks:<BR>> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme<BR>> > <BR>> <BR>                                            <br /><hr />Check out The Great Australian Pay Check now <a href='http://clk.atdmt.com/NMN/go/157639755/direct/01/' target='_new'>Want to know what your boss is paid?</a></body>
</html>