std.data.json formal review
Sönke Ludwig via Digitalmars-d
digitalmars-d at puremagic.com
Tue Aug 25 13:09:13 PDT 2015
Am 25.08.2015 um 14:14 schrieb Sebastiaan Koppe:
> On Tuesday, 25 August 2015 at 06:56:23 UTC, Sönke Ludwig wrote:
>> If I have a string variable and I want to store the upper case version
>> of another string, the direct mental translation is "dst =
>> toUpper(src);" - and not "dst = toUpper(src).array;".
>
> One can also say the problem is that you have a string variable.
But ranges are not always the right solution:
- For fields or setter properties, the exact type of the range is fixed,
which is generally unpractical
- If the underlying data of a range is stored on the stack or any other
transient storage, it cannot be stored on the heap
- If the range is only an input range, it must be copied to an array
anyway if it's going to be read multiple times
- Ranges cannot be immutable (no safe slicing or passing between threads)
- If for some reason template land needs to be left, ranges have trouble
following (although there are wrapper classes available)
- Most existing APIs are string based
- Re-evaluating a computed range each time a variable is read is usually
wasteful
There are probably a bunch of other problems that simply make ranges not
the best answer in every situation.
More information about the Digitalmars-d
mailing list