Unexpected result with -betterC

Juraj junk at vec4.xyz
Sun Nov 3 20:11:25 UTC 2024


On Sunday, 3 November 2024 at 20:04:19 UTC, DLearner wrote:
> On Sunday, 3 November 2024 at 19:47:31 UTC, monkyyy wrote:
> [...]
>>
>> Id expect this to fail, but nothing I see in yours
>>
>> ```d
>> string foo="foo";
>> foo~="bar";
>> ```
>>
>> []'s are both slices and dynamic arrays depending on use, 
>> theres a debate about that decision(im of the opinion a `[?]` 
>> should be a dynamic array and clean up the api), but the 
>> current situation will only break on appends
>
> Surely the line:
>
> ```
>    string Scrn = "OPO NAM='DspVar1' POS='1,1' 
> VAR=('IntVar1','I');E";
> ```
> creates, by the definition of 'string', a dynamic array?

By default, a string literal is typed as a dynamic array, but the 
element count is known at compile time. So all string literals 
can be implicitly converted to an immutable static array. 
[spec](https://dlang.org/spec/expression.html#string_literals)



More information about the Digitalmars-d-learn mailing list