FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


Problem with incompatible types

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog
View previous topic :: View next topic  
Author Message
Martin Meyer



Frankfurt a.M., Germany
Joined: 14 Nov 2002
Posts: 223

PostPosted: 2 Sep 2017 13:14    Post subject: Problem with incompatible types Reply with quote

Hello Thomas,

please have a look at below stripped down version of my code. It throws error c504 : The expression has type 'syntax_t_nt::grammarSymbol{::unsigned, ::unsigned}', which is incompatible with the type 'syntax_t_nt::grammarSymbol{@Terminal, @Nonterminal}' in VIP 8.0.0. How can I circumvent the problem?

interface syntax_t_nt{@Terminal, @Nonterminal}

domains
    grammarSymbol =
        t(@Terminal T);
        nt(@Nonterminal Nt).
    grammarString = grammarSymbol*.

end interface syntax_t_nt

%======

interface cfg{@Terminal, @Nonterminal}
    open syntax_t_nt{@Terminal, @Nonterminal}

predicates
    isNullable : (grammarString GrmStrg) determ.

end interface cfg

%======

interface cfgSupportSite{@Terminal, @Nonterminal}

predicates from cfg{@Terminal, @Nonterminal}
    isNullable/1

end interface cfgSupportSite

%======

class unsignedCfg : cfg{unsigned, unsigned}
end class unsignedCfg

%---

implement unsignedCfg
    open syntax_t_nt{unsigned, unsigned}
    supports cfgSupportSite{unsigned, unsigned}

clauses
    isNullable([nt(Nt) | RestGrmStrg]) :- %the error refers to nt(Nt) in this line
        doSomethingWithAnUnsigned(Nt),
        isNullable(RestGrmStrg).

    isNullable([]).

predicates
    doSomethingWithAnUnsigned : (unsigned).
clauses
    doSomethingWithAnUnsigned(_).

end implement unsignedCfg

%======

implement main

clauses
    run() :-
        _ = unsignedCfg::new().

end implement main


_________________
Regards Martin
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3104

PostPosted: 4 Sep 2017 9:53    Post subject: Reply with quote

In this particular case a workaround is not to use open in the cfg interface:

interface cfg{@Terminal, @Nonterminal}

predicates
    isNullable : (syntax_t_nt{@Terminal, @Nonterminal}::grammarString GrmStrg) determ.

end interface cfg

We will of course look for a non-workaround solution as well.

_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Martin Meyer



Frankfurt a.M., Germany
Joined: 14 Nov 2002
Posts: 223

PostPosted: 4 Sep 2017 17:38    Post subject: Reply with quote

Thank you! I followed your advice and it works now.
_________________
Regards Martin
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum