Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Another feature suggestion

Unread post by Harrison Pratt »

After having explored PropertyDepot ideas, it seems that a nice feature for VP would be a compiler directive that could automatically insert the property getters and setters into the implementation file.
That would make a database of properties less important.

Maybe something like this:

Code: Select all

interface myClass   properties [autoProperty] % automatic code appended to myClass.pro     tally : integer := 0. % count of everything     total : real. % sum of everything   properties % no code generation     textColor : ::color.     bgColor : ::color.     centerText : boolean.   end interface myClass

Code: Select all

Implement myClass ... % This PROPERTY code is maintained automatically, do not update it manually. %  11:56:28-10.2.2023   facts % for autoProperties ... clauses % for autoProperties ... % end of automatic PROPERTY code   end implement myClass
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Another feature suggestion

Unread post by Thomas Linder Puls »

Well, I have two "problems" with this suggestion. First of all it is a strict rule that implementation details are written in the implementation; interfaces only defines the interface.

Secondly, the suggested auto code has exactly the same effect as implementing the property with a fact:

Code: Select all

interface ... property     aProperty : someDomain.   implement ... facts     aProperty : someDomain := ....
Implementing a property using "getters" and "setters" mainly makes sense, if you want some other functionality than the plain get/set functionality. But in that case the code will be different from the auto code and then it cannot be maintained automatically.
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Another feature suggestion

Unread post by Harrison Pratt »

Thanks ... it seems I've been under-thinking this. :oops:
User avatar
Gukalov
VIP Member
Posts: 62
Joined: 5 Oct 2011 15:16

Re: Another feature suggestion

Unread post by Gukalov »

I have a dream)))
The simplest set/get declaration in class/interface with value settings:

Code: Select all

properties     aProperty : someDomain := someValue.
also declares the corresponding fact without extra words in implement.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Another feature suggestion

Unread post by Thomas Linder Puls »

Unfortunately, that dream will not come through. Interfaces define the interface of objects the implementation is written in the implementation. Also recall that though you think of a class and interface together, a single interface can be used for many classes.

Likewise a class defines the "interface" of a class, the implementation is written in the implementation.
Regards Thomas Linder Puls
PDC
Post Reply