creating classes at runtime 
Author Message
 creating classes at runtime

The DRM is a little vague on how to do this, but I'm looking to do
something like this:

// ---- code ----
define class <animal> (<object>) end; // predefined

// sometime later, the user wants to add a class
// (by, e.g., supplying characteristics thru DUIM)
define constant <mammal> = make(<class>, superclasses: <animal>);
// ---- end-code ----

The last line returns an error ... what'll get the expected results?

Sincerely,
Doug Auclair

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 27 Oct 2002 03:00:00 GMT  
 creating classes at runtime
You're on the right track.  There are at least two problems here, though:
 (1) By default, classes are sealed.  That is, <animal> is sealed, so you
     can't create any subclasses.  Define <animal> with 'define open class'.
 (2) I bet 'superclasses:' needs a sequence, not a single class.

I didn't try it, but those two changes will get you farther.

Quote:

>The DRM is a little vague on how to do this, but I'm looking to do
>something like this:

>// ---- code ----
>define class <animal> (<object>) end; // predefined

>// sometime later, the user wants to add a class
>// (by, e.g., supplying characteristics thru DUIM)
>define constant <mammal> = make(<class>, superclasses: <animal>);
>// ---- end-code ----

>The last line returns an error ... what'll get the expected results?

>Sincerely,
>Doug Auclair

>Sent via Deja.com http://www.deja.com/
>Before you buy.



Sun, 27 Oct 2002 03:00:00 GMT  
 creating classes at runtime

Quote:

> You're on the right track.  There are at least two problems here, though:
>  (1) By default, classes are sealed.  That is, <animal> is sealed, so you
>      can't create any subclasses.  Define <animal> with 'define open class'.
>  (2) I bet 'superclasses:' needs a sequence, not a single class.

> I didn't try it, but those two changes will get you farther.

Oddly enough, the DRM sez it can take a <class> or a <sequence> of
classes, so presumably it's just the sealing that's the problem (or a bug
in make(<class>, ...)!).

BTW, the slots you put in a dynamically-created class can given a "type:"
*or* a "deferred-type:".  In the latter case, the expression for the
slot's type isn't evaluated until within the first call fto make for that
class.  Anyone know/think of a use for this?!?

Quote:

> >The DRM is a little vague on how to do this, but I'm looking to do
> >something like this:

> >// ---- code ----
> >define class <animal> (<object>) end; // predefined

> >// sometime later, the user wants to add a class
> >// (by, e.g., supplying characteristics thru DUIM)
> >define constant <mammal> = make(<class>, superclasses: <animal>);
> >// ---- end-code ----

Hugh


Mon, 28 Oct 2002 03:00:00 GMT  
 creating classes at runtime

Quote:
> BTW, the slots you put in a dynamically-created class can given a "type:"
> *or* a "deferred-type:".  In the latter case, the expression for the
> slot's type isn't evaluated until within the first call fto make for that
> class.  Anyone know/think of a use for this?!?

Circular types, e.g., if one of the slots can refer to the type you are in
the middle of creating?


Mon, 28 Oct 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. creating classes at runtime

2. creating classes at runtime

3. Creating new classes at "runtime"

4. Creating a control at runtime - using Create()

5. GNU ST: getting user-created classes to create new instances

6. SmallScript website [Was: Creating blocks at runtime]

7. Creating blocks at runtime

8. Creating Menu at runtime using VB 5 ???

9. creating controls at runtime

10. Problem creating ST/V Win32 2.0 Runtime EXE

11. Creating Controls at Runtime

12. Best embed for creating runtime controls

 

 
Powered by phpBB® Forum Software