Default properties wiki

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Default properties wiki

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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Default properties wiki

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

On Tue, Dec 18, 2018 at 2:32 AM Ryan Joseph <[hidden email]> wrote:
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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal