correct syntax for Floats ?

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

correct syntax for Floats ?

Post by Phil Hepburn »

Hi Team guys,

This morning I came across an issue which is 'something small' but which threw me for quite a while.

I mistakenly thought that most code ('semi' syntax plus) could be done in X# how it is seen in C#. Well, that is what I have been doing successfully for quite some time ;-)

So when I had this code shown below :-
NFposnItems_22.jpg
NFposnItems_22.jpg (41.23 KiB) Viewed 360 times
I thought nothing of it - until I got compilation errors ;-0((

It is line 182 (and many like it) which gave me issues as the (6F,6F) did not translate as {6F,6F} and work, as I thought it would.

After messing around a while (the error messages from the compiler were NOT much help at all) I found out it would work with {6S, 6S} - that is 'S' where 'F' was previously in C#.

Can you explain this please, why F does not work. Here is what X# code compiles and runs :-
NFposnItems_23.jpg
NFposnItems_23.jpg (48.98 KiB) Viewed 360 times
And for 'fun' and interest here is the report page in the DevExpress (DX) framework which I was trying to hand code :- [ .. thanks to Nick Friend for his help and support generally .. ]
NFposnItems_21.jpg
NFposnItems_21.jpg (39.08 KiB) Viewed 360 times
Okay, I am up and running, I think, but I have noticed that if and when I get a compilation error, that often I don't get any meaningful message(s). Shall I report back to you what message is provided when I have F and not S ?

I get by with the VS behaviour as it is BUT it is not conducive to other guys coming new to VS I feel.

Thanks for listening, and have a nice day,
Phil.
Wales, UK.



Best regards,
Phil.
Wales, UK.
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

correct syntax for Floats ?

Post by Phil Hepburn »

Hi again Robert / Team,

Since it is easier to do this now than later, I went and made the error list for when 'F' was used.
NFposnItems_31.jpg
NFposnItems_31.jpg (116.15 KiB) Viewed 360 times
Is the image any good ?

Cheers,
Phil.
User avatar
Chris
Posts: 4854
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

correct syntax for Floats ?

Post by Chris »

Hi Phil,

In X# syntax, we went for post-fixes that we thought make more sense:

- System.Single (REAL4): "s"
- System.Double (REAL8): "d"

So a single precision literal can be typed as 1.23s and a double precision one as 1.23d.

You can argue we should use the (IMO confusing) same post-fixes that c# uses for consistency with it, but this would further complicate things, because what we know as "FLOAT" at least in VO (a double precision type with formatting information embedded into it) is something very different to what c# means with "float", so this would be a source for a lot of confusion.

Btw, in x# (and in the latest vulcan builds) we have also introduced the /vo14 compiler option, which, if set, treats literal decimal numbers without a postfix (like 1.23) as FLOATs (for VO compatibility), otherwise it treats them as REAL8 (System.Double), which has better performance.

As for parser error messages, I agree, a lot of them need improving to point you in a much better way to the actual syntax error itself. You see those other errors because the parser goes out of sync after that one first error, it's something that we want to improve (and have done in several cases already), will look more into it once some other
pressuring issues are finished.

hth,

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

correct syntax for Floats ?

Post by Phil Hepburn »

Hi Chris,

Thanks for the information and clarity.

Makes a lot of sense what you have done.

My simple point was that it is another 'thing' to tackle at the point of syntax conversion from C# to X# - BUT - as you say this is probably a good thing.

I will make a note of this in my eNotes, somewhere ;-0)

My point about the compiler messages was just for your info really, as I do understand what is going one with the general process. trouble is that it has gotten me into the habit of just ignoring them all, and doing things my own way - which is probably NOT a good idea !!

On the main frame doing Algol in the very early 70's, we disregarded all errors after the first half dozen or so - and there were lots ;-0)

If only I had doubted the 'F' before I did this morning - this then pushed me in the wrong direction, as I was then fighting namespaces and assemblies and references for the VERY extensive DX framework for reporting. Ends up that these things were OK !

Must shoot, lots more to do for Cologne 2018.
Cheers,
Phil.
User avatar
wriedmann
Posts: 3748
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

correct syntax for Floats ?

Post by wriedmann »

Hi Phil,

someone will take care that this is also put into the X# Documentation Project the next days. So Google can take it also to his index (the site will be indexed the next days, I hope - Barbara has added it to her webmaster account and added the Google site verification code)

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply