Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-12

Default properties wiki

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

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

Ben Grasset
to Ryan Joseph

Nice! Very thorough. I think most of these are very useful.

AM Ryan Joseph wrote 34 lines
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 _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal