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#
C# declaration style in X#
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
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
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
C# declaration style in X#
Write
VAR myClass := myClass{}
Or
VAR i:= 0
Short enough?
VAR myClass := myClass{}
Or
VAR i:= 0
Short enough?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
C# declaration style in X#
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.
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.
Code: Select all
var x := MyClass{}
Code: Select all
MyClass x := MyClass{}
C# declaration style in X#
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
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#
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...)
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...)
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
C# declaration style in X#
Hi Chris,
I think that X# is a VARient of the C# virus
But that is a good thing!
Jamal
I think that X# is a VARient of the C# virus
But that is a good thing!
Jamal
C# declaration style in X#
Hehe, OK, point taken!
Btw, I tried my best to prevent VAR from being implemented in X# but I failed
Btw, I tried my best to prevent VAR from being implemented in X# but I failed
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
C# declaration style in X#
Chris,
Take this example.
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)
Robert
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 !
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
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
-
- Posts: 200
- Joined: Wed Oct 09, 2019 6:51 pm
C# declaration style in X#
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.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.
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:::