2008/2/11, Thomas Mertes <tho...@gm...>:
> "Leonardo Cecchi" <leo...@gm...> wrote (off-list):
> > It works well also for me.
> > I don't understand how this explicit "new" function will work: it will
> > be used to initialize the interface variable like this?
> >
> > const proc: main is func
> > local
> > var strangeInterface: enterprise is new(astronave);
> > begin
> > (* something here *)
> > end func;
> >
> > I think it's really useful to visually see when an interface variable
> > points to a new value or to an existing implementation value.
> >
> > Thanks,
> >
> > Leonardo
> Yes, it would be used exactly as in your example (maybe without
> parentheses). In the moment I use special primitive actions to
> create and assign interface variables with an implementation value.
> This actions are 'CLS_CREATE2' and 'CLS_CPY2'. This actions accept
> interface objects (category CLASSOBJECT) or implementation objects
> (everything else, but intended to be of category STRUCTOBJECT).
> If the refered implementation object is a temporary expression
> it should be made permanent (which I forgot to do in the case
> of CLS_CREATE2 - see below for the fix of the bug).
>
> The situation, that implementation objects can point to global or
> local objects, which may be constant or variable, and also to
> temporary objects (which should be made permanent in the assignment
> or create action), is confusing.
>
> As you might guess there is a memory leak in this area.
> I plan to use reference counting (or explicit frees when reference
> counting is not enough). In that case I have to destinguish between
> global and local objects (which need no reference counting) and
> managed values (with reference counting).
>
> By the way, here is the fix for the bug you found
> (the next version of Seed7 will contain it):
> --- /home/tm/old_seed7_5/src/clslib.c 2008-02-10 15:47:51.000000000 +0100
> +++ /home/tm/new_seed7_5/src/clslib.c 2008-02-11 13:26:48.000000000 +0100
> @@ -175,6 +175,7 @@
> modu_to->value.objvalue = take_reference(modu_from);
> } else {
> modu_to->value.objvalue = modu_from;
> + CLEAR_TEMP_FLAG(modu_from);
> } /* if */
> return(SYS_EMPTY_OBJECT);
> } /* cls_create2 */
>
> BTW.: If possible I would prefer the discussion to be on
> see...@li...
> That way others can also follow the discussion.
>
> Greetings Thomas Mertes
>
> Seed7 Homepage: http://seed7.sourceforge.net
> Seed7 - The extensible programming language: User defined statements
> and operators, abstract data types, templates without special
> syntax, OO with interfaces and multiple dispatch.
>
> --
> GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
> Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Seed7-users mailing list
> See...@li...
> https://lists.sourceforge.net/lists/listinfo/seed7-users
>
I've tested the fix and it works well for me.
Sorry, previously I've forgotten to forward the response to the mailing list.
Thanks for the ready fix!
Leonardo
|