fbpx

[2.11] Single vs. double quotes

More
1 year 8 months ago - 1 year 8 months ago #1 by Karl Faller
[2.11] Single vs. double quotes was created by Karl Faller
Just got me the new build, install went smoothly.
Read in What's new:
...
In the Core and VO dialect a literal string that is enclosed with single quotes is a string literal. Double quotes are also string literals...

Starting with template "Basic X#" sample (with Xide 1.09):

FUNCTION Start( ) AS VOID
LOCAL c AS STRING
c:='x'
RETURN

Compiling i get:
Compilation failed (1 error)
error XS0029: Cannot implicitly convert type 'char' to 'string' 3,5 Start.prg Stringdelim

Either i misunderstand the help file or there is something amiss...
On further tries, i find:
LOCAL d AS Char
d:='y'
compiles - without the 'c'prefacing the help says i'd need!?

For completeness is started VS17, tried the same and see the same result.


@Chris: i see this new app listed as "StringDelim(v4.0)-X#", note the missing "/Core" part (properties show language X# and dialect Core) - is this new convention?

HTH
Karl
Last edit: 1 year 8 months ago by Karl Faller. Reason: typo

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

More
1 year 8 months ago #2 by Chris Pyrgas
Replied by Chris Pyrgas on topic [2.11] Single vs. double quotes
Hi Karl,

I think you are right, this needs some further clarification. At the moment (in Core dialect), if you specify only one character delimited with single quotes, then this is treated as a Char constant. If there are more than one characters, then it is treated as String. Maybe we will need to review this a bit more again..

As for the "/Core" test not appearing in XIDE, this is a small bug, next time you open the project it will be displayed normally.

Chris

XSharp Development Team
chris(at)xsharp.eu

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

More
1 year 8 months ago - 1 year 8 months ago #3 by Karl Faller
Replied by Karl Faller on topic [2.11] Single vs. double quotes

Chris Pyrgas wrote: Hi Karl,

I think you are right, this needs some further clarification. At the moment (in Core dialect), if you specify only one character delimited with single quotes, then this is treated as a Char constant. If there are more than one characters, then it is treated as String. Maybe we will need to review this a bit more again..

Yes. Too much "implicit" thinking needed ;)
BTW, i wonder, why we need the "special" quoting at all? Either the declaration of a var is needed, then there should be no need to "mark" the name in any special kind - or the compiler deduces the type from the assign, then we could drop the declare <g>.

As for the "/Core" test not appearing in XIDE, this is a small bug, next time you open the project it will be displayed normally.

Indeed. No problem...
Last edit: 1 year 8 months ago by Karl Faller. Reason: typo

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