[fpc-devel] "Default" discussion for SmartPointers etc
hnb.code at gmail.com
Mon Aug 1 23:30:53 CEST 2016
2016-07-26 21:59 GMT+02:00 Sven Barth <pascaldragon at googlemail.com>:
> First of let me tell you that in essence and in general I'm in support
> of your "default" idea
Not only you Sven ;) I found interesting comment by Allen Bauer, seems like
"default" idea is right direction. Completely independent source. I didn't
know before about this comment. Comment created in May 2015 strictly
related to nullable types. My work starts in 2014 and "default" in my case
was created for smart pointers and ARC objects :)
Additional note: IMO 'default' for fields is more powerful and together
with default for non-indexed properties is awesome combo.
=== begin quotation ===
Current working theory of Nullable<T>.
Nullable<T> = record
property Value: T read FValue; default;
Using the default directive to "hoist" the operators of "T". Currently the
default directive only works for array properties by "hoisting" the ''
operator. Marking a non-array property with default will make the
containing type behave as that type.
This, coupled with some intrinsic compiler knowledge of the Nullable<T>
type will make Nullable<T> work without any addition of keywords or other
standard functions or procedures.
Using the "default" directive on a non-array property will work for any
type, except for having the null-propagation semantics.
When considering language features, I try and not only make it work for the
intended purpose, but also broaden reach of any supporting feature. In the
above scenario, even user-defined operators on "T" will be properly hoisted
=== end quotation ===
source (one of last comments) :
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel