November 02, 2019
On Saturday, 2 November 2019 at 20:53:30 UTC, user4567 wrote:
> On Saturday, 2 November 2019 at 20:49:15 UTC, user4567 wrote:
>> On Saturday, 2 November 2019 at 18:45:50 UTC, Eugene wrote:
>>> On Saturday, 2 November 2019 at 18:26:57 UTC, user4567 wrote:
>>>> [...]
>>>
>>> "п" is represented by two code units, but "п"d is represented by one code point, therefore 12 and 6 respectively. Function dup manipulates by code units and represents their to char[]. So?
>>
>> Oh I see what you ask, in first place we thought that you didn't get the implication of encoding. So it's just a rule. If you use `char` literals they must be ascii.
>>
>> The rationale could be that this rule avoid bad surprises on the length of the array, otherwise I cant imagine anything else. ONly original designers (so Bright) must know the exact rationale... cant say more.
>
> Actually you asked why isn't there an implicit encoding if I understand correctly.

That would require special cases in the compiler and language semantics. Implicit encoding would only be possible when a char literal is an array element. special cases in semantic are not nice IMO. "here we are in an array so the literal can be expanded to several bytes, here we're not in array so it's not allowed", you see ? Not nice because confusing.
November 02, 2019
On Saturday, 2 November 2019 at 20:58:06 UTC, user4567 wrote:
> On Saturday, 2 November 2019 at 20:53:30 UTC, user4567 wrote:
>> On Saturday, 2 November 2019 at 20:49:15 UTC, user4567 wrote:
>>> [...]
>>
>> Actually you asked why isn't there an implicit encoding if I understand correctly.
>
> That would require special cases in the compiler and language semantics. Implicit encoding would only be possible when a char literal is an array element. special cases in semantic are not nice IMO. "here we are in an array so the literal can be expanded to several bytes, here we're not in array so it's not allowed", you see ? Not nice because confusing.

Even worse. The special case would only work in dynamic arrays and not static arrays.
November 03, 2019
On Saturday, 2 November 2019 at 20:59:17 UTC, user4567 wrote:
> On Saturday, 2 November 2019 at 20:58:06 UTC, user4567 wrote:
>> On Saturday, 2 November 2019 at 20:53:30 UTC, user4567 wrote:
>>> On Saturday, 2 November 2019 at 20:49:15 UTC, user4567 wrote:
>>>> [...]
>>>
>>> Actually you asked why isn't there an implicit encoding if I understand correctly.
>>
>> That would require special cases in the compiler and language semantics. Implicit encoding would only be possible when a char literal is an array element. special cases in semantic are not nice IMO. "here we are in an array so the literal can be expanded to several bytes, here we're not in array so it's not allowed", you see ? Not nice because confusing.
>
> Even worse. The special case would only work in dynamic arrays and not static arrays.

👍
Yes, since dynamic array and code units (bytes) - spread. Thanks.
1 2
Next ›   Last »