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

Ambiguous name error with non-unique domains

Unread post by dcgreenwood »

I have an add build problem that has come along intermittently over the last few months. I have a large set of simple domains, many of which include the word "none" as one of its members. Example

Code: Select all

domains %General use domains     flag = yes; no.     valid = valid; notvalid.     updowntype = up; down.     gamephasetype = takethelead; raisetheplan; executetheplan; recount; checkendgame; none. %domains for characters; weapons and stats     gender = female; male.     effect = poisoned; hypnotized; none.     faction = hero; villain; none.     messagetype = igotthis; helpme; goforit; canthelpnow; none.
My project has half a dozen classes, all of which use these domains, so I have them declared in main.cl with "open core, main" included in the .cl and .pro files of each class.

Sometimes(!) not always, after adding new classes I start getting the error
e217 Ambiguous name usage 'none' ('core::none' or 'core::none' or...)
followed by s217 warnings repeating the same error message for each domain with 'none' in it.


The actual error is linked to a specific line of a clause that is using 'none', but I am certain that the variable Effect is declared as a domain with 'none' in it.

Code: Select all

                elseif ObjectiveVerb = effect and Effect <> none then

I've had this happen a few times now, and solved sometimes by making sure I was opening main in both the cl and pro files, but now I have it again and I definitely have main open in both the cl and pro files. Is there something else that cause it to require all the elements in the domains to be unique? Or am I completely off base as to what is actually causing it?

Code: Select all

class objectiveHandler : objectiveHandler     open core, main, common
User avatar
Thomas Linder Puls
VIP Member
Posts: 1395
Joined: 28 Feb 2000 0:01

Re: Ambiguous name error with non-unique domains

Unread post by Thomas Linder Puls »

When a name is visible in two (or more) opened scopes (inherits and supports also open the corresponding scopes) then unqualified usages of the name becomes ambiguous.

For functors (like none) that is a bit surprising, because such functors can be used several times within in a single scope without causing any ambiguity.

Maybe we should change the language semantics in this point. But until we (eventually) do that, you will have to live with the current situation.

You can choose to use qualification myClass::none, core::none, etc. Or alternatively you can use some other name than none.

In many places we use no<DomainName> instead of none.

In you case it would be:

Code: Select all

domains     ...     gamePhaseType = takeTheLead; raiseThePlan; executeThePlan; recount; checkEndGame; noGamephasetype.     ...     effect = poisoned; hypnotized; noEffect.     faction = hero; villain; noFraction.     messageType = iGotThis; helpMe; goForIt; cantHelpNow; noMessageType.
You may actually find that a clarity advantage in the rest of the code.
Regards Thomas Linder Puls
PDC
dcgreenwood
Posts: 24
Joined: 16 Jan 2021 1:33

Re: Ambiguous name error with non-unique domains

Unread post by dcgreenwood »

Thanks. I did decide to use "no<domain> or similar and yes, in a way, it improves clarity of the code. What is very odd is my code was functioning fine with "none" in many domains for months...then it stopped.

At any rate, thanks for the response. It confirms for me that this is, mostly, normal behavior, which I shouldn't try to fight :-)
Post Reply