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

Share Tips, Code Samples, etc. with the Visual Prolog community.
Post Reply
User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

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

Post by Ferenc Nagy » 22 Sep 2014 12:51

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

Code: Select all

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).
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.

Code: Select all

def_style:deleteStyleByNum(Num+0),                
TIA, Regards,
Frank Nagy

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

Post by Thomas Linder Puls » 22 Sep 2014 13:16

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):

Code: Select all

clauses     oneDeleteClick(_Source) = button::defaultAction :-         Style = convert(sci_style, number_int:getInteger()),         def_style:deleteStyleByNum(Style).
Regards Thomas Linder Puls
PDC

Post Reply