www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Auto-decoding

reply bauss <jj_1337 live.dk> writes:
I understand what it is and how it works, but I don't understand 
anything of how it solves any problems?

Could someone give an example of when auto-decoding actually is 
useful in contrast to not using it?

Just trying to get an understanding of what exactly its purpose 
is.

I did read 
https://jackstouffer.com/blog/d_auto_decoding_and_you.html

But I still feel like there's not a clear explanation of what 
issues exist when you don't have it.

If I need to be more clear, just let me know.
Jul 14 2017
parent reply ag0aep6g <anonymous example.com> writes:
On 07/15/2017 06:21 AM, bauss wrote:
 I understand what it is and how it works, but I don't understand 
 anything of how it solves any problems?
 
 Could someone give an example of when auto-decoding actually is useful 
 in contrast to not using it?
1) Drop two elements from "Bär". With auto-decoding you get "r", which is nice. Without auto-decoding you get [0xA4, 'r'] where 0xA4 is the second half of the encoding of 'ä'. You have to know your Unicode to understand what is going on there. 2) Search for 'ä' (one wchar/dchar) in the `string` "Bär". With auto-decoding, you pop the 'B' and then there's your 'ä'. Without auto-decoding, you can't find 'ä', because "Bär" doesn't have a single element that matches 'ä'. You have to search for "ä" (two `char`s) instead. The goal of auto-decoding was to make it so that you don't have to think about Unicode all the time when processing strings. Instead you could think in terms of "characters". But auto-decoding falls flat on that goal, which is why it's disliked. You still have to think about Unicode stuff for correctness (combining characters, graphemes), and now you also have to worry about the performance of auto-decoding.
Jul 14 2017
parent reply aberba <karabutaworld gmail.com> writes:
On Saturday, 15 July 2017 at 05:54:32 UTC, ag0aep6g wrote:
 On 07/15/2017 06:21 AM, bauss wrote:
 [...]
1) Drop two elements from "Bär". With auto-decoding you get "r", which is nice. Without auto-decoding you get [0xA4, 'r'] where 0xA4 is the second half of the encoding of 'ä'. You have to know your Unicode to understand what is going on there. [...]
So what is the current plan? :)
Jul 15 2017
next sibling parent ag0aep6g <anonymous example.com> writes:
On 07/15/2017 08:14 PM, aberba wrote:
 So what is the current plan? :)
As far as I'm aware, there's no concrete plan to change anything. We just gotta deal with auto-decoding for the time being.
Jul 15 2017
prev sibling parent reply Joakim <dlang joakim.fea.st> writes:
On Saturday, 15 July 2017 at 18:14:48 UTC, aberba wrote:
 On Saturday, 15 July 2017 at 05:54:32 UTC, ag0aep6g wrote:
 On 07/15/2017 06:21 AM, bauss wrote:
 [...]
1) Drop two elements from "Bär". With auto-decoding you get "r", which is nice. Without auto-decoding you get [0xA4, 'r'] where 0xA4 is the second half of the encoding of 'ä'. You have to know your Unicode to understand what is going on there. [...]
So what is the current plan? :)
Andrei has talked about having a non-auto-decoding path for those who know what they're doing and actively choose that path, while keeping auto-decoding the default, so as not to break existing code. Jack has been submitting PRs for this, but it is probably tedious work, so progress is slow and I don't know how much more remains to be done: https://github.com/dlang/phobos/pulls?q=is%3Apr+auto-decoding+is%3Aclosed
Jul 15 2017
parent Seb <seb wilzba.ch> writes:
On Saturday, 15 July 2017 at 18:47:25 UTC, Joakim wrote:
 On Saturday, 15 July 2017 at 18:14:48 UTC, aberba wrote:
 So what is the current plan? :)
Andrei has talked about having a non-auto-decoding path for those who know what they're doing and actively choose that path, while keeping auto-decoding the default, so as not to break existing code. Jack has been submitting PRs for this, but it is probably tedious work, so progress is slow and I don't know how much more remains to be done: https://github.com/dlang/phobos/pulls?q=is%3Apr+auto-decoding+is%3Aclosed
The idea is that once DIP1000 has matured, more focus on compiler support for reference-counting will be given with the aim of improving the nogc experience. One example is DIP1008 for nogc exceptions [1], but another one that is important in this context is RCString [2]. The idea is that RCString will be a new opt-in string type without auto-decoding and GC. Another idea in the game is `version(NoAutoDecode)`: https://github.com/dlang/phobos/pull/5513 However, here's unfortunately still unclear whether that could result in a working solution. [1] https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md [2] https://github.com/dlang/phobos/pull/4878
Jul 15 2017