[fpc-pascal] Re: User-defined operators and dummy parameters
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Sat Aug 10 14:36:43 CEST 2013
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 0x00000000 in ?? ()
> #1 0x08057205 in SYSTEM_$$_assign$SHORTINT$$VARIANT ()
> #2 0x0806bf94 in U_$SYSTEM_$$_OUTPUT ()
> #3 0x0804816f in plus (R=..., A=0xb7ff7068) at x.pas:30
> #4 0x080482ef in main () at x.pas:47
[Digs] Thanks, you're right :-) Also, if the array elements are variants
then there's no error.
So in other words, it might turn out to be safer to have separate
operators returning integer, double and so on.
I appreciate that I'm abusing the language here, but /should/ the
original implicit conversion have worked?
>> Doesn't work without tuple support
>
> a1 := t1.create(1,2,3,4,5);
Noted. What happens in this case if
a1 := t1.create(1,2,3,4,5);
..
a1 := t1.create(6,7,8,9);
Does there have to be an explicit destroy or similar?
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list