-
- Posts: 24
- Joined: 16 Jan 2021 1:33
Domains across classes?
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?
-
- VIP Member
- Posts: 68
- Joined: 5 Oct 2011 15:16
Re: Domains across classes?
Hm... The declaration of "domainname = .... " is in the main.CL???I tried referencing the domain as "main::domainname" but that didn't work.
-
- Posts: 24
- Joined: 16 Jan 2021 1:33
Re: Domains across classes?
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
I create a package/class called "setup"
In setup.i, I change "open core" to
in setup.pro I declare a predicate
But I then got an e205, unknown domain/interface in pack main.pak
But I solved it by ALSO putting
in setup.pro
I didn't realize you needed the in the other files, not just in the interface file.
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.
In setup.i, I change "open core" to
Code: Select all
interface setup
open core, main
end interface setup
Code: Select all
class predicates
predicatename : (location Location, string Name).
But I solved it by ALSO putting
Code: Select all
implement setup
open core, main
I didn't realize you needed the
Code: Select all
open main
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
Re: Domains across classes?
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.
But if you open main in a scope, then you can skip the main:: qualifications within that scope.
Regards Thomas Linder Puls
PDC
PDC