December 26, 2014 Re: DIP66 v1.1 (Multiple) alias this. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 12/23/2014 10:17 PM, Andrei Alexandrescu wrote: > On 12/23/14 8:54 PM, Walter Bright wrote: >> >> The current behavior of: >> >> is (D : B) >> >> is the expression will evaluate to false if D does not compile. However, >> a compile time error will be issued if B does not compile. >> >> If D and B compile, then it will evaluate to false if B is not >> implicitly convertible to D. This suggests to me Option 1, i.e. if the >> implicit conversion fails due to ambiguity errors, then it should return >> false (not issue a compile time error). > > Though I agree it makes sense to just return false, I think it would be more > sensible and useful to issue an error. If B is reachable from B through multiple > paths, that's a new situation distinct from yes/no. That would be inconsistent with how 'is' works for other types. > In fact a better thought: as soon as D is defined, repeated subtyping should be > detected as an error. Then there's no question about "is" in the first place :o). That's a good idea, but I think it is unworkable. What is the set of types that B is implicitly convertible too? It's unbounded. |
December 27, 2014 Re: DIP66 v1.1 (Multiple) alias this. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 12/26/14 12:37 PM, Walter Bright wrote:
> On 12/23/2014 10:17 PM, Andrei Alexandrescu wrote:
>> In fact a better thought: as soon as D is defined, repeated subtyping
>> should be
>> detected as an error. Then there's no question about "is" in the first
>> place :o).
>
> That's a good idea, but I think it is unworkable. What is the set of
> types that B is implicitly convertible too? It's unbounded.
I think it's bounded. Example to the contrary? -- Andrei
|
December 27, 2014 Re: DIP66 v1.1 (Multiple) alias this. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel N | On 26/12/14 19:53, Daniel N via Digitalmars-d wrote:
> Anyway considering the new ways of working, when using the -dip switch for the
> initial few releases, there is ample time to perfect all details.
Potentially related issue, regarding implicit conversion. Given a struct as follows:
struct Integer
{
int i_;
alias i_ this;
}
Can anyone explain to me why this works:
Integer i = Integer(3);
i = 5;
... but this doesn't:
Integer i = 5;
It seems unintuitive, in the circumstances.
|
May 08, 2015 Re: DIP66 v1.1 (Multiple) alias this. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | On Saturday, 27 December 2014 at 12:28:34 UTC, Joseph Rushton Wakeling wrote:
> On 26/12/14 19:53, Daniel N via Digitalmars-d wrote:
>> Anyway considering the new ways of working, when using the -dip switch for the
>> initial few releases, there is ample time to perfect all details.
>
> Potentially related issue, regarding implicit conversion. Given a struct as follows:
>
> struct Integer
> {
> int i_;
>
> alias i_ this;
> }
>
> Can anyone explain to me why this works:
>
> Integer i = Integer(3);
> i = 5;
>
> ... but this doesn't:
>
> Integer i = 5;
>
> It seems unintuitive, in the circumstances.
Is "multiple alias this" implementation planned in near future? It could be useful for a project of mine :)
|
June 27, 2016 Re: DIP66 v1.1 (Multiple) alias this. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On Friday, 8 May 2015 at 13:57:56 UTC, Andrea Fontana wrote: > On Saturday, 27 December 2014 at 12:28:34 UTC, Joseph Rushton Wakeling wrote: >> On 26/12/14 19:53, Daniel N via Digitalmars-d wrote: >>> Anyway considering the new ways of working, when using the -dip switch for the >>> initial few releases, there is ample time to perfect all details. >> >> Potentially related issue, regarding implicit conversion. Given a struct as follows: >> >> struct Integer >> { >> int i_; >> >> alias i_ this; >> } >> >> Can anyone explain to me why this works: >> >> Integer i = Integer(3); >> i = 5; >> >> ... but this doesn't: >> >> Integer i = 5; >> >> It seems unintuitive, in the circumstances. > > Is "multiple alias this" implementation planned in near future? It could be useful for a project of mine :) I need it too, and also do static inheritance. http://wiki.dlang.org/DIP84 |
June 27, 2016 Re: DIP66 v1.1 (Multiple) alias this. | ||||
---|---|---|---|---|
| ||||
Posted in reply to mogu | On Monday, 27 June 2016 at 00:13:46 UTC, mogu wrote: > On Friday, 8 May 2015 at 13:57:56 UTC, Andrea Fontana wrote: >> Is "multiple alias this" implementation planned in near future? It could be useful for a project of mine :) > > I need it too, and also do static inheritance. > http://wiki.dlang.org/DIP84 I implemented a limited version of multiple alias this: https://github.com/mogud/MultiAliasThis/blob/master/mat.d But it's only useful in composition. Static polymorphism(by implicit conversion in alias this) cannot work. |
Copyright © 1999-2021 by the D Language Foundation