[fpc-pascal] Record Method and Operators

Florian Klaempfl florian at freepascal.org
Wed Oct 22 15:56:49 CEST 2008


Cesar Romero schrieb:
> Florian Klaempfl escreveu:
>> Cesar Romero schrieb:
>>  
>>> Hi,
>>>
>>> Im wondering if FPC Team have plans to support Record Methods/Operators
>>> in future versions of FPC
>>> I read the actual "Future plans" and the most closed item is "RTL:: More
>>> compatibility with later Delphi versions."
>>> But it do not means that records can be changed.
>>>
>>> I want to implement my ValueTypes using record with implicit operators
>>> and constructor/destructor, like this code written by a friend, Lee
>>> Nover.
>>>
>>> TSpecifier = record
>>>   S: AnsiString;
>>>   WS: WideString;
>>>   Intf: IInterface;
>>>
>>>   class operator Implicit(const S: AnsiString): TSpecifier;
>>>   class operator Implicit(const C: Cardinal): TSpecifier;
>>>   class operator Implicit(const D: Double): TSpecifier;
>>>   class operator Implicit(const I: Integer): TSpecifier;
>>>   class operator Implicit(const I64: Int64): TSpecifier;
>>>   class operator Implicit(const V: TValue): TSpecifier;
>>>   class operator Implicit(const WS: WideString): TSpecifier;
>>>   class operator Implicit(const Intf: IInterface): TSpecifier;
>>>
>>>   class operator Implicit(const Spec: TSpecifier): AnsiString;
>>>   class operator Implicit(const Spec: TSpecifier): Cardinal;
>>>   class operator Implicit(const Spec: TSpecifier): Double;
>>>   class operator Implicit(const Spec: TSpecifier): Integer;
>>>   class operator Implicit(const Spec: TSpecifier): Int64;
>>>   class operator Implicit(const Spec: TSpecifier): TValue;
>>>   class operator Implicit(const Spec: TSpecifier): WideString;
>>>   class operator Implicit(const Spec: TSpecifier): IInterface;
>>>
>>>   case NativeType: Integer of
>>>     varInteger: (I: Integer);
>>>     varInt64: (I64: Int64);
>>>     varLongWord: (C: Cardinal);
>>>     varDouble: (D: Double);
>>>     varObject: (O: TValue);
>>> end;
>>>
>>> My plans is to have a single framework compatible with Delphi 2007/2009
>>> and FPC, so Ill not use some D2009 only resources, but implicit
>>> operators make the live of users very better to write less and better
>>> code.
>>>
>>> Can I have any hope about this subject?
>>>     
>>
>> What does it prevent you from using FPC's operator overloading
>> capabilities to do so which has FPC for 10 years?
>> _______________________________________________
>> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>>   
> freepascal search is not working,
> With google I found
> http://courses.cs.vt.edu/~cs3304/FreePascal/doc/ref/node12.html
> 
> Interesting but is not what I mention, it is just the basic.
> 

In which regard, quoting: "The assignment operator is also used to
convert types from one type to another. The compiler will consider all
overloaded assignment operators till it finds one that matches the types
of the left hand and right hand expressions. If no such operator is
found, a 'type mismatch' error is given. " ? It's not our fault that CG
choose another syntax.



More information about the fpc-pascal mailing list