FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


Add '+0' is the shortest conversion among integer-like domains.

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog Tips & Samples
View previous topic :: View next topic  
Author Message
Ferenc Nagy



Hungary
Joined: 24 Apr 2007
Posts: 378

PostPosted: 22 Sep 2014 12:51    Post subject: Add '+0' is the shortest conversion among integer-like domains. Reply with quote

The different integer-like subtypes in calling and called procedure result error message.


domains
sci_style = unsigned8
predicates
deleteStyleByNum:(sci_style Number) determ.
%------------------------------------
predicates
    oneDeleteClick : button::clickResponder.
clauses
    oneDeleteClick(_Source) = button::defaultAction :-
        Num=number_int:getInteger(),
        def_style:deleteStyleByNum(Num).

Quote:
The expression has type '::integer', which is incompatible with the type 'sciLexer_native::sci_style' Reporter.pro Enhanced_Report\

The simplest correction: Add zero to the integer variable in the calling statement.


def_style:deleteStyleByNum(Num+0),


_________________
TIA, Regards,
Frank Nagy
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3094

PostPosted: 22 Sep 2014 13:16    Post subject: Reply with quote

I think this is a bad idea: The code lookes like a sum (even a silly sum), but it in fact a type conversion.

I think it is better to write code that reflects what it does (even if it is not written in the shortest possible way):

clauses
    oneDeleteClick(_Source) = button::defaultAction :-
        Style = convert(sci_style, number_int:getInteger()),
        def_style:deleteStyleByNum(Style).


_________________
Regards Thomas Linder Puls
Prolog Development Center
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 Tips & Samples 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