Looking with ILSpy 3 and Fabrice' plugin into some code, i see things like:
self:cRptFile := (self:cRptFile ?? "")
Is this a new short form of default? Or something from the spy-integration?
Or is this old and i did miss it ;-?
Good night!
Karl
New conditional operator or what?
New conditional operator or what?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
New conditional operator or what?
Hi Karl,
This is c#'s "Null coalescing" operator according to https://docs.microsoft.com/en-us/dotnet ... operators/
x ?? y – returns x if it is non-null; otherwise, returns y.
(I know, it makes code so easy to read )
Probably ILSpy processed some code which looked like
IF self:cRptFile == NULL
self:cRptFile := ""
ENDIF
or similar and translated it into the ?? form. But this operator is not supported in X# and the plugin probably did not know how to translate it, so it left it like that.
One solution might be for Fabrice to extend this code to an IF statement, but I don't know if he has such freedom in the plugin. Maybe translate it to an iif() statement instead?
Another solution would be to add support for this operator in the compiler, but personally I'd really prefer not to
Chris
This is c#'s "Null coalescing" operator according to https://docs.microsoft.com/en-us/dotnet ... operators/
x ?? y – returns x if it is non-null; otherwise, returns y.
(I know, it makes code so easy to read )
Probably ILSpy processed some code which looked like
IF self:cRptFile == NULL
self:cRptFile := ""
ENDIF
or similar and translated it into the ?? form. But this operator is not supported in X# and the plugin probably did not know how to translate it, so it left it like that.
One solution might be for Fabrice to extend this code to an IF statement, but I don't know if he has such freedom in the plugin. Maybe translate it to an iif() statement instead?
Another solution would be to add support for this operator in the compiler, but personally I'd really prefer not to
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
New conditional operator or what?
Hi Chris,
PMFJI, but was not added a default operator in the last versions of X#?
Wolfgang
PMFJI, but was not added a default operator in the last versions of X#?
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
New conditional operator or what?
Wolfgang,
Yes you are right. There is now a DEFAULT expression:
This sets a to b, but if b is NULL then it sets it to ""
Robert
Yes you are right. There is now a DEFAULT expression:
Code: Select all
a := b DEFAULT ""
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu