xsharp.eu • [2.11] Single vs. double quotes
Page 1 of 1

[2.11] Single vs. double quotes

Posted: Mon Apr 24, 2017 9:12 pm
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

[2.11] Single vs. double quotes

Posted: Tue Apr 25, 2017 12:11 am
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

[2.11] Single vs. double quotes

Posted: Tue Apr 25, 2017 8:36 am
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...