Discussions related to Visual Prolog
dcgreenwood
Posts: 24
Joined: 16 Jan 2021 1:33

Domains across classes?

Unread post by dcgreenwood »

I've been doing most of my project so far within main and the gui packages but am now trying to split main into separate packages to be more OO. However I can't figure out how to get my domains to work outside of the main class. I've read the tutorial but haven't found anything specifically addressing this. I tried referencing the domain as "main::domainname" but that didn't work. I can Kludge it by converting to string and then back to a local domain, but there must be a better way. I still don't really understand interfaces, but my reading doesn't suggest that an interface would help anyway. Can domains be declared to be visible/usable across classes?
User avatar
Gukalov
Active Member
Posts: 33
Joined: 5 Oct 2011 15:16

Re: Domains across classes?

Unread post by Gukalov »

I tried referencing the domain as "main::domainname" but that didn't work.
Hm... The declaration of "domainname = .... " is in the main.CL???
dcgreenwood
Posts: 24
Joined: 16 Jan 2021 1:33

Re: Domains across classes?

Unread post by dcgreenwood »

I figured it out. My question was, how to use an interface to extend the scope of a domain
For example, I have a project with the default class "main"

In main.cl, I declare a domain location

Code: Select all

    location =         a20003; a2200; a2600.
I create a package/class called "setup"
In setup.i, I change "open core" to

Code: Select all

interface setup     open core, main end interface setup
in setup.pro I declare a predicate

Code: Select all

class predicates     predicatename : (location Location, string Name).
But I then got an e205, unknown domain/interface in pack main.pak

But I solved it by ALSO putting

Code: Select all

implement setup     open core, main
in setup.pro
I didn't realize you needed the

Code: Select all

open main
in the other files, not just in the interface file.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1244
Joined: 28 Feb 2000 0:01

Re: Domains across classes?

Unread post by Thomas Linder Puls »

When referencing your domain location and the functors a20003, ... in another scope you can write, main::location and main::a20003, ...

But if you open main in a scope, then you can skip the main:: qualifications within that scope.
Regards Thomas Linder Puls
PDC
Post Reply