- Written by Robert van der Hulst
- Created: 11 November 2015
Below is a list of some of the most visible new language features in the Core language of X# , compared to Visual Objects and Vulcan.
As you can see many new keywords were introduced, but these are positional: they will also be recognized as Identifiers on other places, so there is very little chance that you will have to make changes to avoid naming conflicts.
Entities and Statements
Below is a list of the new commands / entities inside X#. There are also some new options for existing commands. A full list of changes will be available later.
|DEFINE <id> := <Expression>||The VO Define is back again in X#. |
It will be compiled into a constant of the Globals class, the same class in which all Functions and Methods are implemented.
The biggest advantage of a DEFINE over the preprocessor DEFINEs in Vulcan.NET is that there is no longer a chance that a DEFINE with the same name as a Method, Property or Variable will lead to incomprehensible compiler errors.
|USING STATIC <Name>|| |
The STATIC modifier for USING (note that the # sign is no longer needed) allows you to name a static class. When you do so you can then use the methods of this class as functions.
USING STATIC System.Console
|BEGIN USING <Var> |
|The USING block allows you to control the lifetime of a variable. |
If <Var> has a destructor then it will be automatically destructed once the block has finished
|SWITCH <Expression> |
|The SWITCH statement generates a more efficient jump structure than the DO CASE command. Also the expression is only evaluated once.|
|BEGIN UNSAFE |
|Allows unsafe code in the context of this block , regardless of the compiler setting for the project as a whole.|
|BEGIN CHECKED |
|The statements inside the block will have checked conversions, regardless of the compiler setting for the project as a whole.|
|BEGIN UNCHECKED |
|The statements inside the block will have unchecked conversions, regardless of the compiler setting for the project as a whole.|
|VAR <Identifier> := <Expression>||This is a synonym for LOCAL IMPLIED|
CLASS <Id> < <ParamName> >
Creating Generic classes is now supported in X#, with all the features that C# also has
CLASS MyList<T> WHERE T IS CLASS
CLASS MyList<T> WHERE T IS ICustomer, NEW()
|ASYNC - AWAIT||The ASYNC AWAIT infratructure is fully available inside X#|
Below are some new expressions that are available in X#
|<Expression> IS <Type>||Allows to check an expression for a type. Can be used in stead of IsInstanceOf() and will perform better|
|Conditional Access Operator ? <Expression> ? <Expression>|| |
Conditional access for properties, methods etc.
VAR temp := MyList
|<Expression> DEFAULT <Expression>|| |
The default operator allows you to inline a check for NULL:
This translates to the same as
Foo() will be evaluated only once. And only when the result is NULL then Bar() will be evaluated.
LINQ Query expressions are now supported:
VAR CustQuery = FROM Cust in Customers WHERE Cust.City = "Athens" ORDER BY Cust.Zipcode Select Cust
The full LINQ feature set will be supported by X#: