[fpc-devel] "Default" discussion for SmartPointers etc
Michael Van Canneyt
michael at freepascal.org
Wed Jul 27 13:11:05 CEST 2016
On Wed, 27 Jul 2016, Maciej Izak wrote:
> 2016-07-27 11:24 GMT+02:00 Jonas Maebe <jonas.maebe at elis.ugent.be>:
>>
>> On a more general note, I think the fact that @recordvar no longer is a
>> pointer to the record is wrong. You need a different keyword instead of
>> "record" in that case (or possibly a modifier for the "record" keyword,
>> like with "class abstract" -- but this is not a record at any more than an
>> shortstring is a record, so I don't think that's a good idea either).
>>
>> Completely changing how certain aspects of a record are treated by the
>> compiler only based on the fact that somewhere there is a "default"
>> modifier for one field is not good. You should definitely not have to go
>> through an entire declaration of a record to be able to know how it will
>> behave.
>
>
> I was thinking on additional modifier for that before. We can use something
> like this:
>
> === code begin ===
> type
> TNullable<T: record> = record proxy to Instance
> public type
> PT = ^T;
> strict private
> Instance: ^T; // no default word anymore
> function GetValue: T;
> === code end ===
Record proxy will not work. Proxy can be the name of a field.
So I think the modifier should be before the record, just as 'packed' or 'bitpacked' are.
And contrary to 'to instance', I prefer the default:
type
TNullable<T: record> = proxy record
public type
PT = ^T;
strict private
Instance: ^T; default;
function GetValue: T;
end;
Michael.
More information about the fpc-devel
mailing list