No we should not support enum types derived from strings

NonNull non-null at use.startmail.com
Wed May 12 14:49:35 UTC 2021


On Friday, 7 May 2021 at 20:53:08 UTC, Andrei Alexandrescu wrote:
> On 5/7/21 2:44 PM, Steven Schveighoffer wrote:
>> On 5/7/21 2:17 PM, Adam D. Ruppe wrote:
>>> I think it was actually a mistake for Phobos to UFCS 
>>> shoe-horn in range functions on arrays too - this includes 
>>> strings as well as int[] and such as well.
>> 
>> The most common range BY FAR in all of D code is an array.
>> 
>> The end result of something like you allude to would result in 
>> nearly all of phobos NOT working with arrays.
>
> Yah, ranges are a generalization of arrays. It would be odd if 
> the generalization of arrays didn't work when tried with arrays.

No. Ranges are not a generalization of arrays unless you ignore 
the most important feature of the notion of a Range. An array is 
a sequence of things in space: a spatial container (all values 
stored) that happens to be a sequence. A Range is a sequence of 
things in time. (Purist definition, often true in practice.)

A spatial container can be /exploded/ into a sequence in time. 
And a sequence in time can be /accreted/ into a spatial container 
(whether it has sequence or not).

Explode is a natural idea and could be defined for any spatial 
container, producing a Range from a spatial container, and 
specifically from an array.

Making a distinction of spatial and temporal makes sense.



More information about the Digitalmars-d mailing list