Page 1 of 1

Domains across classes?

Posted: 1 Jun 2021 19:40
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?

Re: Domains across classes?

Posted: 1 Jun 2021 20:03
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???

Re: Domains across classes?

Posted: 3 Jun 2021 2:47
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.

Re: Domains across classes?

Posted: 3 Jun 2021 8:49
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.