Page 1 of 1

How to create self-referencing objects?

Posted: Wed Jan 28, 2004 3:25 pm
by Gambit37
Here's a weird one:

How do I create an object that CONVERT_TO another that in turn CONVERT_TO the initial object?

For example, say I want an empty flask that CONVERT_TO a full flask that in turn CONVERT_TO an empty flask, ad infinitum?

I can't do it at present because when you define your new objects, RTC checks to see that it's CONVERT_TO object already exists... but in this case each one can't have a CONVERT_TO parameter without the other one already being defined!

This is a rather nasty catch-22 loop. How to get around it?

Don't suggest creating interim objects because the same thing applies!

Posted: Wed Jan 28, 2004 4:40 pm
by andyboy_uk
Can you clone the objects, like this

my_ flask_full
and
my_flask_empty

and put the convert to to switch to each other?

Or is that what you meant by interim objects?

Posted: Wed Jan 28, 2004 4:53 pm
by Gambit37
I don't understand your sample. Is the word 'and' important?

The problem is that RTC checks for any object listed in the CONVERT_TO paramter. If it doesn't already exist, it generates critical errors.

So it's not possible to do this:

MY_FLASK_EMPTY .... CONVERT_TO(MY_FLASK_FULL)
MY_FLASK_FULL .... CONVERT_TO(MY_FLASK_EMPTY)

...because the definition for MY_FLASK_EMPTY includes a CONVERT_TO reference to an object that has not yet been defined....