Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 459 Joined: 5 Nov 2000 0:01
Post
by Harrison Pratt » 31 May 2024 13:13
It is straightforward to refer to other predicates in predicate and fact declarations.
Is there a way to similarly directly refer to a database fact?
Code: Select all
class facts - menuDB
menuAction : ( string ActionName , predicate Action ) .
namedProperty : ( string PropertyName , fact Property ) . % <== can VP do something like this ?
clauses
menuAction( "Open database" , dbOpen) .
menuAction( "Export database" , dbExport) .
Thomas Linder Puls
VIP Member
Posts: 1469 Joined: 28 Feb 2000 0:01
Post
by Thomas Linder Puls » 3 Jun 2024 8:14
The short answer is no.
facts are very different from each other (different number of arguments of different types).
But if we are for example considering fact variables of type string, then you can assert getter and the setter predicates.
Code: Select all
class facts
namedProperty : ( string Name , function{ string} Get , predicate{ string} Set ) .
clauses
namedProperty( "aaa" , { = aaa } , { ( S ) :- aaa := S } ) .
namedProperty( "bbb" , { = bbb } , { ( S ) :- bbb := S } ) .
But there is no simple syntax for this.
(You will most likely not need a fact for this, because it is not likely that you are going to invent additional facts, getters and setters while during program run).
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 459 Joined: 5 Nov 2000 0:01
Post
by Harrison Pratt » 3 Jun 2024 10:27
Very clear answer -- thank you!