You probably know this already, but the single line syntax for properties is already supported by the compiler:
The GET clause expects an expression, the SET clause expects an expression list.
No I have not known it, well done, good to know. Must have missed it in the "whats new" section.
Regards,
Jack
______________________
Johan Nel
Boshof, South Africa
Robert van der Hulst wrote:Jack,
This was probably never mentioned in the readme, since the single line property syntax is also supported b Vulcan.
You can see the EBNF notation for the property on: http://www.xsharp.eu/help/property.html
Robert
If I remember correctly the #command single line was initially shown before PPOPERTY was available in Vulcan as wrapper to ACCESS/ASSIGN to align it with the then to be released PROPERTY.
The #command was done to not have to GET _var SET _var := VALUE, but shorten it to GETSET _var.
Although thus not 100% needed for a one liner property, I still think the concept of the pre-processor is a beauty and set the Clipper based dialects far ahead of the rest of the XBase pack.
It is however good to have a discussion around it to make people aware of the power that it brings to the language. We can "emulate" many other dialect syntax that the compiler does not understand yet to produce meaningful and useful code.
Jack
______________________
Johan Nel
Boshof, South Africa
You are absolutely right that having a pre-processor adds a lot of power to a language.
I think that we can emulate 99% of the FoxPro syntax with the preprocessor as well.
I remember in the past, many years ago in 1993, that there was a product called the "CA-Clipper Compiler Kit for dBase IV". This product, written by Matt Whelan was using UDCs to convert dBase IV code to functions, which were then supplied in the form of a special library.
Most likely I still have a version of that (probably on 5 1/4 floppy disks), so I can have a look and use similar UDCs when we are going to add the FoxPro support.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
What you are looking for, is (generic) type inference based on the return type of the method, here's a simplified version of your code:
FUNCTION Start() AS VOID
LOCAL s AS STRING
s := TestClass.GenericMethod<STRING>() // OK
s := TestClass.GenericMethod() // error
CLASS TestClass
STATIC METHOD GenericMethod<T>() AS T
RETURN Default(T)
END CLASS
here you ask the compiler to figure out that the generic argument type of the method is STRING, because the result of that method is being assigned to a STRING var. While I agree that (in this case) it looks straightforward, type inference on return type is not supported by design (it's the same as in c#). Here is a discussion about this:
I tested one of your snippets with the new UDC support and the result is below;
prop1.png (29.25 KiB) Viewed 512 times
You can see:
- UDC definition is recognized and colored in the preprocessor color
- UDC usage is recognized ans colored as keyword (especially the GETSET, NOTIFY and CHANGE words which are not normal keywords)
- The editor shows the difference between the statement separator semi colon (which is part of the UDC) and the line continuation semi colon, so they are both colored in a different color!
And in the image below you see the preprocessor output:
prop2.png (57.87 KiB) Viewed 512 times
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu