Problem with generic domain

Discussions related to Visual Prolog
Post Reply
Martin Meyer
VIP Member
Posts: 226
Joined: 14 Nov 2002 0:01

Problem with generic domain

Post by Martin Meyer » 20 Feb 2018 20:36

Hello Thomas,

please check this stripped down version of my code. It throws fatal error c098 : Place was not set (in VIP 8 build 801).

Code: Select all

interface someTypes{@Type}   domains     rec = rec(@Type).   domains     valueProvider = (rec*) -> @Type Value.   end interface someTypes   %======   interface objA end interface objA   %---   class objA{@Type} : objA     open someTypes{@Type}   constructors     new : (valueProvider).   end class objA   %---   implement objA{@Type}   clauses     new(_ProvideValue).   end implement objA   %======   interface objB{@Type}   domains     useTypeToPreventWarning = @Type.   end interface objB   %---   class objB{@Type} : objB{@Type} end class objB   %---   implement objB{@Type}     open someTypes{@Type}   clauses     new() :-         %hasDomain(valueProvider, ProvideValue),         ProvideValue = { (RecList) = Val :- [rec(Val)] == RecList },         _ObjA = objA::new(ProvideValue).   end implement objB   %======   implement main   clauses     run() :-         _ObjB = objB::new().   end implement main
When uncommenting the hasDomain line, the message changes to error c504 : The expression has type '(someTypes::rec*) -> @Type procedure', which is incompatible with the type '(someTypes::rec{@Type}*) -> @Type procedure'. Trying to strip down the problem further, I found that following short code produces same kind of error.

Code: Select all

interface someTypes{@Type}   domains     rec = rec(@Type).   end interface someTypes   implement main   clauses     run() :-         hasDomain(someTypes{unsigned}::rec, _Rec).   end implement main
Regards Martin

User avatar
Thomas Linder Puls
VIP Member
Posts: 2307
Joined: 28 Feb 2000 0:01

Re: Problem with generic domain

Post by Thomas Linder Puls » 20 Feb 2018 21:52

Thank you. We will investigate the problems.

As always I believe you can work around the problems by refraining from using @Type in domains and define ordinary parameterized domains instead. And then only use @Type in predicate declarations.

Code: Select all

interface someTypes{@Type}   domains     rec{T} = rec(T). % Do not use @Type here   domains     valueProvider{T} = (rec{T}*) -> T Value. % Do not use @Type here   predicates     ppp : (valueProvider{@Type} VP). % Here @Type can be used   end interface someTypes
The problem is that the domains does not really belong to the objects and therefore it is "problematic" to let them depend on the interface parameters.

But we have allowed such usage, so we will of course address the problem.
Regards Thomas Linder Puls
Prolog Development Center

Post Reply