Miscellaneous questions about converting VO code to X#

This forum is meant for questions and discussions about the X# language and tools
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Miscellaneous questions about converting VO code to X#

Post by robert »

Kees,
Kees Bouw wrote: Tue Apr 23, 2024 10:16 am Found it, it is probably String2Symbol("#NULL_DATE") right?
String2Symbol("NULL_DATE")

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Kees Bouw
Posts: 97
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

Re: Miscellaneous questions about converting VO code to X#

Post by Kees Bouw »

Hi all,

In the application I am converting to X# I found that in many places it relies on the fact that NULL_STRING is in fact an empty string. In X# however, NULL_STRING seems to be equal to NULL or NIL. In VO NULL_STRING seems to be just "". This behaviour can be simulated in X# by setting the /vo2 option. But because I want to convert everything to X# I am reluctant to change options which make it more like VO. Also this option initialises every string variable to an empty string automatically which I don't need or want. I am thinking about simply replacing every occurrence of NULL_STRING with "". Before I do that, I would like to ask if anyone knows any reason why that would not be a good idea.

Kees.
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Miscellaneous questions about converting VO code to X#

Post by Chris »

Hi Kees,

I think it's better to just enable the /vo2 option, this is why we introduced it, to help porting applications from VO.

In VO, not only NULL_STRING practically means "", but all locals and class variables are also used like that:

Code: Select all

FUNCTION Start() AS INT
LOCAL c AS STRING
LOCAL o AS TestClass
? c == "" // TRUE
o := TestClass{}
? o:c == "" // TRUE
RETURN 0

CLASS TestClass
EXPORT c AS STRING
END CLASS
When you enable the /vo2 option in X#, the compiler mimics also this behavior. If you do not initialize (or forget to do that) all such vars to "" in X#, all sorts of problems may arise (at runtime...) in cases where your VO code relies on that.

So I'd suggest to just enable the option, nothing wrong about it, it only makes code say 0.001% slower... If you write a new .Net app, it's probably better to not use it, but even if you want to enable it also in this case, there's nothing wrong with it.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply