* * *

Author Topic: Is in plans to realize overload properties?  (Read 5918 times)

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 180
Re: Is in plans to realize overload properties?
« Reply #15 on: October 12, 2016, 10:58:13 am »
FPC supports overloaded properties - but it's a bug in FPC.

Just overload the getters/setters and don't redefine the property. See http://mantis.freepascal.org/view.php?id=28949

SnoopyDog

  • New member
  • *
  • Posts: 15
Re: Is in plans to realize overload properties?
« Reply #16 on: October 13, 2016, 01:20:18 pm »
@ondrejpokorny: Thank you very much for sharing this information. You made my day :) Now i can use Lazarus 1.6 with my existing code! Just need to play with compiler switches...
« Last Edit: October 13, 2016, 01:22:16 pm by SnoopyDog »

staratel20

  • Full Member
  • ***
  • Posts: 199
Re: Is in plans to realize overload properties?
« Reply #17 on: November 01, 2016, 11:00:41 am »
FPC supports overloaded properties - but it's a bug in FPC.
if you call it 'bug' , not 'future', so is in plan to fix it? If so, I don't understand SnoopyDog's joy, because code will not work in future.
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

Thaddy

  • Hero Member
  • *****
  • Posts: 4429
Re: Is in plans to realize overload properties?
« Reply #18 on: November 01, 2016, 11:23:28 am »
feature may well be implemented in the future....I guess
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

staratel20

  • Full Member
  • ***
  • Posts: 199
Re: Is in plans to realize overload properties?
« Reply #19 on: November 01, 2016, 04:55:43 pm »
Also want to add, that variant types less preferable than overloaded getters/setters. Because in 2nd case you understand all parameters types class works with by just looking at class declaration. In 1st case you need also jump/scroll to implementation + analyse code. Thus useless seconds accumulate to useless hours of "programming".
« Last Edit: November 01, 2016, 04:57:53 pm by staratel20 »
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

Blestan

  • Sr. Member
  • ****
  • Posts: 452
Re: Is in plans to realize overload properties?
« Reply #20 on: March 03, 2017, 03:46:31 pm »
in the end of the day i do not understands if this "feature" (allowing properies to use differnt type of indices ) is future safe or is just a bug in the compiler...
help apreciated because my code relies on this
thanks!
Speak postscript or die!
Translate to pdf and live!

Thaddy

  • Hero Member
  • *****
  • Posts: 4429
Re: Is in plans to realize overload properties?
« Reply #21 on: March 03, 2017, 04:37:18 pm »
in the end of the day i do not understands if this "feature" (allowing properies to use differnt type of indices ) is future safe or is just a bug in the compiler...
help apreciated because my code relies on this
thanks!

What you need is a dictionary (or a map, same thing) . TDictionary<TKey.TValue> or TFPGMap<TKey,TValue>
Both of these can query for items of either type Key or Type Value. property Keys[], property Values[], much more clear.

Although the example code with the class helper still compiles in trunk, you will run into trouble implementing a sane result from it ;) But it still does work. And please use generics.


"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Awkward

  • New member
  • *
  • Posts: 32
Re: Is in plans to realize overload properties?
« Reply #22 on: March 03, 2017, 05:01:04 pm »
if only i can realize my class for ini-files with default property where can use different count of array parameters... one, two or three...

Blestan

  • Sr. Member
  • ****
  • Posts: 452
Re: Is in plans to realize overload properties?
« Reply #23 on: March 03, 2017, 05:29:20 pm »
@Thaddy:  my own object notation (XON) is itself a dictioanry or if you call it a map- its a an super data structure capable of holding scalar values or arrays ( integer index) or objects ( string indices) ... for the elegance of the code it's better to be able to write:
 xvarA[1]:=1; // xvar.GetChildByIndex(1).AsInteger=1;
 xvarB['name']:='blaBlaBla'; xvar.GetChildByKey.AsString='BlaBlaBla';

i hole this will still work in the future
Speak postscript or die!
Translate to pdf and live!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus