digitalmars.D - Possible regression (2.060 -> 2.061) with member access
- Benjamin Thaut (28/28) Feb 09 2013 The following reduced source code would compile just fine with dmd 2.060...
- kenji hara (5/31) Feb 09 2013 You can use built-in 'tupleof' property, which still bypass access
- Benjamin Thaut (5/7) Feb 09 2013 Will they continue to do so, or will this also be fixed? We should at
- Dicebot (4/15) Feb 09 2013 According to my private-related DIP - yes, they will continue,
- Jacob Carlborg (5/8) Feb 09 2013 The workaround would be to use .tupleof:
- Andrej Mitrovic (10/11) Feb 09 2013 Perhaps we could relax the rule and allow bypassing access
- Nick Sabalausky (7/12) Feb 09 2013 I think that's asking for confusion to have different visibility rules
- Jacob Carlborg (4/9) Feb 09 2013 Couldn't typeof() be considered part of a reflection mechanism?
- Nick Sabalausky (4/15) Feb 09 2013 Yea, but not the part of reflection I was trying to refer to. Wasn't
- Dicebot (5/16) Feb 10 2013 May be, but definitely not an advanced librar'ish one - contrary
- Benjamin Thaut (2/15) Feb 10 2013 Really? I'm using typeof all over the place in my user code.
- Dicebot (3/4) Feb 10 2013 That is exactly what I have just said :) And reason why it should
- Benjamin Thaut (2/6) Feb 10 2013 Oh ok, then I misunderstood your argument.
The following reduced source code would compile just fine with dmd 2.060 but does no longer compile with dmd 2.061: file a.d: module a; import b; template getType(T) { alias typeof(T.i) getType; } void main(string[] args) { alias getType!Foo t; } file b.d: module b; struct Foo { private int i; } This breaks all kind of low level functionality I did build. It breaks both my serialization code and runtime type information system. Because in both use cases I need to be able to access the type of a protected or private member. Has this been "fixed" intentionally? Or is this a regression? If it has been "fixed" what would be a workaround to get the type of Foo.i (outside of the b module) ? Kind Regards Benjamin Thaut
Feb 09 2013
2013/2/10 Benjamin Thaut <code benjamin-thaut.de>The following reduced source code would compile just fine with dmd 2.060 but does no longer compile with dmd 2.061: file a.d: module a; import b; template getType(T) { alias typeof(T.i) getType; } void main(string[] args) { alias getType!Foo t; } file b.d: module b; struct Foo { private int i; } This breaks all kind of low level functionality I did build. It breaks both my serialization code and runtime type information system. Because in both use cases I need to be able to access the type of a protected or private member. Has this been "fixed" intentionally? Or is this a regression?It's introduced by fixing issue 5385, so at least not a regressionIf it has been "fixed" what would be a workaround to get the type of Foo.i (outside of the b module)You can use built-in 'tupleof' property, which still bypass access modifier. Kenji Hara
Feb 09 2013
Am 09.02.2013 16:40, schrieb kenji hara:You can use built-in 'tupleof' property, which still bypass access modifier.Will they continue to do so, or will this also be fixed? We should at least have some way to do low level work like serialization. Kind Regards Benjamin Thaut
Feb 09 2013
On Saturday, 9 February 2013 at 15:52:04 UTC, Benjamin Thaut wrote:Am 09.02.2013 16:40, schrieb kenji hara:According to my private-related DIP - yes, they will continue, and there have been no objections on this part.You can use built-in 'tupleof' property, which still bypass access modifier.Will they continue to do so, or will this also be fixed? We should at least have some way to do low level work like serialization. Kind Regards Benjamin Thaut
Feb 09 2013
On 2013-02-09 16:20, Benjamin Thaut wrote:Has this been "fixed" intentionally? Or is this a regression? If it has been "fixed" what would be a workaround to get the type of Foo.i (outside of the b module) ?The workaround would be to use .tupleof: https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L237 -- /Jacob Carlborg
Feb 09 2013
On 2/9/13, kenji hara <k.hara.pg gmail.com> wrote:It's introduced by fixing issue 5385, so at least not a regressionPerhaps we could relax the rule and allow bypassing access restrictions when using typeof(). There are similar bugs opened about purity, where e.g. you can't check the length of an impure static array in a pure function (even though it will never change length). I think we'll have to define in the spec exactly what is and isn't allowed and then implement this properly, otherwise we risk fixing bug exactly what happened with fixing 5385).
Feb 09 2013
On Sat, 9 Feb 2013 21:34:54 +0100 Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:On 2/9/13, kenji hara <k.hara.pg gmail.com> wrote:I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.It's introduced by fixing issue 5385, so at least not a regressionPerhaps we could relax the rule and allow bypassing access restrictions when using typeof().
Feb 09 2013
On 2013-02-09 21:51, Nick Sabalausky wrote:I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.Couldn't typeof() be considered part of a reflection mechanism? -- /Jacob Carlborg
Feb 09 2013
On Sat, 09 Feb 2013 23:54:09 +0100 Jacob Carlborg <doob me.com> wrote:On 2013-02-09 21:51, Nick Sabalausky wrote:Yea, but not the part of reflection I was trying to refer to. Wasn't sure what to call it besides the overly-general "reflection mechanism".I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.Couldn't typeof() be considered part of a reflection mechanism?
Feb 09 2013
On Saturday, 9 February 2013 at 22:54:09 UTC, Jacob Carlborg wrote:On 2013-02-09 21:51, Nick Sabalausky wrote:May be, but definitely not an advanced librar'ish one - contrary to .tupleof and some __traits is is a pretty common guest in user code.I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.Couldn't typeof() be considered part of a reflection mechanism?
Feb 10 2013
Am 10.02.2013 11:21, schrieb Dicebot:On Saturday, 9 February 2013 at 22:54:09 UTC, Jacob Carlborg wrote:Really? I'm using typeof all over the place in my user code.On 2013-02-09 21:51, Nick Sabalausky wrote:May be, but definitely not an advanced librar'ish one - contrary to .tupleof and some __traits is is a pretty common guest in user code.I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.Couldn't typeof() be considered part of a reflection mechanism?
Feb 10 2013
On Sunday, 10 February 2013 at 10:22:59 UTC, Benjamin Thaut wrote:Really? I'm using typeof all over the place in my user code.That is exactly what I have just said :) And reason why it should behave according to usual protection attribute rules.
Feb 10 2013
Am 10.02.2013 11:55, schrieb Dicebot:On Sunday, 10 February 2013 at 10:22:59 UTC, Benjamin Thaut wrote:Oh ok, then I misunderstood your argument.Really? I'm using typeof all over the place in my user code.That is exactly what I have just said :) And reason why it should behave according to usual protection attribute rules.
Feb 10 2013