Operator declaration

Meta jared771 at gmail.com
Fri Apr 24 21:00:52 UTC 2026


On Friday, 24 April 2026 at 14:59:25 UTC, Nick Treleaven wrote:
> On Thursday, 23 April 2026 at 20:30:04 UTC, Meta wrote:
>> Now that we have ImportC, maybe he he can be convinced to 
>> soften his stance a bit.

The arguments from that section are:
- 32-bit integer operations are often faster than smaller integer 
types for single variables on modern architectures.

I'm not an expert in modern CPU architecture, but I'm extremely 
skeptical of this claim. I doubt the difference is even 
noticeable with modern compiler optimization techniques.

- Promotion helps avoid accidental overflow which is more common 
with small integer types.

I got 3 words for you: Value Range Propagation. We pay for it, so 
we should use it wherever possible.

> Just to note that there are rationale points for integer 
> promotions here, in addition to ease of porting C:
> https://dlang.org/spec/type.html#integer-promotions
>
> `op=` is supposed to work without error:
> https://dlang.org/spec/expression.html#assignment_operator_expressions
>
>> His argument is that people will paste C code into a .d file 
>> and expect it to work the same as in C. However, now they can 
>> just take that C code and compile it directly with DMD, and 
>> use it seemlessly from D. So IMO his reasoning doesn't hold 
>> that much weight anymore.
>
> What if you want to port the C code to D so you can refactor 
> and develop it using D features?




More information about the Digitalmars-d-learn mailing list