fbpx

correct syntax for Floats ?

More
11 months 1 week ago #1 by Phil Hepburn
correct syntax for Floats ? was created 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 :-



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 :-



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 .. ]



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.
Attachments:

Please Log in or Create an account to join the conversation.

More
11 months 1 week ago #2 by Phil Hepburn
Replied by Phil Hepburn on topic correct syntax for Floats ?
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.



Is the image any good ?

Cheers,
Phil.
Attachments:

Please Log in or Create an account to join the conversation.

More
11 months 1 week ago #3 by Chris Pyrgas
Replied by Chris Pyrgas on topic correct syntax for Floats ?
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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
11 months 1 week ago #4 by Phil Hepburn
Replied by Phil Hepburn on topic correct syntax for Floats ?
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.

Please Log in or Create an account to join the conversation.

More
11 months 1 week ago #5 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic correct syntax for Floats ?
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

Please Log in or Create an account to join the conversation.