array literal element types

Robert Jacques sandford at jhu.edu
Thu Nov 12 17:36:20 PST 2009


On Thu, 12 Nov 2009 20:29:31 -0500, Bill Baxter <wbaxter at gmail.com> wrote:

> On Thu, Nov 12, 2009 at 5:16 PM, Robert Jacques <sandford at jhu.edu> wrote:
>> On Thu, 12 Nov 2009 16:42:45 -0500, Walter Bright
>> <newshound1 at digitalmars.com> wrote:
>>
>>> Currently, the type is determined by the type of the first element and  
>>> the
>>> rest are implicitly cast to it.
>>>
>>> I propose changing it to being the type produced by applying the ?:  
>>> logic
>>> repeatedly to all the elements.
>>
>> Given how numeric literals currently work:
>> vote--
>>
>> for example currently:
>> float[] = [1.0f, 2.5, 5.6, 0.8].dup;
>>
>> under the proposal
>> float[] = [1.0f, 2.5f, 5.6f, 0.8f].dup;
>
> On the other hand, currently
>
> float[] = [1.0f, 2.0f, 3.0f, 4.5f].dup;
>
> under the proposal:
> float[] = [1, 2, 3, 4.5f].dup;
>
> (I think    (true)?1:4.5f  is a float, anyway).
> --bb

Shouldn't that be:

On the other hand, currently

float[] = [1f, 2, 3, 4.5].dup;



More information about the Digitalmars-d mailing list