Thread overview
Redundancy in languages by Walter
May 31, 2020
Max Samukha
Jun 01, 2020
Ali Çehreli
Jun 01, 2020
Max Samukha
May 31, 2020
I was re-reading Walter's old article on redundancy and thought new people here might find it useful: https://www.digitalmars.com/articles/b05.html.

It is good overall, except for a couple of arguable points, such as types of temporaries condemned as bad redundancy, where the issue is not the redundant type declaration but rather the type system allowing implicit lossy conversions.


May 31, 2020
On 5/31/20 6:14 AM, Max Samukha wrote:> I was re-reading Walter's old article on redundancy and thought new
> people here might find it useful:
> https://www.digitalmars.com/articles/b05.html.

Thanks for the reminder. I read it again.

> It is good overall, except for a couple of arguable points, such as
> types of temporaries condemned as bad redundancy, where the issue is not
> the redundant type declaration but rather the type system allowing
> implicit lossy conversions.

Yes, implicit conversion is a concern but I didn't take the point that way: When the type is not spelled out, it means "whatever the type of the expression is." On the other hand, if one uses 'int' e.g. because the type of the expression is 'int' today, the compiler cannot know whether the programmer means "whatever the type of the expression is" or "I want specifically int". Note that 'int' conversion may not be lossy or wrong at all; there may be a perfectly valid 'int' conversion.

The issue is, the compiler cannot know and that's why Walter calls this a bad redundancy.

Ali

June 01, 2020
On Monday, 1 June 2020 at 06:53:05 UTC, Ali Çehreli wrote:

> Yes, implicit conversion is a concern but I didn't take the point that way: When the type is not spelled out, it means "whatever the type of the expression is." On the other hand, if one uses 'int' e.g. because the type of the expression is 'int' today, the compiler cannot know whether the programmer means "whatever the type of the expression is" or "I want specifically int". Note that 'int' conversion may not be lossy or wrong at all; there may be a perfectly valid 'int' conversion.
>
> The issue is, the compiler cannot know and that's why Walter calls this a bad redundancy.
>
> Ali

It seems you can look at it this way as well.