July 27, 2019
On Sat, Jul 27, 2019 at 5:45 PM Exil via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>
> On Saturday, 27 July 2019 at 22:36:23 UTC, Manu wrote:
> > I think implicit conversions are EXTREMELY enabling for a lot of cases of meta-programming in D, and I also feel much more comfortable with the idea that they are opt-in rather than opt-out as in C++. I think that's the right balance.
>
> I think it'd be even worse with meta programming. Now not only do you not know what type you may have, case it can be any type. You can also possibly convert it to any other type with implicit conversion.

Not quite. I think you mean "you can also INTENTIONALLY convert it to SELECT other types with implicit conversion".

> This would make it even more difficult to try to read
> and understand what is going on with implicit conversions. It
> could make it more powerful, and have the code be simpler. But
> overall it makes maintainability a pain, especially so since it
> makes the code look simpler, when in reality it is actually far
> more complicated.

I find the bigger pain when I need to insert detection for specific things into meta-code, because they require a manual conversion step when the things is something that I'd like to convert implicitly.
July 31, 2019
On Sunday, 28 July 2019 at 02:22:36 UTC, Manu wrote:
> On Sat, Jul 27, 2019 at 5:45 PM Exil via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>>
>> On Saturday, 27 July 2019 at 22:36:23 UTC, Manu wrote:
>> > I think implicit conversions are EXTREMELY enabling for a lot of cases of meta-programming in D, and I also feel much more comfortable with the idea that they are opt-in rather than opt-out as in C++. I think that's the right balance.
>>
>> I think it'd be even worse with meta programming. Now not only do you not know what type you may have, case it can be any type. You can also possibly convert it to any other type with implicit conversion.
>
> Not quite. I think you mean "you can also INTENTIONALLY convert it to SELECT other types with implicit conversion".

The implicit conversion can be intentionally. But if you change a function signature, and it can implicitly convert to it. When you first wrote the code you didn't intend for it to be implicitly converted for that function. Code changes, and this sort of change won't give a compiler error when you make a change that wasn't intended to happen.

>> This would make it even more difficult to try to read
>> and understand what is going on with implicit conversions. It
>> could make it more powerful, and have the code be simpler. But
>> overall it makes maintainability a pain, especially so since it
>> makes the code look simpler, when in reality it is actually far
>> more complicated.
>
> I find the bigger pain when I need to insert detection for specific things into meta-code, because they require a manual conversion step when the things is something that I'd like to convert implicitly.

Instead of inserting `static if` everywhere like you mention, if you have a function that does that instead then you don't need to do the checks at the calls sites. You just use the function that does the checks for you.

Even still, why couldn't you just put a constructor for this case? Couldn't you just give U() the constructor to handle SpecialCaseThing? Then you wouldn't need the static if. This just isn't a very good example of what you intend, using `static if` here is your choice but there are alternatives already available to avoid it.


  static if (is(T == SpecialCaseThing)
  {
    U x = special_case_conversion(thing);
  }
  else
  {
    U x = thing; // direct or implicit conversion
  }



July 31, 2019
On Sunday, 28 July 2019 at 01:47:21 UTC, 12345swordy wrote:
>> It is the feature itself.
>
> The goto feature exist. You want to argue for deprecation for that feature?

It eases conversion from C/C++, so wouldn't be in the best interest to deprecate it. DMD probably wouldn't have been converted to D as easily, seeing how it abused goto.
July 31, 2019
On Sunday, 28 July 2019 at 01:47:21 UTC, 12345swordy wrote:
>  Also you can make the same argument regarding the goto statement.

i <3 goto

though i also wish we had implicit cast and implicit constructor more easily in d
1 2 3 4
Next ›   Last »