Constructor's type not determined

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

Constructor's type not determined

Unread post by Martin Meyer »

Hi Thomas,

the compiler build 7500 throws error c520 : Impossible to determine the type of the term on this code. I suppose, it is not intended:

Code: Select all

interface myObj{@Type}     domains         useTheParameter = @Type. end interface myObj   class myObj{@Type} : myObj{@Type} end class myObj   implement myObj{@Type} end implement myObj   implement main     clauses         run() :-             _ = myObj{integer}::new. end implement main
Regards,
Martin
Vitaly Markov
Active Member
Posts: 40
Joined: 30 Nov 2003 0:01

Unread post by Vitaly Markov »

parenthesis:

run() :-
_ = myObj{integer}::new().
Martin Meyer
VIP Member
Posts: 280
Joined: 14 Nov 2002 0:01

Unread post by Martin Meyer »

Hello Markov,

appending the parenthesis is not compellent. myObj{integer}::new is a legal expression. It has the type () -> myObj{integer}, i.e. a function type.

Regards,
Martin
Vitaly Markov
Active Member
Posts: 40
Joined: 30 Nov 2003 0:01

Unread post by Vitaly Markov »

Hello Meyer!
You try:

run() :-
_ = myObj{integer}::new().

It is a good tablet :-)
User avatar
Thomas Linder Puls
VIP Member
Posts: 1177
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The type checker is only supposed to say "impossible to determine the type" if something remains polymorphic, i.e. if one of the types can be chosen arbitrarily and still solve the system.

That would have been the case it you had written:

Code: Select all

clauses     run() :-         _ = myObj::new.
But when instantiating the class with integer, only integer will solve the system. So this is a bug.

The situation will however not happen often, because normally you will use the value (rather than just throwing it away like here), and then the usage will typically fix the type:

Code: Select all

clauses     run() :-        Factory = myObj::new,        use(Factory).
Should nothing fix the type, you can fix it explicitly using hasDomain:

Code: Select all

clauses     run() :-        hasDomain(core::function{integer}, Factory),        Factory = myObj::new,        use(Factory).
Or using the new (i.e. vip 7.5) function form of hasDomain:

Code: Select all

clauses     run() :-        Factory = hasDomain(core::function{integer}, myObj::new),        use(Factory).
We will of course address the bug.
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 280
Joined: 14 Nov 2002 0:01

Unread post by Martin Meyer »

Thanx Thomas and VITALY (I guess, by "Hello Meyer" you are giving me a wink, that Vitaly is your first name :D )!

Best Regards,
Martin
Post Reply