[fpc-pascal] Default properties wiki
Ryan Joseph
ryan at thealchemistguild.com
Tue Dec 18 08:01:04 CET 2018
I decided to make a wiki going over all the details of default properties which I’ve covered so far, including various usage examples. There’s some questionable stuff in here and it’s actually a pretty complicated concept so I wanted to share it publicly.
Some changes and things of interest:
- While exploring the idea I’ve made it possible to enable multiple defaults because it’s trivial to just stop the search at the first default if it’s decided to make not sense. There’s some potential for multiple “implements” defaults properties to ease delegation which is interesting.
- Because it’s technically possible default properties on array types are enabled. This makes it possible to index into an array wrapped in a record using [] syntax and for..in loops on the record itself without making an enumerator object.
- For certain statements like if..then it’s possible to access the default property (for ordinal types like boolean). I think this is going to be helpful for nullable types in particular so it was added.
- At the end I included some notes on technical details so you can easily find what changes I made in the compiler. I wasn’t sure at all how to implement this but this what I’ve arrived at as the best solution. Lots of cleanup required of course if we decided this is the correct way forward.
http://wiki.freepascal.org/default_properties
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list