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

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

Unread post by Ferenc Nagy »

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: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

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