Nuts and bolts of the language changes made for .NET
Clarion# Language features
In the early days of the Clarion# beta we had an ongoing discussion in the news groups focused on what changes we could make to Clarion# syntax to make it easier to read and write code. We've been busy implementing and testing those changes and we'll deliver them to you in the next release sometime next week.
Here is what's coming up:
We have removed the requirement to use & to declare a reference to an object in the data section. So instead of writing;
myString &String
you'll just write -
myString String
The & operator is still required when you want to declare a reference to a value type. Value types are known as simple or primitive types and they include types such as Byte and Long, and by default, they are passed by value. Also GROUP, QUEUE, FILE, and ANY will require the & operator to declare as a reference. But a reference type can be declared without the & and if the declaration doesn't have any parameters then the object will not be instantiated.
MyClass.P2 PROCEDURE()
A MyCollection ! just a declaration requires explicit instantiation
B MyClass() ! calls the default constructor
CODE
This also means that you will use = operator for all reference types where now &= is currently required. For example:
Aa System.ICloneable
Bb System.ICloneable
CODE
Aa = Bb ! whereas in the current version we write Aa &= Bb
That means we no longer have any need for the := operator, so its now removed from the Clarion# language.
However the &= operator is still needed to work with references to value-types (LONG, SHORT, DATE, GROUP, QUEUE, FILE, etc.)
Another change that was requested and implemented; no more automatic instantiation of objects, in other words all reference types are implicitly a TYPE.
Aa CLASS,TYPE
…
END
is now equivalent to:
Aa CLASS
…
END
The reasoning for this change was well explained by Dave Harms in a ClarionMag article which you can read here: http://www.clarionmag.com:8080/cmag/v9/v9n12instantiation.html
Automatic disposal of objects:
Since we now assign null to objects there is no sense to automatically call DISPOSE. Now it's the user's responsibility to create an object instance and thus it's user's responsibility to call DISPOSE if it's needed.
A word on constructors and declarations:
s System.String('abc')
b bool(True)
the compiler will generate for you as:
s = new String("abc")
b = new bool(true);
Another example to make this very clear:
S System.String() ! parentheses means calling the default constructor
S System.String ! no parentheses so just a declaration without calling any constructor
With the described changes, given this code snippet:
A Aa
B Aa
CODE
A = B
The statement A=B means assigning a reference.
So if the = operator is used to assign a reference, how do you copy content from one object to another? Easy to do and required no language changes, the deep assignment operator :=: can be used for copying of content between like objects.
We have also introduced a new attribute AUTODISPOSE. If you mark a declaration with AUTODISPOSE then DISPOSE is called automatically on exit from the scope.
ZERO based indexes
We are changing Clarion# to use zero based indexes for all arrays and collections. But FILEs and QUEUEs will still use 1-based indexes. The rationale behind this change is that this makes it easier to work with the core Framework objects, 3rd-party .Net libraries, shared libraries you may write, as well as make it easier to translate code samples from C# or VB.
For those of you who have Clarion#, and those who soon will, we have also been looking into adding some features that will make it very easy to pass data back and forth from Clarion# and Clarion 7, so you'll be able to easily work side-by-side, .Net and Win32 Of course that can be done now but the idea is to make it much easier.
We have also been refining some of the UI features in the C7 RTL, and I'll post a blog on those changes later this weekend.
SoftVelocity Inc.
