Page 1 of 2
C# declaration style in X#
Posted: Fri Oct 18, 2019 3:10 pm
by Jamal
Is it possible to add C# declaration style where the type precedes the variable - sometime in the future?
For example:
MyClass x := MyClass{}
which behaves like the X# style:
LOCAL x := MyClass{} AS MyClass
or
int y := 0
which behaves as:
LOCAL y := 0 as int
I like the C# short style.
Jamal
C# declaration style in X#
Posted: Fri Oct 18, 2019 3:16 pm
by robert
Jamal,
We already have
var x := MyClass{}
Adding C# style syntax is probably technically possible but I wonder how many people would really want that?
Robert
C# declaration style in X#
Posted: Fri Oct 18, 2019 3:28 pm
by FFF
Write
VAR myClass := myClass{}
Or
VAR i:= 0
Short enough?
C# declaration style in X#
Posted: Fri Oct 18, 2019 3:53 pm
by FoxProMatt
If the matter is allowing (or supporting) that one can make an explicit reference to the Type rather than using the VAR keyword, I'd vote to add support for this.
One, it would make X# even more C#-like, and
Two, in the C# world, many people poo-pooh the use of the "var" keyword in favor of the explicit Type reference.
Simply allow both.
C# declaration style in X#
Posted: Fri Oct 18, 2019 3:54 pm
by Jamal
Hi Robert,
But VAR declares an implied local, which might be good, but it is ambiguous. I prefer strongly typed declarations.
This may be exciting for people who are familiar with C# (like me :woohoo: )
Jamal
C# declaration style in X#
Posted: Fri Oct 18, 2019 4:31 pm
by Chris
Hi Jamal,
I think you've been infected with the well known nasty c# virus! But it's OK, nowadays it can be healed! Best medicine is to stay away from it for a couple weeks and do only xBase programming.
(just kidding of course!!!)
(hmm, well, mostly...
)
C# declaration style in X#
Posted: Fri Oct 18, 2019 4:48 pm
by Jamal
Hi Chris,
I think that X# is a VARient of the C# virus
But that is a good thing!
Jamal
C# declaration style in X#
Posted: Fri Oct 18, 2019 4:51 pm
by Chris
Hehe, OK, point taken!
Btw, I tried my best to prevent VAR from being implemented in X# but I failed
C# declaration style in X#
Posted: Fri Oct 18, 2019 6:36 pm
by robert
Chris,
Take this example.
Code: Select all
LOCAL oDev := GetDevelopers() as IList<Developer>
LOCAL oC := GetCountries() as IList<Country>
LOCAL oAll := FROM D IN oDev ;
JOIN C IN oC ON D:Country EQUALS C:Name ;
ORDERBY D:LastName ;
SELECT CLASS {D:Name, D:Country, C:Region} // Anonymous class !
What should the type of oAll be ?
I think using VAR oAll make a lot of sense here.
Btw the answer is (the last time I checked)
Code: Select all
IOrderedEnumerable<<>f__AnonymousType0<Developer,Country,String>>
Robert
C# declaration style in X#
Posted: Fri Oct 18, 2019 8:34 pm
by mainhatten
Matt Slay wrote:If the matter is allowing (or supporting) that one can make an explicit reference to the Type rather than using the VAR keyword, I'd vote to add support for this.
One, it would make X# even more C#-like, and
Two, in the C# world, many people poo-pooh the use of the "var" keyword in favor of the explicit Type reference.
Simply allow both.
I think personal preference has its place - but there is already for me a lot of ambivalence (plus uncetrainty as I am learning) on how to human-parse X#. For a single dev no problem, he can go to the next mirror and blame the dev, but in team effort I'd argue for more lenience
only after a tool similar to vfp "Beautify" is introduced. Every coder can have their own idea of "neat" or readable code applied to new version from source control and must adhere to company standard during check in - best done via automatic call.
Comparing versions might look different from personal pref, but reading speed while coding is not artificially lowered when working on the code from THE GUY WITH THE CAPSLOCK PROBLEM WHO CODES TOTALLY DIFFERENT FROM MY STYLE:::