In our previous episode, Howard Page-Clark said:
>
> var i1, i2: TSortableInteger;
_INTERFACES_ are refcounted, not classes. And these are class references.
Change it to ISortableInteger, remove the free, and it will work fine probably.
___
fpc-pascal
I've been exploring interfaces a bit, and fail to understand when
automatic destruction of an object is precipitated by the compiler, and
when not.
Consider the lifetime of the two instances i1 and i2 in the following
program. It seems that i2 (called in a method of i1) is freed
automatically,
> I appreciate that I'm abusing the language here, but /should/ the original
implicit conversion have worked?
I don't know, but IMO it should. Well, a variant should be able to accept
any variant compatible type, right?
> Does there have to be an explicit destroy or similar?
Nope, dynamic array
leledumbo wrote:
works if I change the operator header to:
operator + (const r: r_; const a: t1) s: integer;
from gdb bt, the problem seems to be assignment from shortint to variant:
#0 0x in ?? ()
#1 0x08057205 in SYSTEM_$$_assign$SHORTINT$$VARIANT ()
#2 0x0806bf94 in U_$SYSTEM_$$_
works if I change the operator header to:
operator + (const r: r_; const a: t1) s: integer;
from gdb bt, the problem seems to be assignment from shortint to variant:
#0 0x in ?? ()
#1 0x08057205 in SYSTEM_$$_assign$SHORTINT$$VARIANT ()
#2 0x0806bf94 in U_$SYSTEM_$$_OUTPUT ()
#3 0x080
Is it possible to pass a dummy parameter to a user-defined operator,
with no expectation that it be referenced?
The following test program compiles OK but fails at runtime with an
error 217 on all platforms if the record is empty. It works if it
contains a variant, but not reliably with other