The compiler for the upcoming 2.8 build of X# has received an "overhaul". We have updated the Roslyn code to the latest C# level (the same C# that comes with VS 2019 Preview 4). This means that we now benefit from many changes in the C# compiler. You should see that the compiler is a bit faster. The new compiler requires .Net framework 4.7.2 or .Net core 3.0. The apps created with the new compiler can still target the framework versions from 2.0 until 4.8, .Net Core 2.0, 3.0 and .Net 5 and .Net 6.

We have also taken the opportunity to add a few new things to the language:

Local Functions and Local Procedures

You can declare local function  and local procedures inside methods, properties, functions and procedures.

The syntax is

LOCAL FUNCTION <Name> (<Parameters>) AS <Type>
. statements

Some remarks:

  • parameters are optional but must be typed
  • return type is mandatory
  • the local function automatically has access to the local variables and instance variables from its surrounding code.
  • the local function cannot have attributes

Embedded bodied Members

C# has the option to write simple bodies of methods, functions and properties with a one liner and the => operator. We support that too now. For example:

FUNCTION Multiply ( nLhs AS LONG, nRhs AS LONG) AS LONG => nLhs * nRhs

This does the same as

   RETURN nLhs * nRhs

 but is a bit compacter.
You can use this notation for FUNCTION, PROCEDURE, ACCESS, ASSIGN, METHOD, PROPERTY etc.

Using declarations

You can now declare a variable and tell the compiler to automatically dispose it at the end of the block where it is declared. This means that you will no longer have to use a BEGIN USING .. END USING block. Behind the scenes the compiler will automatically create such as block.


USING VAR reader := StringReader{manyLines}

Null Coalescing Operator and Null Coalescing assignment

This operator allows you to choose the first non NULL value of 2 or more values. Note that the values MUST be reference typed. Otherwise the compiler will complain that the value cannot be null.

 x := A ?? B

This assigns the reference value A to x, but when A is NULL then B is assigned. So this is the equivalent of x := iif (A != NULL, A, B)

A ??= B

This assigns B to A when A is NULL. So this is the equivalent of

A := IIF(A != NULL, A, B) 

Native Integers

We have added 2 new data types:

  • NINT (signed native integer)
  • NUINT (unsigned native integer)

These types are  32 bit integer on x86 machines and a 64 bit integer on x64 machines.

More changes will follow in the coming months.

A prerelease version of this new compiler will be released to our FOX subscribers in a few days.

You are not authorised to post comments.