No compiler error

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

No compiler error

Post by Horst »

Hello

This line makes no compiler error +self

Code: Select all

	cHtml 			+= +SELF:odbKontroll:FIELDGET(#Kontroller) 
Horst
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: No compiler error

Post by Chris »

Hi Horst,

I think that strictly speaking this is not an error, because the expression returned by SELF:odbKontroll:FIELDGET(#Kontroller) can be a number (since FIELDGET returns a usual), and the +/- unary operator is valid for numbers. Using the plus sign might sound strange, but it's the same as using the minus sign, which is valid in the case of a number:

nNumber += -SELF:odbKontroll:FIELDGET(#Kontroller)

This is adding the negative value of the field, of course it would make more sense to use -= in the first place, but still, this is valid syntax.

Of course in your case you are using a string variable, in which it is not valid to add/subtract a number, but I don't think the compiler can be made that smart to recognize this (since it does not know the return value type of FIELDGET). Unless Robert has a different idea..
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: No compiler error

Post by robert »

Horst, Chris,

This is valid syntax. The usual type supports both the unary plus and unary minus operations.
The result of that operation is then casted to a string for the += operation with cHtml.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply