Syntax sugar for {} with structs

Max Samukha maxsamukha at gmail.com
Sat Jul 2 05:26:31 UTC 2022


On Friday, 1 July 2022 at 21:01:43 UTC, Paul Backus wrote:
> On Friday, 1 July 2022 at 20:21:45 UTC, Max Samukha wrote:
>> Why is this more problematic than e.g.:
>>
>> ```d
>> void f(int[])
>> {
>> }
>>
>> void f(byte[])
>> {
>> }
>>
>> void main()
>> {
>>     f([]); // Nice ambiguity error
>> }
>> ```
>
> It's not. I'd say they're both equally problematic.

I really don't see what is problematic with this (except for the 
FUD spread by some C++ gurus).

>
> Array literals are useful enough in general that we're willing 
> to accept this problematic special case in order to have them. 
> It's not obvious to me that the proposed `{}` meets the same 
> standard. Maybe if the proposal were for some kind of "struct 
> literals", rather than just `{}` by itself, it would be more 
> attractive.

'{}' by itself would be bad.




More information about the Digitalmars-d mailing list