xsharp.eu • X# 2.6: XS0218
Page 1 of 1

X# 2.6: XS0218

Posted: Wed Sep 23, 2020 1:49 pm
by wriedmann
Hi Chris,
with 2.6 I have a very compile strange error:

Code: Select all

error XS0218: In order for 'XSharp.__Usual.operator &(XSharp.__Usual, XSharp.__Usual)' to be applicable as a short circuit operator, its declaring type 'USUAL' must define operator true and operator false
in this line of code:

Code: Select all

while ! oHallo:EoF .and. oHallo:FieldGet( "what" ) == ""
This is the complete sample code:

Code: Select all

function Start( ) as void
	local oHallo		as DbServer

	System.Console.WriteLine("Hello x#!")

	oHallo := DbServer{ "c:temphallo.dbf" }
	oHallo:GoTop()
	while ! oHallo:EoF .and. oHallo:FieldGet( "what" ) == ""
		oHallo:Skip()
	end
	oHallo:Close()

	return
if I change the code to

Code: Select all

while oHallo:EoF == false .and. oHallo:FieldGet( "what" ) == ""
it compiles.
I have a lot of similar code in my applications....
Please find a complete sample attached.
Wolfgang
DbServerEof.zip
(1.23 KiB) Downloaded 38 times

X# 2.6: XS0218

Posted: Wed Sep 23, 2020 1:59 pm
by Chris
Hi Wolfgang,

Thanks, I see the problem, but in this sample you are using USUALs inside a Core app, which is not really a supported scenario. Is there any reason why you use Core dialect instead of VO in this case?

X# 2.6: XS0218

Posted: Wed Sep 23, 2020 2:10 pm
by wriedmann
Hi Chris,
no, this is was not intended.....
The code comes from a real application, and since I'm using the Core dialect whenever possible to have better code, and sometimes I need to use DbServers there.... and DbServers are returning usuals.
I have to return to my project of a fully typed DBServer.... Unfortunately I'm having some problems with my CoreDBF based on the RDD (don't have found out yet how to set orders).
Sorry for the false alarm!
Wolfgang

X# 2.6: XS0218

Posted: Wed Sep 23, 2020 2:19 pm
by Chris
Hi Wolfgang,

Ah OK, thanks, glad it is not really a problem!

Btw, I wouldn't say that code in Core dialect is "better" than in VO or other dialects, it's just different regarding things like character literals, string literals etc. In fact the only reason I do not always use the VO dialect in all my apps (including XIDE), is that it requires references to the X# runtime.

Btw, if what you are after is making sure you do not have accidentally left untyped locals, parameters etc, you can simply add this in the extra options of your apps:

/vo15-

this will tell the compiler to always check for that, even in VO dialect.

X# 2.6: XS0218

Posted: Wed Sep 23, 2020 2:27 pm
by wriedmann
Hi Chris,
thank you very much!
After seeing all the trouble untyped variables can cause in the compiler and/or the runtime I would prefer to exclude that whenever possible and create code that is clear not only to me, but also to the compiler and the runtime.
For legacy code all the compiler and runtime sorcery is needed, but in newly written code it should not be necessary (therefore I'm using ADO to access ADS).
Wolfgang

X# 2.6: XS0218

Posted: Wed Sep 23, 2020 6:05 pm
by robert
Wolfgang, Chris,

We can also consider to add an operator TRUE and operator FALSE to the Usual type.
This should not hurt, I think.

Robert

X# 2.6: XS0218

Posted: Thu Sep 24, 2020 4:09 am
by wriedmann
Hi Robert,
that would be great, thank you very much!
Personally I think that usuals in Core dialect code will occur.
Wolfgang