[2.11] Single vs. double quotes

This forum is meant for questions and discussions about the X# language and tools
Post Reply
FFF
Posts: 1584
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

[2.11] Single vs. double quotes

Post by FFF »

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 edited by Phil Hepburn on Tue Apr 25, 2017 12:51 pm, edited 1 time in total.
Reason: typo
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

[2.11] Single vs. double quotes

Post by Chris »

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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FFF
Posts: 1584
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

[2.11] Single vs. double quotes

Post by FFF »

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...
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Post Reply