www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - nested class inheritance

reply Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--bcaec5523980f7d0bd04c4b9d868
Content-Type: text/plain; charset=UTF-8

Doesn't this make sense?

class Fruit
{
    class Seed { }
}

class Apple: Fruit
{
     class AppleSeed: Fruit.Seed { }
}

This means, that as Fruit.Seed needs access to enclosing Fruit, AppleSeed,
being a Fruit.Seed will also have access to enclosing Fruit, which is Apple.
DMD 0.259 has this to say:

Error: class main.Apple.AppleSeed is nested within Apple, but super class
Seed is nested within Fruit

Which doesn't make sense, IMO. What do you guys think about this? Who makes
more sense me or DMD 2.059?

-- 
Bye,
Gor Gyolchanyan.

--bcaec5523980f7d0bd04c4b9d868
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Doesn&#39;t this make sense?<div><br></div><div>class Fruit</div><div>{</di=
v><div>=C2=A0 =C2=A0 class Seed=C2=A0{=C2=A0}</div><div>}</div><div><br></d=
iv><div>class Apple: Fruit</div><div>{</div><div>=C2=A0 =C2=A0 =C2=A0class =
AppleSeed: Fruit.Seed=C2=A0{=C2=A0}</div><div>
}<br clear=3D"all"><div><br></div><div>This means, that as Fruit.Seed needs=
 access to enclosing Fruit, AppleSeed, being a Fruit.Seed will also have ac=
cess to enclosing Fruit, which is Apple.</div><div>DMD 0.259 has this to sa=
y:</div>
<div><br></div><div>Error: class main.Apple.AppleSeed is nested within Appl=
e, but super class Seed is nested within Fruit</div><div><br></div><div>Whi=
ch doesn&#39;t make sense, IMO. What do you guys think about this? Who make=
s more sense me or DMD 2.059?</div>
<div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>

--bcaec5523980f7d0bd04c4b9d868--
Jul 13 2012
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/13/12 1:59 PM, Gor Gyolchanyan wrote:
 Doesn't this make sense?

 class Fruit
 {
      class Seed { }
 }

 class Apple: Fruit
 {
       class AppleSeed: Fruit.Seed { }
 }

 This means, that as Fruit.Seed needs access to enclosing Fruit,
 AppleSeed, being a Fruit.Seed will also have access to enclosing Fruit,
 which is Apple.
 DMD 0.259 has this to say:

 Error: class main.Apple.AppleSeed is nested within Apple, but super
 class Seed is nested within Fruit

 Which doesn't make sense, IMO. What do you guys think about this? Who
 makes more sense me or DMD 2.059?

Untested: class Fruit { static class Seed { } } class Apple: Fruit { static class AppleSeed: Fruit.Seed { } } Andrei
Jul 13 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/13/12 2:30 PM, Gor Gyolchanyan wrote:
 The whole point is to have it not static. I need it to be properly
 nested with the this.outer.

What would be the type of this.outer? Andrei
Jul 13 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/13/12 3:07 PM, Gor Gyolchanyan wrote:
 On Fri, Jul 13, 2012 at 11:03 PM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org <mailto:SeeWebsiteForEmail erdani.org>>
 wrote:

     On 7/13/12 2:30 PM, Gor Gyolchanyan wrote:

         The whole point is to have it not static. I need it to be properly
         nested with the this.outer.


     What would be the type of this.outer?

     Andrei


 For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
 because the Apple, which AppleSeed sees is the same object, which
 Fruit.Seed sees as it's base type Fruit.

That would mean AppleSeed has two outer fields: a Fruit and an Apple. Andrei
Jul 13 2012
next sibling parent reply travert phare.normalesup.org (Christophe Travert) writes:
Andrei Alexandrescu , dans le message (digitalmars.D:172280), a écrit :
 For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
 because the Apple, which AppleSeed sees is the same object, which
 Fruit.Seed sees as it's base type Fruit.

That would mean AppleSeed has two outer fields: a Fruit and an Apple.

Only one. Apple. And when AppleSeed.super seed this Apple, it sees a fruit. AppleSeed a; assert(is(typeof(a.outer) == Apple)); assert(is(typeof(a.super) == Seed)); assert(is(typeof(a.super.outer) == Fruit)); //but: assert(a.outer is a.super.outer); If you can't figure out how can a.outer and a.super.outer have two different types, but be the same, think about covariant return.
Jul 13 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/13/12 3:18 PM, Christophe Travert wrote:
 Andrei Alexandrescu , dans le message (digitalmars.D:172280), a écrit :
 For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
 because the Apple, which AppleSeed sees is the same object, which
 Fruit.Seed sees as it's base type Fruit.

That would mean AppleSeed has two outer fields: a Fruit and an Apple.

Only one. Apple. And when AppleSeed.super seed this Apple, it sees a fruit. AppleSeed a; assert(is(typeof(a.outer) == Apple)); assert(is(typeof(a.super) == Seed)); assert(is(typeof(a.super.outer) == Fruit)); //but: assert(a.outer is a.super.outer); If you can't figure out how can a.outer and a.super.outer have two different types, but be the same, think about covariant return.

Makes sense, thanks. Andrei
Jul 13 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:
 The initial question was: why does DMD 2.059 reject this if this makes
 sense?
 It's not even a new feature. It's a (possibly) new (and apparently
 sensible) use case of an existing feature.

I think the simple answer is there was no provision for it. The feature copies the Java feature, and I don't think Java has something like what you defined. Andrei
Jul 13 2012
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/13/12 3:49 PM, Gor Gyolchanyan wrote:
 On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org <mailto:SeeWebsiteForEmail erdani.org>>
 wrote:

     On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:

         The initial question was: why does DMD 2.059 reject this if this
         makes
         sense?
         It's not even a new feature. It's a (possibly) new (and apparently
         sensible) use case of an existing feature.


     I think the simple answer is there was no provision for it. The
     feature copies the Java feature, and I don't think Java has
     something like what you defined.

     Andrei


 Well, the nested classes are pretty much useless without this feature.
 Except for translating Java code. If I had multiple inheritance, I'd
 just make the Apple as base class and have all the seeds virtually
 derive from it. Not having multiple inheritance drove me to try the next
 best think. And after it failed, I complained about it.. And here we
 are. Is it a difficult thing to fix?

I don't know, you may want to submit an enhancement request. Andrei
Jul 13 2012
parent reply deadalnix <deadalnix gmail.com> writes:
On 14/07/2012 08:27, Gor Gyolchanyan wrote:
 On Sat, Jul 14, 2012 at 12:31 AM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org <mailto:SeeWebsiteForEmail erdani.org>>
 wrote:

     On 7/13/12 3:49 PM, Gor Gyolchanyan wrote:

         On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexandrescu
         <SeeWebsiteForEmail erdani.org
         <mailto:SeeWebsiteForEmail erdani.org>
         <mailto:SeeWebsiteForEmail __erdani.org
         <mailto:SeeWebsiteForEmail erdani.org>>>

         wrote:

              On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:

                  The initial question was: why does DMD 2.059 reject
         this if this
                  makes
                  sense?
                  It's not even a new feature. It's a (possibly) new (and
         apparently
                  sensible) use case of an existing feature.


              I think the simple answer is there was no provision for it. The
              feature copies the Java feature, and I don't think Java has
              something like what you defined.

              Andrei


         Well, the nested classes are pretty much useless without this
         feature.
         Except for translating Java code. If I had multiple inheritance, I'd
         just make the Apple as base class and have all the seeds virtually
         derive from it. Not having multiple inheritance drove me to try
         the next
         best think. And after it failed, I complained about it.. And here we

         are. Is it a difficult thing to fix?


     I don't know, you may want to submit an enhancement request.

     Andrei


 http://d.puremagic.com/issues/show_bug.cgi?id=8389

 Anyone who thinks this is important, please vote up.

 --
 Bye,
 Gor Gyolchanyan.

This is something to do, but I don't know if it is really that important.
Jul 14 2012
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
The only problem about this is:

class Fruit
{
   class Seed {
     void SetFruit(Fruit fruit)
     {
       this.outer = fruit;
     }
   }
}

class Apple: Fruit
{
   void AppleOnlyMethod(){ ... }

   class AppleSeed: Fruit.Seed {
     void DoSomething()
     {
       AppleOnlyMethod();
     }
   }

   auto GetNewSeed() { return new AppleSeed(); }
}

auto apple = new Apple();
auto seed = apple.GetNewSeed();
seed.SetFruit(new Fruit());
seed.DoSomething(); //what happens here?

Kind Regards
Benjamin Thaut
Jul 14 2012
next sibling parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 14.07.2012 19:18, schrieb Gor Gyolchanyan:
 On Sat, Jul 14, 2012 at 9:12 PM, Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de>> wrote:

     The only problem about this is:

     class Fruit
     {
        class Seed {
          void SetFruit(Fruit fruit)
          {
            this.outer = fruit;
          }
        }
     }

     class Apple: Fruit
     {
        void AppleOnlyMethod(){ ... }

        class AppleSeed: Fruit.Seed {
          void DoSomething()
          {
            AppleOnlyMethod();
          }
        }

        auto GetNewSeed() { return new AppleSeed(); }
     }

     auto apple = new Apple();
     auto seed = apple.GetNewSeed();
     seed.SetFruit(new Fruit());
     seed.DoSomething(); //what happens here?

     Kind Regards
     Benjamin Thaut


 I think this.outer is not an lvalue, which solves the problem. It
 wouldn't make sense to have it an lvalue, because the object is
 specifically created out of the initial outer object.

 --
 Bye,
 Gor Gyolchanyan.

The last time I checked you could reassign outer ;-)
Jul 14 2012
prev sibling parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 14.07.2012 19:21, schrieb kenji hara:
 2012/7/15 Benjamin Thaut <code benjamin-thaut.de>:
 The only problem about this is:

 class Fruit
 {
    class Seed {
      void SetFruit(Fruit fruit)
      {
        this.outer = fruit;

Setting to pseudo variable 'outer' should be rejected in compilation. Please report it to bugzilla.
      }
    }
 }

 class Apple: Fruit
 {
    void AppleOnlyMethod(){ ... }

    class AppleSeed: Fruit.Seed {
      void DoSomething()
      {
        AppleOnlyMethod();
      }
    }

    auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut

Kenji Hara

I will not report this, beacuse it will break my custom new operator (template) for inner classes ;-) Kind Regards Benjamin Thaut
Jul 14 2012
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:
 On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de>> wrote:

     Am 14.07.2012 19:21, schrieb kenji hara:

         2012/7/15 Benjamin Thaut <code benjamin-thaut.de
         <mailto:code benjamin-thaut.de>>:

             The only problem about this is:

             class Fruit
             {
                 class Seed {
                   void SetFruit(Fruit fruit)
                   {
                     this.outer = fruit;


         Setting to pseudo variable 'outer' should be rejected in
         compilation.
         Please report it to bugzilla.

                   }
                 }
             }

             class Apple: Fruit
             {
                 void AppleOnlyMethod(){ ... }

                 class AppleSeed: Fruit.Seed {
                   void DoSomething()
                   {
                     AppleOnlyMethod();
                   }
                 }

                 auto GetNewSeed() { return new AppleSeed(); }
             }

             auto apple = new Apple();
             auto seed = apple.GetNewSeed();
             seed.SetFruit(new Fruit());
             seed.DoSomething(); //what happens here?

             Kind Regards
             Benjamin Thaut


         Kenji Hara


     I will not report this, beacuse it will break my custom new operator
     (template) for inner classes ;-)

     Kind Regards
     Benjamin Thaut


 That's most unwise, because if it's not supposed to be like that it will
 get fixed anyway, so you better start replacing your custom new operator.

 --
 Bye,
 Gor Gyolchanyan.

Replacing my custom new operator exactly by what? Overloading the build in new is deprecated...
Jul 14 2012
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 07/15/2012 12:55 AM, Benjamin Thaut wrote:
 Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:
 On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de>> wrote:

 Am 14.07.2012 19:21, schrieb kenji hara:

 2012/7/15 Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de>>:

 The only problem about this is:

 class Fruit
 {
 class Seed {
 void SetFruit(Fruit fruit)
 {
 this.outer = fruit;


 Setting to pseudo variable 'outer' should be rejected in
 compilation.
 Please report it to bugzilla.

 }
 }
 }

 class Apple: Fruit
 {
 void AppleOnlyMethod(){ ... }

 class AppleSeed: Fruit.Seed {
 void DoSomething()
 {
 AppleOnlyMethod();
 }
 }

 auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut


 Kenji Hara


 I will not report this, beacuse it will break my custom new operator
 (template) for inner classes ;-)

 Kind Regards
 Benjamin Thaut


 That's most unwise, because if it's not supposed to be like that it will
 get fixed anyway, so you better start replacing your custom new operator.

 --
 Bye,
 Gor Gyolchanyan.

Replacing my custom new operator exactly by what? Overloading the build in new is deprecated...

class C{ class D{ } } void main(){ auto c = new C; auto buf = new void[__traits(classInstanceSize, C.D)]; (cast(byte[])buf)[] = typeid(C.D).init[]; auto d = cast(C.D)buf.ptr; static if(is(typeof(d.__ctor()))) d.__ctor(); enum offset=d.outer.offsetof; static assert(offset%C.sizeof==0); (cast(C[])buf)[offset/C.sizeof]=c; assert(d.outer is c); }
Jul 14 2012
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 15.07.2012 02:02, schrieb Timon Gehr:
 On 07/15/2012 12:55 AM, Benjamin Thaut wrote:
 Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:
 On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de>> wrote:

 Am 14.07.2012 19:21, schrieb kenji hara:

 2012/7/15 Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de>>:

 The only problem about this is:

 class Fruit
 {
 class Seed {
 void SetFruit(Fruit fruit)
 {
 this.outer = fruit;


 Setting to pseudo variable 'outer' should be rejected in
 compilation.
 Please report it to bugzilla.

 }
 }
 }

 class Apple: Fruit
 {
 void AppleOnlyMethod(){ ... }

 class AppleSeed: Fruit.Seed {
 void DoSomething()
 {
 AppleOnlyMethod();
 }
 }

 auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut


 Kenji Hara


 I will not report this, beacuse it will break my custom new operator
 (template) for inner classes ;-)

 Kind Regards
 Benjamin Thaut


 That's most unwise, because if it's not supposed to be like that it will
 get fixed anyway, so you better start replacing your custom new
 operator.

 --
 Bye,
 Gor Gyolchanyan.

Replacing my custom new operator exactly by what? Overloading the build in new is deprecated...

class C{ class D{ } } void main(){ auto c = new C; auto buf = new void[__traits(classInstanceSize, C.D)]; (cast(byte[])buf)[] = typeid(C.D).init[]; auto d = cast(C.D)buf.ptr; static if(is(typeof(d.__ctor()))) d.__ctor(); enum offset=d.outer.offsetof; static assert(offset%C.sizeof==0); (cast(C[])buf)[offset/C.sizeof]=c; assert(d.outer is c); }

Yes of course I can assign the reference by computing the address and then using that to assign it. But the point here is, that this is currently the only bug that is hepling me in what I'm doing, and I rather want the 7 other bugs I reported so far to be fixed, rather then the one that helps me. Kind Regards Benjamin Thaut
Jul 15 2012
parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 15.07.2012 13:24, schrieb Gor Gyolchanyan:
 On Sun, Jul 15, 2012 at 1:41 PM, Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de>> wrote:

     Am 15.07.2012 02:02, schrieb Timon Gehr:

         On 07/15/2012 12:55 AM, Benjamin Thaut wrote:

             Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:

                 On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut
                 <code benjamin-thaut.de <mailto:code benjamin-thaut.de>
                 <mailto:code benjamin-thaut.de
                 <mailto:code benjamin-thaut.de>__>> wrote:

                 Am 14.07.2012 19:21, schrieb kenji hara:

                 2012/7/15 Benjamin Thaut <code benjamin-thaut.de
                 <mailto:code benjamin-thaut.de>
                 <mailto:code benjamin-thaut.de
                 <mailto:code benjamin-thaut.de>__>>:

                 The only problem about this is:

                 class Fruit
                 {
                 class Seed {
                 void SetFruit(Fruit fruit)
                 {
                 this.outer = fruit;


                 Setting to pseudo variable 'outer' should be rejected in
                 compilation.
                 Please report it to bugzilla.

                 }
                 }
                 }

                 class Apple: Fruit
                 {
                 void AppleOnlyMethod(){ ... }

                 class AppleSeed: Fruit.Seed {
                 void DoSomething()
                 {
                 AppleOnlyMethod();
                 }
                 }

                 auto GetNewSeed() { return new AppleSeed(); }
                 }

                 auto apple = new Apple();
                 auto seed = apple.GetNewSeed();
                 seed.SetFruit(new Fruit());
                 seed.DoSomething(); //what happens here?

                 Kind Regards
                 Benjamin Thaut


                 Kenji Hara


                 I will not report this, beacuse it will break my custom
                 new operator
                 (template) for inner classes ;-)

                 Kind Regards
                 Benjamin Thaut


                 That's most unwise, because if it's not supposed to be
                 like that it will
                 get fixed anyway, so you better start replacing your
                 custom new
                 operator.

                 --
                 Bye,
                 Gor Gyolchanyan.


             Replacing my custom new operator exactly by what?
             Overloading the build
             in new is deprecated...


         class C{
               class D{

               }
         }
         void main(){
               auto c = new C;
               auto buf = new void[__traits(__classInstanceSize, C.D)];
               (cast(byte[])buf)[] = typeid(C.D).init[];
               auto d = cast(C.D)buf.ptr;
               static if(is(typeof(d.__ctor()))) d.__ctor();
               enum offset=d.outer.offsetof;
               static assert(offset%C.sizeof==0);
               (cast(C[])buf)[offset/C.__sizeof]=c;
               assert(d.outer is c);
         }


     Yes of course I can assign the reference by computing the address
     and then using that to assign it. But the point here is, that this
     is currently the only bug that is hepling me in what I'm doing, and
     I rather want the 7 other bugs I reported so far to be fixed, rather
     then the one that helps me.

     Kind Regards
     Benjamin Thaut


 Not being able to assign is not about some sort of authoritative
 forbidding. It's about not breaking a working mechanism. You can't cast
 a function pointer into a class object not because the type system says
 so (which it does), but because that'll result in an undefined behavior,
 which will result in an immediate crash in the best scenario. Go ahead
 and change the outer via those hacks. But then don't get surprised when
 your program crashes for no reason (because the compiler assumed it not
 to change and ended up being wrong).

 --
 Bye,
 Gor Gyolchanyan.

Before your change suggestion it was absolutley save to assign to outer. Thats the whole point why I posted this here. I very well know that the bug will get fixed some time. But before your change suggestion it was not even a bug. Kind Regards Benjamin Thaut
Jul 15 2012
prev sibling parent reply Guillaume Chatelet <chatelet.guillaume gmail.com> writes:
On 07/13/12 21:41, Andrei Alexandrescu wrote:
 On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:
 The initial question was: why does DMD 2.059 reject this if this makes
 sense?
 It's not even a new feature. It's a (possibly) new (and apparently
 sensible) use case of an existing feature.

I think the simple answer is there was no provision for it. The feature copies the Java feature, and I don't think Java has something like what you defined. Andrei

class Fruit { class Seed { } } class Apple extends Fruit { class AppleSeed extends Fruit.Seed { Apple getOuter() { return Apple.this; } } } class Main { public static void main(String[] args) { final Apple apple = new Apple(); final Apple.AppleSeed appleSeed = apple.new AppleSeed(); assert (appleSeed instanceof Fruit.Seed); assert (apple == appleSeed.getOuter()); assert (appleSeed.getOuter() instanceof Apple); assert (appleSeed.getOuter() instanceof Fruit); } } This is valid Java code actually and I agree with Gor I would have expected it to work with D. Guillaume
Jul 14 2012
next sibling parent Paulo Pinto <pjmlp progtools.org> writes:
Am 14.07.2012 11:45, schrieb Gor Gyolchanyan:
 On Sat, Jul 14, 2012 at 1:36 PM, Guillaume Chatelet
 <chatelet.guillaume gmail.com <mailto:chatelet.guillaume gmail.com>> wrote:

     On 07/13/12 21:41, Andrei Alexandrescu wrote:
      > On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:
      >> The initial question was: why does DMD 2.059 reject this if this
     makes
      >> sense?
      >> It's not even a new feature. It's a (possibly) new (and apparently
      >> sensible) use case of an existing feature.
      >
      > I think the simple answer is there was no provision for it. The
     feature
      > copies the Java feature, and I don't think Java has something
     like what
      > you defined.
      >
      > Andrei
      >

     class Fruit {
          class Seed {
          }
     }

     class Apple extends Fruit {
          class AppleSeed extends Fruit.Seed {
              Apple getOuter() {
                  return Apple.this;
              }
          }
     }

     class Main {
          public static void main(String[] args) {
              final Apple apple = new Apple();
              final Apple.AppleSeed appleSeed = apple.new AppleSeed();
              assert (appleSeed instanceof Fruit.Seed);
              assert (apple == appleSeed.getOuter());
              assert (appleSeed.getOuter() instanceof Apple);
              assert (appleSeed.getOuter() instanceof Fruit);
          }
     }

     This is valid Java code actually and I agree with Gor I would have
     expected it to work with D.

     Guillaume


 I didn't even know this worked in Java. This means, that nested classed
 in D can't translate nested classed in Java after all.

This usually comes up in certification and interview questions.
Jul 14 2012
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/14/12 5:36 AM, Guillaume Chatelet wrote:
 class Fruit {
      class Seed {
      }
 }

 class Apple extends Fruit {
      class AppleSeed extends Fruit.Seed {
          Apple getOuter() {
              return Apple.this;
          }
      }
 }

 class Main {
      public static void main(String[] args) {
          final Apple apple = new Apple();
          final Apple.AppleSeed appleSeed = apple.new AppleSeed();
          assert (appleSeed instanceof Fruit.Seed);
          assert (apple == appleSeed.getOuter());
          assert (appleSeed.getOuter() instanceof Apple);
          assert (appleSeed.getOuter() instanceof Fruit);
      }
 }

 This is valid Java code actually and I agree with Gor I would have
 expected it to work with D.

 Guillaume

You may want to add the example to the bug report. Thanks, Andrei
Jul 14 2012
parent Guillaume Chatelet <chatelet.guillaume gmail.com> writes:
On 07/14/12 13:51, Andrei Alexandrescu wrote:
 On 7/14/12 5:36 AM, Guillaume Chatelet wrote:
 class Fruit {
      class Seed {
      }
 }

 class Apple extends Fruit {
      class AppleSeed extends Fruit.Seed {
          Apple getOuter() {
              return Apple.this;
          }
      }
 }

 class Main {
      public static void main(String[] args) {
          final Apple apple = new Apple();
          final Apple.AppleSeed appleSeed = apple.new AppleSeed();
          assert (appleSeed instanceof Fruit.Seed);
          assert (apple == appleSeed.getOuter());
          assert (appleSeed.getOuter() instanceof Apple);
          assert (appleSeed.getOuter() instanceof Fruit);
      }
 }

 This is valid Java code actually and I agree with Gor I would have
 expected it to work with D.

 Guillaume

You may want to add the example to the bug report. Thanks, Andrei

Done. http://d.puremagic.com/issues/show_bug.cgi?id=8389 Guillaume
Jul 14 2012
prev sibling parent deadalnix <deadalnix gmail.com> writes:
On 13/07/2012 21:10, Andrei Alexandrescu wrote:
 On 7/13/12 3:07 PM, Gor Gyolchanyan wrote:
 On Fri, Jul 13, 2012 at 11:03 PM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org <mailto:SeeWebsiteForEmail erdani.org>>
 wrote:

 On 7/13/12 2:30 PM, Gor Gyolchanyan wrote:

 The whole point is to have it not static. I need it to be properly
 nested with the this.outer.


 What would be the type of this.outer?

 Andrei


 For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
 because the Apple, which AppleSeed sees is the same object, which
 Fruit.Seed sees as it's base type Fruit.

That would mean AppleSeed has two outer fields: a Fruit and an Apple. Andrei

An Apple is a Fruit, so it shouldn't be a problem and don't require 2 fields.
Jul 14 2012
prev sibling next sibling parent reply "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan wrote:
 Doesn't this make sense?

 class Fruit
 {
     class Seed { }
 }

 class Apple: Fruit
 {
      class AppleSeed: Fruit.Seed { }
 }

 This means, that as Fruit.Seed needs access to enclosing Fruit, 
 AppleSeed, being a Fruit.Seed will also have access to 
 enclosing Fruit, which is Apple.
 DMD 0.259 has this to say:

 Error: class main.Apple.AppleSeed is nested within Apple, but  
 super class Seed is nested within Fruit

 Which doesn't make sense, IMO. What do you guys think about 
 this? Who makes more sense me or DMD 2.059?

I'd say DMD makes more sense. Seed has knowledge of itself AND Fruit. So if it's following the same rules and for how it makes sense, then unless you add static to Seed, then you won't get it to work. Reminds me of when I used Java years ago experimenting with inner classes, came to a distinct conclusion of object referencing and why it didn't want to work without an outer object. Consider: fails on seed, not seed2. class Fruit { int x; class Seed { void oneMoreToX() { x++; //knows about Fruit.x, even if not instantiated } } static class Seed2 { void oneMoreToX() { // x++; //fails to compile, no knowledge of Fruit } } } class Apple: Fruit { class AppleSeed: Fruit.Seed { } //fails (no outer object (Fruit.x) and makes no sense) class AppleSeed2: Fruit.Seed2 { } //works fine }
Jul 13 2012
next sibling parent travert phare.normalesup.org (Christophe Travert) writes:
"Era Scarecrow" , dans le message (digitalmars.D:172269), a écrit :
 class Fruit {
   int x;
   class Seed {
    void oneMoreToX() {
     x++; //knows about Fruit.x, even if not instantiated
    }
   }
 
   static class Seed2 {
    void oneMoreToX() {
 //  x++; //fails to compile, no knowledge of Fruit
    }
   }
 }
 
 class Apple: Fruit {
   class AppleSeed: Fruit.Seed { } //fails (no outer object 
 (Fruit.x) and makes no sense)
   class AppleSeed2: Fruit.Seed2 { } //works fine
 }

AppleSeed does have a outer Fruit, and this Fruit happens to be an Apple. I don't see what is the issue, and what prevents the langage to support such AppleSeed. I'm not saying there is nothing that prevents the langage to support such pattern, I am not used to inner classes. Pleas enlighten me.
Jul 13 2012
prev sibling parent travert phare.normalesup.org (Christophe Travert) writes:
"Era Scarecrow" , dans le message (digitalmars.D:172272), a écrit :
   Then perhaps have the inherited class within fruit?
 
 class Fruit {
    class Seed {}
    class Appleseed : Seed {}
 }

But then AppleSeed doesn't know about Apple....
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d042c5ed7873fe904c4ba463c
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 13, 2012 at 10:19 PM, Andrei Alexandrescu <
SeeWebsiteForEmail erdani.org> wrote:

 On 7/13/12 1:59 PM, Gor Gyolchanyan wrote:

 Doesn't this make sense?

 class Fruit
 {
      class Seed { }
 }

 class Apple: Fruit
 {
       class AppleSeed: Fruit.Seed { }
 }

 This means, that as Fruit.Seed needs access to enclosing Fruit,
 AppleSeed, being a Fruit.Seed will also have access to enclosing Fruit,
 which is Apple.
 DMD 0.259 has this to say:

 Error: class main.Apple.AppleSeed is nested within Apple, but super
 class Seed is nested within Fruit

 Which doesn't make sense, IMO. What do you guys think about this? Who
 makes more sense me or DMD 2.059?

Untested: class Fruit { static class Seed { } } class Apple: Fruit { static class AppleSeed: Fruit.Seed { } } Andrei

The whole point is to have it not static. I need it to be properly nested with the this.outer. -- Bye, Gor Gyolchanyan. --f46d042c5ed7873fe904c4ba463c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 10:19 PM, Andrei Alexand= rescu <span dir=3D"ltr">&lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org= " target=3D"_blank">SeeWebsiteForEmail erdani.org</a>&gt;</span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On 7/13/12 1:59 PM, Gor Gyolchanyan= wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Doesn&#39;t this make sense?<br> <br> class Fruit<br> {<br> =C2=A0 =C2=A0 =C2=A0class Seed { }<br> }<br> <br> class Apple: Fruit<br> {<br> =C2=A0 =C2=A0 =C2=A0 class AppleSeed: Fruit.Seed { }<br> }<br> <br> This means, that as Fruit.Seed needs access to enclosing Fruit,<br> AppleSeed, being a Fruit.Seed will also have access to enclosing Fruit,<br> which is Apple.<br> DMD 0.259 has this to say:<br> <br> Error: class main.Apple.AppleSeed is nested within Apple, but super<br> class Seed is nested within Fruit<br> <br> Which doesn&#39;t make sense, IMO. What do you guys think about this? Who<b= r> makes more sense me or DMD 2.059?<br> </blockquote> <br></div></div> Untested:<br> <br> class Fruit<br> {<br> =C2=A0 =C2=A0 static class Seed { }<br> }<br> <br> class Apple: Fruit<br> {<br> =C2=A0 =C2=A0 =C2=A0static class AppleSeed: Fruit.Seed { }<br> }<span class=3D"HOEnZb"><font color=3D"#888888"><br> <br> <br> Andrei<br> </font></span></blockquote></div><br>The whole point is to have it not stat= ic. I need it to be properly nested with the this.outer.<br clear=3D"all"><= div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --f46d042c5ed7873fe904c4ba463c--
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0401730b961e6004c4ba52fd
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 13, 2012 at 10:25 PM, Era Scarecrow <rtcvb32 yahoo.com> wrote:

 On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan wrote:

 Doesn't this make sense?

 class Fruit
 {
     class Seed { }
 }

 class Apple: Fruit
 {
      class AppleSeed: Fruit.Seed { }
 }

 This means, that as Fruit.Seed needs access to enclosing Fruit,
 AppleSeed, being a Fruit.Seed will also have access to enclosing Fruit,
 which is Apple.
 DMD 0.259 has this to say:

 Error: class main.Apple.AppleSeed is nested within Apple, but  super
 class Seed is nested within Fruit

 Which doesn't make sense, IMO. What do you guys think about this? Who
 makes more sense me or DMD 2.059?

I'd say DMD makes more sense. Seed has knowledge of itself AND Fruit. So if it's following the same rules and for how it makes sense, then unless you add static to Seed, then you won't get it to work. Reminds me of when I used Java years ago experimenting with inner classes, came to a distinct conclusion of object referencing and why it didn't want to work without an outer object. Consider: fails on seed, not seed2. class Fruit { int x; class Seed { void oneMoreToX() { x++; //knows about Fruit.x, even if not instantiated } } static class Seed2 { void oneMoreToX() { // x++; //fails to compile, no knowledge of Fruit } } } class Apple: Fruit { class AppleSeed: Fruit.Seed { } //fails (no outer object (Fruit.x) and makes no sense) class AppleSeed2: Fruit.Seed2 { } //works fine }

I need Seed to have a reference to Fruit because there will be more then one derivative of Seed in the same derivative of Fruit and they all need to store data inside the fruit and communicate with each other in that way. That's why Seed can't be static. What can I do to have multiple seeds in the same fruit with all seed-fruit-seed communication hidden in the base classes? -- Bye, Gor Gyolchanyan. --f46d0401730b961e6004c4ba52fd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 10:25 PM, Era Scarecrow = <span dir=3D"ltr">&lt;<a href=3D"mailto:rtcvb32 yahoo.com" target=3D"_blank= ">rtcvb32 yahoo.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quo= te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=

wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Doesn&#39;t this make sense?<br> <br> class Fruit<br> {<br> =C2=A0 =C2=A0 class Seed { }<br> }<br> <br> class Apple: Fruit<br> {<br> =C2=A0 =C2=A0 =C2=A0class AppleSeed: Fruit.Seed { }<br> }<br> <br> This means, that as Fruit.Seed needs access to enclosing Fruit, AppleSeed, = being a Fruit.Seed will also have access to enclosing Fruit, which is Apple= .<br> DMD 0.259 has this to say:<br> <br> Error: class main.Apple.AppleSeed is nested within Apple, but =C2=A0super c= lass Seed is nested within Fruit<br> <br> Which doesn&#39;t make sense, IMO. What do you guys think about this? Who m= akes more sense me or DMD 2.059?<br> </blockquote> <br></div> =C2=A0I&#39;d say DMD makes more sense. Seed has knowledge of itself AND Fr= uit. So if it&#39;s following the same rules and for how it makes sense, th= en unless you add static to Seed, then you won&#39;t get it to work. Remind= s me of when I used Java years ago experimenting with inner classes, came t= o a distinct conclusion of object referencing and why it didn&#39;t want to= work without an outer object.<br> <br> =C2=A0Consider: fails on seed, not seed2.<br> <br> class Fruit {<br> =C2=A0int x;<br> =C2=A0class Seed {<br> =C2=A0 void oneMoreToX() {<br> =C2=A0 =C2=A0x++; //knows about Fruit.x, even if not instantiated<br> =C2=A0 }<br> =C2=A0}<br> <br> =C2=A0static class Seed2 {<br> =C2=A0 void oneMoreToX() {<br> // =C2=A0x++; //fails to compile, no knowledge of Fruit<br> =C2=A0 }<br> =C2=A0}<br> }<br> <br> class Apple: Fruit {<br> =C2=A0class AppleSeed: Fruit.Seed { } //fails (no outer object (Fruit.x) an= d makes no sense)<br> =C2=A0class AppleSeed2: Fruit.Seed2 { } //works fine<br> }<br> </blockquote></div><br>I need Seed to have a reference to Fruit because the= re will be more then one derivative of Seed in the same derivative of Fruit= and they all need to store data inside the fruit and communicate with each= other in that way. That&#39;s why Seed can&#39;t be static. What can I do = to have multiple seeds in the same fruit with all seed-fruit-seed communica= tion hidden in the base classes?<div> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> </div> --f46d0401730b961e6004c4ba52fd--
Jul 13 2012
prev sibling next sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Friday, 13 July 2012 at 18:34:06 UTC, Gor Gyolchanyan wrote:
 I need Seed to have a reference to Fruit because there will be 
 more then one derivative of Seed in the same derivative of 
 Fruit and they all need to store data inside the fruit and 
 communicate with each other in that way. That's why Seed can't 
 be static. What can I do to have multiple seeds in the same 
 fruit with all seed-fruit-seed communication hidden in the base 
 classes?

Then perhaps have the inherited class within fruit? class Fruit { class Seed {} class Appleseed : Seed {} }
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--e0cb4efe33903c415b04c4bab62d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 13, 2012 at 10:55 PM, Christophe Travert <
travert phare.normalesup.org> wrote:

 "Era Scarecrow" , dans le message (digitalmars.D:172272), a =C3=A9crit :
   Then perhaps have the inherited class within fruit?

 class Fruit {
    class Seed {}
    class Appleseed : Seed {}
 }

But then AppleSeed doesn't know about Apple....

of fruits like Apple, each of which can have tons of different Seeds. I really didn't get why my original example didn't make sense. --=20 Bye, Gor Gyolchanyan. --e0cb4efe33903c415b04c4bab62d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 10:55 PM, Christophe Tra= vert <span dir=3D"ltr">&lt;<a href=3D"mailto:travert phare.normalesup.org" = target=3D"_blank">travert phare.normalesup.org</a>&gt;</span> wrote:<br><bl= ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #= ccc solid;padding-left:1ex"> &quot;Era Scarecrow&quot; , dans le message (digitalmars.D:172272), a =C3= =A9crit=C2=A0:<br> <div class=3D"im">&gt; =C2=A0 Then perhaps have the inherited class within = fruit?<br> &gt;<br> &gt; class Fruit {<br> &gt; =C2=A0 =C2=A0class Seed {}<br> &gt; =C2=A0 =C2=A0class Appleseed : Seed {}<br> &gt; }<br> <br> </div>But then AppleSeed doesn&#39;t know about Apple....<br> <br> </blockquote></div><br>Right. And Fruit.Seed can&#39;t know about Apple eit= her, because there are tons of fruits like Apple, each of which can have to= ns of different Seeds.<div>I really didn&#39;t get why my original example = didn&#39;t make sense.</div> <div><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> </div> --e0cb4efe33903c415b04c4bab62d--
Jul 13 2012
prev sibling next sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Friday, 13 July 2012 at 18:55:28 UTC, 
travert phare.normalesup.org (Christophe Travert) wrote:
 "Era Scarecrow" , dans le message (digitalmars.D:172272), a 
 écrit :
   Then perhaps have the inherited class within fruit?
 
 class Fruit {
    class Seed {}
    class Appleseed : Seed {}
 }

But then AppleSeed doesn't know about Apple....

So I forgot the apple :P But then inner inheritance won't work. class Fruit { class Seed {} class Apple { class Appleseed : Seed {} //same error as before } } If you make seed static, then Appleseed & apple will have access to Fruit but seed (by itself) won't. Other combinations faile as far as I can tell. How far you can take inner class inheritance I don't know, but it seems not that many levels.
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--e0cb4efe3390d36e1e04c4bacbdb
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 13, 2012 at 11:03 PM, Andrei Alexandrescu <
SeeWebsiteForEmail erdani.org> wrote:

 On 7/13/12 2:30 PM, Gor Gyolchanyan wrote:

 The whole point is to have it not static. I need it to be properly
 nested with the this.outer.

What would be the type of this.outer? Andrei

because the Apple, which AppleSeed sees is the same object, which Fruit.Seed sees as it's base type Fruit. -- Bye, Gor Gyolchanyan. --e0cb4efe3390d36e1e04c4bacbdb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 11:03 PM, Andrei Alexand= rescu <span dir=3D"ltr">&lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org= " target=3D"_blank">SeeWebsiteForEmail erdani.org</a>&gt;</span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> <div class=3D"im">On 7/13/12 2:30 PM, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> The whole point is to have it not static. I need it to be properly<br> nested with the this.outer.<br> </blockquote> <br></div> What would be the type of this.outer?<span class=3D"HOEnZb"><font color=3D"= #888888"><br> <br> Andrei<br> <br> </font></span></blockquote></div><br>For Fruit.Seed it&#39;s Fruit, for App= leSeed it&#39;s Apple. This makes sense because the Apple, which AppleSeed = sees is the same object, which Fruit.Seed sees as it&#39;s base type Fruit.= <br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --e0cb4efe3390d36e1e04c4bacbdb--
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--bcaec554d8420d7afe04c4bacf7c
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 13, 2012 at 11:02 PM, Era Scarecrow <rtcvb32 yahoo.com> wrote:

 On Friday, 13 July 2012 at 18:55:28 UTC, travert phare.normalesup.org(Chr=

 "Era Scarecrow" , dans le message (digitalmars.D:172272), a =C3=A9crit :

   Then perhaps have the inherited class within fruit?

 class Fruit {
    class Seed {}
    class Appleseed : Seed {}
 }

But then AppleSeed doesn't know about Apple....

So I forgot the apple :P But then inner inheritance won't work. class Fruit { class Seed {} class Apple { class Appleseed : Seed {} //same error as before } } If you make seed static, then Appleseed & apple will have access to Frui=

 but seed (by itself) won't. Other combinations faile as far as I can tell=

 How far you can take inner class inheritance I don't know, but it seems n=

 that many levels.

This all won't work, because having Fruit know about Apple defeats the whole purpose. --=20 Bye, Gor Gyolchanyan. --bcaec554d8420d7afe04c4bacf7c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 11:02 PM, Era Scarecrow = <span dir=3D"ltr">&lt;<a href=3D"mailto:rtcvb32 yahoo.com" target=3D"_blank= ">rtcvb32 yahoo.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quo= te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=

UTC, <a href=3D"mailto:travert phare.normalesup.org" target=3D"_blank">tra= vert phare.normalesup.org</a> (Christophe Travert) wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> &quot;Era Scarecrow&quot; , dans le message (digitalmars.D:172272), a =C3= =A9crit=C2=A0:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> =C2=A0 Then perhaps have the inherited class within fruit?<br> <br> class Fruit {<br> =C2=A0 =C2=A0class Seed {}<br> =C2=A0 =C2=A0class Appleseed : Seed {}<br> }<br> </blockquote> <br> But then AppleSeed doesn&#39;t know about Apple....<br> </blockquote> <br></div></div> So I forgot the apple :P But then inner inheritance won&#39;t work.<br> <br> =C2=A0class Fruit {<br> =C2=A0 class Seed {}<br> =C2=A0 class Apple {<br> =C2=A0 =C2=A0class Appleseed : Seed {} //same error as before<br> =C2=A0 }<br> =C2=A0}<br> <br> =C2=A0If you make seed static, then Appleseed &amp; apple will have access = to Fruit but seed (by itself) won&#39;t. Other combinations faile as far as= I can tell. How far you can take inner class inheritance I don&#39;t know,= but it seems not that many levels.<br> </blockquote></div><br>This all won&#39;t work, because having Fruit know a= bout Apple defeats the whole purpose.<br clear=3D"all"><div><br></div>-- <b= r>Bye,<br>Gor Gyolchanyan.<br> --bcaec554d8420d7afe04c4bacf7c--
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0407160b187a7b04c4baf7ab
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 13, 2012 at 11:10 PM, Andrei Alexandrescu <
SeeWebsiteForEmail erdani.org> wrote:

 On 7/13/12 3:07 PM, Gor Gyolchanyan wrote:

 On Fri, Jul 13, 2012 at 11:03 PM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org
<mailto:SeeWebsiteForEmail **erdani.org<SeeWebsiteForEmail erdani.org>


wrote: On 7/13/12 2:30 PM, Gor Gyolchanyan wrote: The whole point is to have it not static. I need it to be properly nested with the this.outer. What would be the type of this.outer? Andrei For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense because the Apple, which AppleSeed sees is the same object, which Fruit.Seed sees as it's base type Fruit.

That would mean AppleSeed has two outer fields: a Fruit and an Apple. Andrei

difference is, that the Fruit.Seed would see it as Fruit and the AppleSeed would see it as Apple. And If someone derived from Apple and AppleSeed (say RedAple and RedAppleSeed), the RedAppleSeed would see the exact same object, except typed as RedApple. When you create a new AppleSeed, you need to create it from an Apple or something derived from an Apple. This ensures, that every seed sees the correct fruit as the correct type. -- Bye, Gor Gyolchanyan. --f46d0407160b187a7b04c4baf7ab Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 11:10 PM, Andrei Alexand= rescu <span dir=3D"ltr">&lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org= " target=3D"_blank">SeeWebsiteForEmail erdani.org</a>&gt;</span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> <div class=3D"im">On 7/13/12 3:07 PM, Gor Gyolchanyan wrote:<br> </div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"><div class=3D"im"> On Fri, Jul 13, 2012 at 11:03 PM, Andrei Alexandrescu<br></div> &lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org" target=3D"_blank">SeeW= ebsiteForEmail erdani.org</a> &lt;mailto:<a href=3D"mailto:SeeWebsiteForEma= il erdani.org" target=3D"_blank">SeeWebsiteForEmail <u></u>erdani.org</a>&g= t;&gt;<div> <div class=3D"h5"><br> wrote:<br> <br> =C2=A0 =C2=A0 On 7/13/12 2:30 PM, Gor Gyolchanyan wrote:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 The whole point is to have it not static. I nee= d it to be properly<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 nested with the this.outer.<br> <br> <br> =C2=A0 =C2=A0 What would be the type of this.outer?<br> <br> =C2=A0 =C2=A0 Andrei<br> <br> <br></div></div><div class=3D"im"> For Fruit.Seed it&#39;s Fruit, for AppleSeed it&#39;s Apple. This makes sen= se<br> because the Apple, which AppleSeed sees is the same object, which<br> Fruit.Seed sees as it&#39;s base type Fruit.<br> </div></blockquote> <br> That would mean AppleSeed has two outer fields: a Fruit and an Apple.<span = class=3D"HOEnZb"><font color=3D"#888888"><br> <br> Andrei<br> <br> </font></span></blockquote></div><br>Why? The this.outer would be the same = object from both perspectives. The difference is, that the Fruit.Seed would= see it as Fruit and the AppleSeed would see it as Apple. And If someone de= rived from Apple and AppleSeed (say RedAple and RedAppleSeed), the RedApple= Seed would see the exact same object, except typed as RedApple.<div> <br></div><div>When you create a new AppleSeed, you need to create it from = an Apple or something derived from an Apple. This ensures, that every seed = sees the correct fruit as the correct type.<br clear=3D"all"><div><br></div=

</div> --f46d0407160b187a7b04c4baf7ab--
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0401730b2d351304c4bb000d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 13, 2012 at 11:18 PM, Christophe Travert <
travert phare.normalesup.org> wrote:

 Andrei Alexandrescu , dans le message (digitalmars.D:172280), a =C3=A9cri=

 For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
 because the Apple, which AppleSeed sees is the same object, which
 Fruit.Seed sees as it's base type Fruit.

That would mean AppleSeed has two outer fields: a Fruit and an Apple.

Only one. Apple. And when AppleSeed.super seed this Apple, it sees a fruit. AppleSeed a; assert(is(typeof(a.outer) =3D=3D Apple)); assert(is(typeof(a.super) =3D=3D Seed)); assert(is(typeof(a.super.outer) =3D=3D Fruit)); //but: assert(a.outer is a.super.outer); If you can't figure out how can a.outer and a.super.outer have two different types, but be the same, think about covariant return.

--=20 Bye, Gor Gyolchanyan. --f46d0401730b2d351304c4bb000d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 11:18 PM, Christophe Tra= vert <span dir=3D"ltr">&lt;<a href=3D"mailto:travert phare.normalesup.org" = target=3D"_blank">travert phare.normalesup.org</a>&gt;</span> wrote:<br><bl= ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #= ccc solid;padding-left:1ex"> Andrei Alexandrescu , dans le message (digitalmars.D:172280), a =C3=A9crit= =C2=A0:<br> <div class=3D"im">&gt;&gt; For Fruit.Seed it&#39;s Fruit, for AppleSeed it&= #39;s Apple. This makes sense<br> &gt;&gt; because the Apple, which AppleSeed sees is the same object, which<= br> &gt;&gt; Fruit.Seed sees as it&#39;s base type Fruit.<br> &gt;<br> &gt; That would mean AppleSeed has two outer fields: a Fruit and an Apple.<= br> <br> </div>Only one. Apple. And when AppleSeed.super seed this Apple, it sees a<= br> fruit.<br> <br> AppleSeed a;<br> assert(is(typeof(a.outer) =3D=3D Apple));<br> assert(is(typeof(a.super) =3D=3D Seed));<br> assert(is(typeof(a.super.outer) =3D=3D Fruit));<br> //but:<br> assert(a.outer is a.super.outer);<br> <br> If you can&#39;t figure out how can a.outer and a.super.outer have two<br> different types, but be the same, think about covariant return.<br> <br> <br> </blockquote></div><br>Exactly!<br clear=3D"all"><div><br></div>-- <br>Bye,= <br>Gor Gyolchanyan.<br> --f46d0401730b2d351304c4bb000d--
Jul 13 2012
prev sibling next sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Friday, 13 July 2012 at 19:08:54 UTC, Gor Gyolchanyan wrote:

 If you make seed static, then Appleseed & apple will have 
 access to Fruit but seed (by itself) won't. Other combinations 
 faile as far as I can tell. How far you can take inner class 
 inheritance I don't know, but it seems not that many levels.

This all won't work, because having Fruit know about Apple defeats the whole purpose.

So why not...?? class Seed{} //same as static class in fruit class Apple { class Appleseed : Seed {} } Perhaps you would rather have Seed as an interface instead? It seems like I need a full detail of how everything connects together, so let's see.. Fruit covers apple (but maybe not seed) Apple covers (and is a class of) fruit, but also contains a seed (or the seed pertains to Apple specifically) All fruits (including apple's) have seeds that do specific things, namely plant, water and grow, and perhaps produceFruit. If that isn't right, explain how the relationship of it all goes and a possible solution may show itself.
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0401240b7bea4904c4bb2e7d
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 13, 2012 at 11:26 PM, Era Scarecrow <rtcvb32 yahoo.com> wrote:

 On Friday, 13 July 2012 at 19:08:54 UTC, Gor Gyolchanyan wrote:

  If you make seed static, then Appleseed & apple will have access to Fruit
 but seed (by itself) won't. Other combinations faile as far as I can tell.
 How far you can take inner class inheritance I don't know, but it seems not
 that many levels.

This all won't work, because having Fruit know about Apple defeats the whole purpose.

So why not...?? class Seed{} //same as static class in fruit class Apple { class Appleseed : Seed {} } Perhaps you would rather have Seed as an interface instead? It seems like I need a full detail of how everything connects together, so let's see.. Fruit covers apple (but maybe not seed) Apple covers (and is a class of) fruit, but also contains a seed (or the seed pertains to Apple specifically) All fruits (including apple's) have seeds that do specific things, namely plant, water and grow, and perhaps produceFruit. If that isn't right, explain how the relationship of it all goes and a possible solution may show itself.

The seed can't be an interface because it needs to contain state. For instance the progress towards becoming the respective fruit. The seed needs to be aware of the fruit it came from to access the fruit's DNA to inherit the traits of that fruit when it grows into a fruit of its own. (Please note, that it's just an example). A fruit can have multiple such seeds, each of which must have it's own state and connection to the same fruit they came from. So, we start off by inheriting from Fruit, defining the properties of that fruit (It's an Apple, it's delicious and it goes great in a pie). Then we define several different types of Apple seeds, each of which need access to the apple. -- Bye, Gor Gyolchanyan. --f46d0401240b7bea4904c4bb2e7d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 11:26 PM, Era Scarecrow = <span dir=3D"ltr">&lt;<a href=3D"mailto:rtcvb32 yahoo.com" target=3D"_blank= ">rtcvb32 yahoo.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quo= te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=

wrote:<br> <br> </div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"><div class=3D"im"><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> If you make seed static, then Appleseed &amp; apple will have access to Fru= it but seed (by itself) won&#39;t. Other combinations faile as far as I can= tell. How far you can take inner class inheritance I don&#39;t know, but i= t seems not that many levels.<br> </blockquote> <br></div><div class=3D"im"> This all won&#39;t work, because having Fruit know about Apple defeats the<= br> whole purpose.<br> </div></blockquote> <br> So why not...??<br> <br> class Seed{} //same as static class in fruit<div class=3D"im"><br> <br> class Apple {<br> =C2=A0 class Appleseed : Seed {}<br> }<br> <br></div> =C2=A0Perhaps you would rather have Seed as an interface instead? It seems = like I need a full detail of how everything connects together, so let&#39;s= see..<br> <br> =C2=A0Fruit covers apple (but maybe not seed)<br> =C2=A0Apple covers (and is a class of) fruit, but also contains a seed (or = the seed pertains to Apple specifically)<br> =C2=A0All fruits (including apple&#39;s) have seeds that do specific things= , namely plant, water and grow, and perhaps produceFruit.<br> <br> =C2=A0If that isn&#39;t right, explain how the relationship of it all goes = and a possible solution may show itself.<br> </blockquote></div><br>The seed can&#39;t be an interface because it needs = to contain state. For instance the progress towards becoming the respective= fruit.<div><br></div><div>The seed needs to be aware of the fruit it came = from to access the fruit&#39;s DNA to inherit the traits of that fruit when= it grows into a fruit of its own. (Please note, that it&#39;s just an exam= ple).</div> <div><br></div><div>A fruit can have multiple such seeds, each of which mus= t have it&#39;s own state and connection to the same fruit they came from.<= /div><div><br></div><div>So, we start off by inheriting from Fruit, definin= g the properties of that fruit (It&#39;s an Apple, it&#39;s delicious and i= t goes great in a pie). Then we define several different types of Apple see= ds, each of which need access to the apple.<br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> </div> --f46d0401240b7bea4904c4bb2e7d--
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--bcaec554deb2db86fd04c4bb339f
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 13, 2012 at 11:30 PM, Andrei Alexandrescu <
SeeWebsiteForEmail erdani.org> wrote:

 On 7/13/12 3:18 PM, Christophe Travert wrote:

 Andrei Alexandrescu , dans le message (digitalmars.D:172280), a =C3=A9cr=


 For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
 because the Apple, which AppleSeed sees is the same object, which
 Fruit.Seed sees as it's base type Fruit.

That would mean AppleSeed has two outer fields: a Fruit and an Apple.

Only one. Apple. And when AppleSeed.super seed this Apple, it sees a fruit. AppleSeed a; assert(is(typeof(a.outer) =3D=3D Apple)); assert(is(typeof(a.super) =3D=3D Seed)); assert(is(typeof(a.super.**outer) =3D=3D Fruit)); //but: assert(a.outer is a.super.outer); If you can't figure out how can a.outer and a.super.outer have two different types, but be the same, think about covariant return.

Makes sense, thanks. Andrei

sense? It's not even a new feature. It's a (possibly) new (and apparently sensible) use case of an existing feature. I came up with this when I was trying to work around the limitation of not having multiple inheritance. --=20 Bye, Gor Gyolchanyan. --bcaec554deb2db86fd04c4bb339f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 11:30 PM, Andrei Alexand= rescu <span dir=3D"ltr">&lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org= " target=3D"_blank">SeeWebsiteForEmail erdani.org</a>&gt;</span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On 7/13/12 3:18 PM, Christophe Trav= ert wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Andrei Alexandrescu , dans le message (digitalmars.D:172280), a =C3=A9crit = :<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><blockquote class=3D"gmail_quote" style=3D"m= argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> For Fruit.Seed it&#39;s Fruit, for AppleSeed it&#39;s Apple. This makes sen= se<br> because the Apple, which AppleSeed sees is the same object, which<br> Fruit.Seed sees as it&#39;s base type Fruit.<br> </blockquote> <br> That would mean AppleSeed has two outer fields: a Fruit and an Apple.<br> </blockquote> <br> Only one. Apple. And when AppleSeed.super seed this Apple, it sees a<br> fruit.<br> <br> AppleSeed a;<br> assert(is(typeof(a.outer) =3D=3D Apple));<br> assert(is(typeof(a.super) =3D=3D Seed));<br> assert(is(typeof(a.super.<u></u>outer) =3D=3D Fruit));<br> //but:<br> assert(a.outer is a.super.outer);<br> <br> If you can&#39;t figure out how can a.outer and a.super.outer have two<br> different types, but be the same, think about covariant return.<br> </blockquote> <br></div></div> Makes sense, thanks.<span class=3D"HOEnZb"><font color=3D"#888888"><br> <br> Andrei<br> <br> </font></span></blockquote></div><br>The initial question was: why does DMD= 2.059 reject this if this makes sense?=C2=A0<div>It&#39;s not even a new f= eature. It&#39;s a (possibly) new (and apparently sensible) use case of an = existing feature.</div> <div><br></div><div>I came up with this when I was trying to work around th= e limitation of not having multiple inheritance.<br clear=3D"all"><div><br>= </div>-- <br>Bye,<br>Gor Gyolchanyan.<br> </div> --bcaec554deb2db86fd04c4bb339f--
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d04088ee5a90b2604c4bb61aa
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexandrescu <
SeeWebsiteForEmail erdani.org> wrote:

 On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:

 The initial question was: why does DMD 2.059 reject this if this makes
 sense?
 It's not even a new feature. It's a (possibly) new (and apparently
 sensible) use case of an existing feature.

I think the simple answer is there was no provision for it. The feature copies the Java feature, and I don't think Java has something like what you defined. Andrei

Except for translating Java code. If I had multiple inheritance, I'd just make the Apple as base class and have all the seeds virtually derive from it. Not having multiple inheritance drove me to try the next best think. And after it failed, I complained about it. And here we are. Is it a difficult thing to fix? -- Bye, Gor Gyolchanyan. --f46d04088ee5a90b2604c4bb61aa Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexand= rescu <span dir=3D"ltr">&lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org= " target=3D"_blank">SeeWebsiteForEmail erdani.org</a>&gt;</span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> <div class=3D"im">On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> The initial question was: why does DMD 2.059 reject this if this makes<br> sense?<br> It&#39;s not even a new feature. It&#39;s a (possibly) new (and apparently<= br> sensible) use case of an existing feature.<br> </blockquote> <br></div> I think the simple answer is there was no provision for it. The feature cop= ies the Java feature, and I don&#39;t think Java has something like what yo= u defined.<span class=3D"HOEnZb"><font color=3D"#888888"><br> <br> Andrei<br> <br> </font></span></blockquote></div><br>Well, the nested classes are pretty mu= ch useless without this feature. Except for translating Java code. If I had= multiple inheritance, I&#39;d just make the Apple as base class and have a= ll the seeds virtually derive from it. Not having multiple inheritance drov= e me to try the next best think. And after it failed, I complained about it= . And here we are. Is it a difficult thing to fix?<br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --f46d04088ee5a90b2604c4bb61aa--
Jul 13 2012
prev sibling next sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Friday, 13 July 2012 at 19:35:34 UTC, Gor Gyolchanyan wrote:
 The seed can't be an interface because it needs to contain 
 state. For instance the progress towards becoming the 
 respective fruit.

The interface itself may not have state, but what uses the interface can have state. So i don't see an issue. Worse case you can use an abstract class which is a partial definition. interface Counter { void addOne(); int getCount(); } //A contains state and is both A and Counter. class A : Counter { int x; void addOne() {x++;} void getCount() {return x;} }
 The seed needs to be aware of the fruit it came from to access 
 the fruit's DNA to inherit the traits of that fruit when it 
 grows into a fruit of its own. (Please note, that it's just an 
 example).

 A fruit can have multiple such seeds, each of which must have 
 it's own state and connection to the same fruit they came from.

so far... class Fruit { class Seed { class Apple {} } }
 So, we start off by inheriting from Fruit, defining the 
 properties of that fruit (It's an Apple, it's delicious and it 
 goes great in a pie). Then we define several different types of 
 Apple seeds, each of which need access to the apple.

Hmmm... interface Seed {} class Fruit { class Appleseed : Seed { class Apple {} } //or? static class Apple { class AppleSeed : Seed {} //multiple seeds, but need Fruit access? } } or perhaps...? interface Seed{} interface Fruit{} //Apple knows it's a fruit.. class Apple : Fruit { //Appleseed is from the Apple (which is a fruit as well) //Appleseed is a seed, we can have multiple seeds from Apple, all which know //all about Apple's (and basic fruits) but not about non-appple seeds. class Appleseed : Seed { } }
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--bcaec554deb2aa447a04c4bb9690
Content-Type: text/plain; charset=UTF-8

On Fri, Jul 13, 2012 at 11:59 PM, Era Scarecrow <rtcvb32 yahoo.com> wrote:

 On Friday, 13 July 2012 at 19:35:34 UTC, Gor Gyolchanyan wrote:

 The seed can't be an interface because it needs to contain state. For
 instance the progress towards becoming the respective fruit.

The interface itself may not have state, but what uses the interface can have state. So i don't see an issue. Worse case you can use an abstract class which is a partial definition. interface Counter { void addOne(); int getCount(); } //A contains state and is both A and Counter. class A : Counter { int x; void addOne() {x++;} void getCount() {return x;} } The seed needs to be aware of the fruit it came from to access the
 fruit's DNA to inherit the traits of that fruit when it grows into a fruit
 of its own. (Please note, that it's just an example).

A fruit can have multiple such seeds, each of which must have it's own
 state and connection to the same fruit they came from.

so far... class Fruit { class Seed { class Apple {} } }
 So, we start off by inheriting from Fruit, defining the properties of
 that fruit (It's an Apple, it's delicious and it goes great in a pie). Then
 we define several different types of Apple seeds, each of which need access
 to the apple.

Hmmm... interface Seed {} class Fruit { class Appleseed : Seed { class Apple {} } //or? static class Apple { class AppleSeed : Seed {} //multiple seeds, but need Fruit access? } } or perhaps...? interface Seed{} interface Fruit{} //Apple knows it's a fruit.. class Apple : Fruit { //Appleseed is from the Apple (which is a fruit as well) //Appleseed is a seed, we can have multiple seeds from Apple, all which know //all about Apple's (and basic fruits) but not about non-appple seeds. class Appleseed : Seed { } }

The seed itself must have private state, or else it would violate encapsulation and require nasty mixins. And as I said, fruit can't know about apple. -- Bye, Gor Gyolchanyan. --bcaec554deb2aa447a04c4bb9690 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div>On Fri, Jul 13, 2012 at 11:59 PM, Era Scarecrow <span dir=3D"ltr">&lt;= <a href=3D"mailto:rtcvb32 yahoo.com" target=3D"_blank">rtcvb32 yahoo.com</a=
&gt;</span> wrote:</div><div class=3D"gmail_quote"><blockquote class=3D"gm=

ft:1ex"> <div class=3D"im">On Friday, 13 July 2012 at 19:35:34 UTC, Gor Gyolchanyan = wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> <br> The seed can&#39;t be an interface because it needs to contain state. For i= nstance the progress towards becoming the respective fruit.<br> </blockquote> <br></div> =C2=A0The interface itself may not have state, but what uses the interface = can have state. So i don&#39;t see an issue. Worse case you can use an abst= ract class which is a partial definition.<br> <br> interface Counter {<br> =C2=A0 void addOne();<br> =C2=A0 int getCount();<br> }<br> <br> //A contains state and is both A and Counter.<br> class A : Counter {<br> =C2=A0 int x;<br> =C2=A0 void addOne() {x++;}<br> =C2=A0 void getCount() {return x;}<div class=3D"im"><br> }<br> <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> The seed needs to be aware of the fruit it came from to access the fruit&#3= 9;s DNA to inherit the traits of that fruit when it grows into a fruit of i= ts own. (Please note, that it&#39;s just an example).<br> </blockquote> <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> A fruit can have multiple such seeds, each of which must have it&#39;s own = state and connection to the same fruit they came from.<br> </blockquote> <br></div> so far...<div class=3D"im"><br> class Fruit {<br> =C2=A0class Seed {<br> =C2=A0 class Apple {}<br> =C2=A0}<br> }<br> <br> </div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"> <br><div class=3D"im"> So, we start off by inheriting from Fruit, defining the properties of that = fruit (It&#39;s an Apple, it&#39;s delicious and it goes great in a pie). T= hen we define several different types of Apple seeds, each of which need ac= cess to the apple.<br> </div></blockquote> <br> Hmmm...<br> interface Seed {}<br> <br> class Fruit {<br> =C2=A0 class Appleseed : Seed {<br> =C2=A0 =C2=A0 class Apple {}<br> =C2=A0 }<br> <br> =C2=A0 //or?<br> =C2=A0 static class Apple {<br> =C2=A0 =C2=A0 class AppleSeed : Seed {} //multiple seeds, but need Fruit ac= cess?<br> =C2=A0 }<br> }<br> <br> or perhaps...?<br> <br> interface Seed{}<br> interface Fruit{}<br> <br> //Apple knows it&#39;s a fruit..<br> class Apple : Fruit {<br> =C2=A0 //Appleseed is from the Apple (which is a fruit as well)<br> =C2=A0 //Appleseed is a seed, we can have multiple seeds from Apple, all wh= ich know<br> =C2=A0 //all about Apple&#39;s (and basic fruits) but not about non-appple = seeds.<br> =C2=A0 class Appleseed : Seed {<br> =C2=A0 }<br> }<br> </blockquote></div><br>The seed itself must have private state, or else it = would violate encapsulation and require nasty mixins.<br clear=3D"all"><div=
And as I said, fruit can&#39;t know about apple.</div><div><br></div>-- <b=

Bye,<br>Gor Gyolchanyan.<br> --bcaec554deb2aa447a04c4bb9690--
Jul 13 2012
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Fri, 13 Jul 2012 13:59:54 -0400, Gor Gyolchanyan  
<gor.f.gyolchanyan gmail.com> wrote:

 Doesn't this make sense?

 class Fruit
 {
     class Seed { }
 }

 class Apple: Fruit
 {
      class AppleSeed: Fruit.Seed { }
 }

 This means, that as Fruit.Seed needs access to enclosing Fruit,  
 AppleSeed,
 being a Fruit.Seed will also have access to enclosing Fruit, which is  
 Apple.
 DMD 0.259 has this to say:

 Error: class main.Apple.AppleSeed is nested within Apple, but super class
 Seed is nested within Fruit

 Which doesn't make sense, IMO. What do you guys think about this? Who  
 makes
 more sense me or DMD 2.059?

This is what you are asking for: class A {} class B : A {} class C { A member; } class D : C { override B member; } You can mimic it via: class C { protected A _member; property inout(A) member() inout { return _member; } } class C : B { override property inout(B) member() inout { return cast(inout(B))_member; } } I have had many times where I had to do this workaround (with casting), or store extra references, but it would be nice to have this simply work depending on the type. I don't think anyone considered doing this with outer, it certainly would be a valid feature. I'd like to have the general feature as well. Covariant fields... -Steve
Jul 13 2012
prev sibling next sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Friday, 13 July 2012 at 20:04:43 UTC, Gor Gyolchanyan wrote:
 On Fri, Jul 13, 2012 at 11:59 PM, Era Scarecrow
 or perhaps...?

 interface Seed{}
 interface Fruit{}

 //Apple knows it's a fruit..
 class Apple : Fruit {
   //Appleseed is from the Apple (which is a fruit as well)
   //Appleseed is a seed, we can have multiple seeds from 
 Apple, all which
 know
   //all about Apple's (and basic fruits) but not about 
 non-appple seeds.
   class Appleseed : Seed {
   }
 }

The seed itself must have private state, or else it would violate encapsulation and require nasty mixins. And as I said, fruit can't know about apple.

Fruit doesn't know about apples in this last case, only that an apple IS a fruit (And can do anything a fruit can do). And the seed CAN have a private state, only part of the interface (from interface Seed) is exposed. So I do not see a problem. interface Seed { void func(); } class Appleseed : Seed { int x; //private state void func() {x++;} } Appleseed a = new Appleseed(); Seed s = cast(Seed) a; //appleseed a.func(); a.x = 5; //seed s.func(); //known and callable s.x = 10; //error, x isn't defined or known in seed. How is this not private state?
Jul 13 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--047d7b603bfad9952d04c4c4482a
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 12:31 AM, Andrei Alexandrescu <
SeeWebsiteForEmail erdani.org> wrote:

 On 7/13/12 3:49 PM, Gor Gyolchanyan wrote:

 On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org
<mailto:SeeWebsiteForEmail **erdani.org<SeeWebsiteForEmail erdani.org>


wrote: On 7/13/12 3:36 PM, Gor Gyolchanyan wrote: The initial question was: why does DMD 2.059 reject this if this makes sense? It's not even a new feature. It's a (possibly) new (and apparently sensible) use case of an existing feature. I think the simple answer is there was no provision for it. The feature copies the Java feature, and I don't think Java has something like what you defined. Andrei Well, the nested classes are pretty much useless without this feature. Except for translating Java code. If I had multiple inheritance, I'd just make the Apple as base class and have all the seeds virtually derive from it. Not having multiple inheritance drove me to try the next best think. And after it failed, I complained about it.. And here we are. Is it a difficult thing to fix?

I don't know, you may want to submit an enhancement request. Andrei

Anyone who thinks this is important, please vote up. -- Bye, Gor Gyolchanyan. --047d7b603bfad9952d04c4c4482a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 12:31 AM, Andrei Alexand= rescu <span dir=3D"ltr">&lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org= " target=3D"_blank">SeeWebsiteForEmail erdani.org</a>&gt;</span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On 7/13/12 3:49 PM, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexandrescu<br> &lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org" target=3D"_blank">SeeW= ebsiteForEmail erdani.org</a> &lt;mailto:<a href=3D"mailto:SeeWebsiteForEma= il erdani.org" target=3D"_blank">SeeWebsiteForEmail <u></u>erdani.org</a>&g= t;&gt;<div> <div class=3D"h5"><br> wrote:<br> <br> =C2=A0 =C2=A0 On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 The initial question was: why does DMD 2.059 re= ject this if this<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 makes<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 sense?<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 It&#39;s not even a new feature. It&#39;s a (po= ssibly) new (and apparently<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 sensible) use case of an existing feature.<br> <br> <br> =C2=A0 =C2=A0 I think the simple answer is there was no provision for it. T= he<br> =C2=A0 =C2=A0 feature copies the Java feature, and I don&#39;t think Java h= as<br> =C2=A0 =C2=A0 something like what you defined.<br> <br> =C2=A0 =C2=A0 Andrei<br> <br> <br></div></div><div class=3D"im"> Well, the nested classes are pretty much useless without this feature.<br> Except for translating Java code. If I had multiple inheritance, I&#39;d<br=

derive from it. Not having multiple inheritance drove me to try the next<br=
</div>

ass=3D"im"><br> are. Is it a difficult thing to fix?<br> </div></blockquote> <br> I don&#39;t know, you may want to submit an enhancement request.<span class= =3D"HOEnZb"><font color=3D"#888888"><br> <br> Andrei<br> <br> </font></span></blockquote></div><br><a href=3D"http://d.puremagic.com/issu= es/show_bug.cgi?id=3D8389">http://d.puremagic.com/issues/show_bug.cgi?id=3D= 8389</a>=C2=A0<div><br></div><div>Anyone who thinks this is important, plea= se vote up.<br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> </div> --047d7b603bfad9952d04c4c4482a--
Jul 13 2012
prev sibling next sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan wrote:
 Which doesn't make sense, IMO. What do you guys think about 
 this? Who makes
 more sense me or DMD 2.059?

http://d.puremagic.com/issues/show_bug.cgi?id=1175 https://github.com/D-Programming-Language/dmd/pull/889
Jul 14 2012
parent Guillaume Chatelet <chatelet.guillaume gmail.com> writes:
On 07/14/12 11:41, Vladimir Panteleev wrote:
 On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan wrote:
 Which doesn't make sense, IMO. What do you guys think about this? Who
 makes
 more sense me or DMD 2.059?

http://d.puremagic.com/issues/show_bug.cgi?id=1175 https://github.com/D-Programming-Language/dmd/pull/889

So I marked 8389 as a duplicate of 1175 and closed the issue ( as 1175 has been resolved too) I hope you don't mind Gor. Feel free to reopen if needed. Guillaume
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d04016d5d227ce704c4c70fc2
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 1:36 PM, Guillaume Chatelet <
chatelet.guillaume gmail.com> wrote:

 On 07/13/12 21:41, Andrei Alexandrescu wrote:
 On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:
 The initial question was: why does DMD 2.059 reject this if this makes
 sense?
 It's not even a new feature. It's a (possibly) new (and apparently
 sensible) use case of an existing feature.

I think the simple answer is there was no provision for it. The feature copies the Java feature, and I don't think Java has something like what you defined. Andrei

class Fruit { class Seed { } } class Apple extends Fruit { class AppleSeed extends Fruit.Seed { Apple getOuter() { return Apple.this; } } } class Main { public static void main(String[] args) { final Apple apple = new Apple(); final Apple.AppleSeed appleSeed = apple.new AppleSeed(); assert (appleSeed instanceof Fruit.Seed); assert (apple == appleSeed.getOuter()); assert (appleSeed.getOuter() instanceof Apple); assert (appleSeed.getOuter() instanceof Fruit); } } This is valid Java code actually and I agree with Gor I would have expected it to work with D. Guillaume

I didn't even know this worked in Java. This means, that nested classed in D can't translate nested classed in Java after all. -- Bye, Gor Gyolchanyan. --f46d04016d5d227ce704c4c70fc2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 1:36 PM, Guillaume Chate= let <span dir=3D"ltr">&lt;<a href=3D"mailto:chatelet.guillaume gmail.com" t= arget=3D"_blank">chatelet.guillaume gmail.com</a>&gt;</span> wrote:<br><blo= ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c= cc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On 07/13/12 21:41, Andrei Alexandre= scu wrote:<br> &gt; On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:<br> &gt;&gt; The initial question was: why does DMD 2.059 reject this if this m= akes<br> &gt;&gt; sense?<br> &gt;&gt; It&#39;s not even a new feature. It&#39;s a (possibly) new (and ap= parently<br> &gt;&gt; sensible) use case of an existing feature.<br> &gt;<br> &gt; I think the simple answer is there was no provision for it. The featur= e<br> &gt; copies the Java feature, and I don&#39;t think Java has something like= what<br> &gt; you defined.<br> &gt;<br> &gt; Andrei<br> &gt;<br> <br> </div></div>class Fruit {<br> =C2=A0 =C2=A0 class Seed {<br> =C2=A0 =C2=A0 }<br> }<br> <br> class Apple extends Fruit {<br> =C2=A0 =C2=A0 class AppleSeed extends Fruit.Seed {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Apple getOuter() {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return Apple.this;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> =C2=A0 =C2=A0 }<br> }<br> <br> class Main {<br> =C2=A0 =C2=A0 public static void main(String[] args) {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 final Apple apple =3D new Apple();<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 final Apple.AppleSeed appleSeed =3D apple.new A= ppleSeed();<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert (appleSeed instanceof Fruit.Seed);<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert (apple =3D=3D appleSeed.getOuter());<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert (appleSeed.getOuter() instanceof Apple);= <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert (appleSeed.getOuter() instanceof Fruit);= <br> =C2=A0 =C2=A0 }<br> }<br> <br> This is valid Java code actually and I agree with Gor I would have<br> expected it to work with D.<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> Guillaume<br> </font></span></blockquote></div><br>I didn&#39;t even know this worked in = Java. This means, that nested classed in D can&#39;t translate nested class= ed in Java after all.<br clear=3D"all"><div><br></div>-- <br>Bye,<br>Gor Gy= olchanyan.<br> --f46d04016d5d227ce704c4c70fc2--
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0401240bc1f7ea04c4c715c0
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 1:41 PM, Vladimir Panteleev <
vladimir thecybershadow.net> wrote:

 On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan wrote:

 Which doesn't make sense, IMO. What do you guys think about this? Who
 makes
 more sense me or DMD 2.059?

http://d.puremagic.com/issues/**show_bug.cgi?id=1175<http://d.puremagic.com/issues/show_bug.cgi?id=1175> https://github.com/D-**Programming-Language/dmd/pull/**889<https://github.com/D-Programming-Language/dmd/pull/889>

-- Bye, Gor Gyolchanyan. --f46d0401240bc1f7ea04c4c715c0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 1:41 PM, Vladimir Pantel= eev <span dir=3D"ltr">&lt;<a href=3D"mailto:vladimir thecybershadow.net" ta= rget=3D"_blank">vladimir thecybershadow.net</a>&gt;</span> wrote:<br><block= quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc= solid;padding-left:1ex"> <div class=3D"im">On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan = wrote:<br> </div><div class=3D"im"><blockquote class=3D"gmail_quote" style=3D"margin:0= 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Which doesn&#39;t make sense, IMO. What do you guys think about this? Who m= akes<br> more sense me or DMD 2.059?<br> </blockquote> <br> </div><a href=3D"http://d.puremagic.com/issues/show_bug.cgi?id=3D1175" targ= et=3D"_blank">http://d.puremagic.com/issues/<u></u>show_bug.cgi?id=3D1175</= a><br> <a href=3D"https://github.com/D-Programming-Language/dmd/pull/889" target= =3D"_blank">https://github.com/D-<u></u>Programming-Language/dmd/pull/<u></= u>889</a><br> <br> </blockquote></div><br>I see it&#39;s already merged. I presume this will e= nd up in DMD 2.060, right?<br clear=3D"all"><div><br></div>-- <br>Bye,<br>G= or Gyolchanyan.<br> --f46d0401240bc1f7ea04c4c715c0--
Jul 14 2012
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Saturday, July 14, 2012 13:47:29 Gor Gyolchanyan wrote:
 I see it's already merged. I presume this will end up in DMD 2.060, right?

Anything and everything which has already been merged on github will end up in the next release of dmd unless it's reverted or altered by another commit prior to the next release. We don't currently maintain any branches as part of the development process. - Jonathan M Davis
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0435c1d257c05a04c4c7433e
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 1:56 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote:

 On Saturday, July 14, 2012 13:47:29 Gor Gyolchanyan wrote:
 I see it's already merged. I presume this will end up in DMD 2.060,

Anything and everything which has already been merged on github will end up in the next release of dmd unless it's reverted or altered by another commit prior to the next release. We don't currently maintain any branches as part of the development process. - Jonathan M Davis

That's great. That means, I don't have to work around it and I can just wait a bit until DMD 2.060 comes out. Btw, when will it happen? -- Bye, Gor Gyolchanyan. --f46d0435c1d257c05a04c4c7433e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 1:56 PM, Jonathan M Davi= s <span dir=3D"ltr">&lt;<a href=3D"mailto:jmdavisProg gmx.com" target=3D"_b= lank">jmdavisProg gmx.com</a>&gt;</span> wrote:<br><blockquote class=3D"gma= il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef= t:1ex"> <div class=3D"im">On Saturday, July 14, 2012 13:47:29 Gor Gyolchanyan wrote= :<br> &gt; I see it&#39;s already merged. I presume this will end up in DMD 2.060= , right?<br> <br> </div>Anything and everything which has already been merged on github will = end up in<br> the next release of dmd unless it&#39;s reverted or altered by another comm= it<br> prior to the next release. We don&#39;t currently maintain any branches as = part of<br> the development process.<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> - Jonathan M Davis<br> </font></span></blockquote></div><br>That&#39;s great. That means, I don&#3= 9;t have to work around it and I can just wait a bit until DMD 2.060 comes = out. Btw, when will it happen?<br clear=3D"all"><div><br></div>-- <br>Bye,<= br> Gor Gyolchanyan.<br> --f46d0435c1d257c05a04c4c7433e--
Jul 14 2012
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Saturday, July 14, 2012 14:00:14 Gor Gyolchanyan wrote:
 That's great. That means, I don't have to work around it and I can just
 wait a bit until DMD 2.060 comes out. Btw, when will it happen?

No idea. Normally, releases have been happening every 2 months or so, but we're at just passed 3 months since the last one now. It pretty much depends on when Walter decides to do a beta. He made noise about that over a month ago but didn't end up doing it (I think that he went on vacation shortly after that), and he hasn't said anything about it since. We should probably do one soon though. - Jonathan M Davis
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0408da07b13bdf04c4c78d62
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 2:04 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote:

 On Saturday, July 14, 2012 14:00:14 Gor Gyolchanyan wrote:
 That's great. That means, I don't have to work around it and I can just
 wait a bit until DMD 2.060 comes out. Btw, when will it happen?

No idea. Normally, releases have been happening every 2 months or so, but we're at just passed 3 months since the last one now. It pretty much depends on when Walter decides to do a beta. He made noise about that over a month ago but didn't end up doing it (I think that he went on vacation shortly after that), and he hasn't said anything about it since. We should probably do one soon though. - Jonathan M Davis

I see. Is it possible to get the change log for the upcoming release? That would also show us what we shouldn't work around. -- Bye, Gor Gyolchanyan. --f46d0408da07b13bdf04c4c78d62 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 2:04 PM, Jonathan M Davi= s <span dir=3D"ltr">&lt;<a href=3D"mailto:jmdavisProg gmx.com" target=3D"_b= lank">jmdavisProg gmx.com</a>&gt;</span> wrote:<br><blockquote class=3D"gma= il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef= t:1ex"> <div class=3D"im">On Saturday, July 14, 2012 14:00:14 Gor Gyolchanyan wrote= :<br> &gt; That&#39;s great. That means, I don&#39;t have to work around it and I= can just<br> &gt; wait a bit until DMD 2.060 comes out. Btw, when will it happen?<br> <br> </div>No idea. Normally, releases have been happening every 2 months or so,= but<br> we&#39;re at just passed 3 months since the last one now. It pretty much de= pends<br> on when Walter decides to do a beta. He made noise about that over a month = ago<br> but didn&#39;t end up doing it (I think that he went on vacation shortly af= ter<br> that), and he hasn&#39;t said anything about it since. We should probably d= o one<br> soon though.<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> - Jonathan M Davis<br> </font></span></blockquote></div><br>I see. Is it possible to get the chang= e log for the upcoming release? That would also show us what we shouldn&#39= ;t work around.<br clear=3D"all"><div><br></div>-- <br>Bye,<br>Gor Gyolchan= yan.<br> --f46d0408da07b13bdf04c4c78d62--
Jul 14 2012
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Saturday, July 14, 2012 14:21:01 Gor Gyolchanyan wrote:
 On Sat, Jul 14, 2012 at 2:04 PM, Jonathan M Davis 

 On Saturday, July 14, 2012 14:00:14 Gor Gyolchanyan wrote:
 That's great. That means, I don't have to work around it and I can just
 wait a bit until DMD 2.060 comes out. Btw, when will it happen?

No idea. Normally, releases have been happening every 2 months or so, but we're at just passed 3 months since the last one now. It pretty much depends on when Walter decides to do a beta. He made noise about that over a month ago but didn't end up doing it (I think that he went on vacation shortly after that), and he hasn't said anything about it since. We should probably do one soon though. - Jonathan M Davis

I see. Is it possible to get the change log for the upcoming release? That would also show us what we shouldn't work around.

Yes and no. If you look in each repository, there's a partial changelog for each (changelog.dd), but odds are that they're missing a number of items, and actually, for some reason, dmd's hasn't been updated in a year, so I have no clue how Walter puts together dmd's portion of the changelog. Andrei recently brought up the idea of automatically generating the bug fix list for the changelog with a query to bugzilla, which would make sure that everything made it into the changelog (right now, it depends on the devs making sure that they manually add it all, and stuff gets missed). I believe that this query will list every bug that has been fixed since 2.059: http://d.puremagic.com/issues/buglist.cgi?bug_status=RESOLVED&chfieldto=Now&chfield=bug_status&query_format=advanced&chfieldfrom=2012-04-12&resolution=FIXED which as you can see is far from being short. - Jonathan M Davis
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0401730b78d75904c4c7d801
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 2:35 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote:

 On Saturday, July 14, 2012 14:21:01 Gor Gyolchanyan wrote:
 On Sat, Jul 14, 2012 at 2:04 PM, Jonathan M Davis

 On Saturday, July 14, 2012 14:00:14 Gor Gyolchanyan wrote:
 That's great. That means, I don't have to work around it and I can



 wait a bit until DMD 2.060 comes out. Btw, when will it happen?

No idea. Normally, releases have been happening every 2 months or so,


 we're at just passed 3 months since the last one now. It pretty much
 depends
 on when Walter decides to do a beta. He made noise about that over a


 ago
 but didn't end up doing it (I think that he went on vacation shortly


 that), and he hasn't said anything about it since. We should probably


 one
 soon though.

 - Jonathan M Davis

I see. Is it possible to get the change log for the upcoming release?

 would also show us what we shouldn't work around.

Yes and no. If you look in each repository, there's a partial changelog for each (changelog.dd), but odds are that they're missing a number of items, and actually, for some reason, dmd's hasn't been updated in a year, so I have no clue how Walter puts together dmd's portion of the changelog. Andrei recently brought up the idea of automatically generating the bug fix list for the changelog with a query to bugzilla, which would make sure that everything made it into the changelog (right now, it depends on the devs making sure that they manually add it all, and stuff gets missed). I believe that this query will list every bug that has been fixed since 2.059: http://d.puremagic.com/issues/buglist.cgi?bug_status=RESOLVED&chfieldto=Now&chfield=bug_status&query_format=advanced&chfieldfrom=2012-04-12&resolution=FIXED which as you can see is far from being short. - Jonathan M Davis

Auto-generating a change log is a great idea. I think it would be great to generate the change log for all previous versions as well and diff it with the existing change log to see the changes that didn't show up in the change log. -- Bye, Gor Gyolchanyan. --f46d0401730b78d75904c4c7d801 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 2:35 PM, Jonathan M Davi= s <span dir=3D"ltr">&lt;<a href=3D"mailto:jmdavisProg gmx.com" target=3D"_b= lank">jmdavisProg gmx.com</a>&gt;</span> wrote:<br><blockquote class=3D"gma= il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef= t:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On Saturday, July 14, 2012 14:21:01= Gor Gyolchanyan wrote:<br> &gt; On Sat, Jul 14, 2012 at 2:04 PM, Jonathan M Davis<br> &lt;<a href=3D"mailto:jmdavisProg gmx.com">jmdavisProg gmx.com</a>&gt;wrote= :<br> &gt; &gt; On Saturday, July 14, 2012 14:00:14 Gor Gyolchanyan wrote:<br> &gt; &gt; &gt; That&#39;s great. That means, I don&#39;t have to work aroun= d it and I can just<br> &gt; &gt; &gt; wait a bit until DMD 2.060 comes out. Btw, when will it happ= en?<br> &gt; &gt;<br> &gt; &gt; No idea. Normally, releases have been happening every 2 months or= so, but<br> &gt; &gt; we&#39;re at just passed 3 months since the last one now. It pret= ty much<br> &gt; &gt; depends<br> &gt; &gt; on when Walter decides to do a beta. He made noise about that ove= r a month<br> &gt; &gt; ago<br> &gt; &gt; but didn&#39;t end up doing it (I think that he went on vacation = shortly after<br> &gt; &gt; that), and he hasn&#39;t said anything about it since. We should = probably do<br> &gt; &gt; one<br> &gt; &gt; soon though.<br> &gt; &gt;<br> &gt; &gt; - Jonathan M Davis<br> &gt;<br> &gt; I see. Is it possible to get the change log for the upcoming release? = That<br> &gt; would also show us what we shouldn&#39;t work around.<br> <br> </div></div>Yes and no. If you look in each repository, there&#39;s a parti= al changelog for<br> each (changelog.dd), but odds are that they&#39;re missing a number of item= s, and<br> actually, for some reason, dmd&#39;s hasn&#39;t been updated in a year, so = I have no<br> clue how Walter puts together dmd&#39;s portion of the changelog.<br> <br> Andrei recently brought up the idea of automatically generating the bug fix= <br> list for the changelog with a query to bugzilla, which would make sure that= <br> everything made it into the changelog (right now, it depends on the devs<br=

e<br> that this query will list every bug that has been fixed since 2.059:<br> <br> <a href=3D"http://d.puremagic.com/issues/buglist.cgi?bug_status=3DRESOLVED&= amp;chfieldto=3DNow&amp;chfield=3Dbug_status&amp;query_format=3Dadvanced&am= p;chfieldfrom=3D2012-04-12&amp;resolution=3DFIXED" target=3D"_blank">http:/= /d.puremagic.com/issues/buglist.cgi?bug_status=3DRESOLVED&amp;chfieldto=3DN= ow&amp;chfield=3Dbug_status&amp;query_format=3Dadvanced&amp;chfieldfrom=3D2= 012-04-12&amp;resolution=3DFIXED</a><br> <br> which as you can see is far from being short.<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> - Jonathan M Davis<br> </font></span></blockquote></div><br>Auto-generating a change log is a grea= t idea. I think it would be great to generate the change log for all previo= us versions as well and diff it with the existing change log to see the cha= nges that didn&#39;t show up in the change log.<br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --f46d0401730b78d75904c4c7d801--
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--bcaec554deb209b6fb04c4c9bded
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 4:17 PM, Guillaume Chatelet <
chatelet.guillaume gmail.com> wrote:

 On 07/14/12 11:41, Vladimir Panteleev wrote:
 On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan wrote:
 Which doesn't make sense, IMO. What do you guys think about this? Who
 makes
 more sense me or DMD 2.059?

http://d.puremagic.com/issues/show_bug.cgi?id=1175 https://github.com/D-Programming-Language/dmd/pull/889

So I marked 8389 as a duplicate of 1175 and closed the issue ( as 1175 has been resolved too) I hope you don't mind Gor. Feel free to reopen if needed. Guillaume

Sure, it's fine. :-) As long as the damn thing works. :-D -- Bye, Gor Gyolchanyan. --bcaec554deb209b6fb04c4c9bded Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 4:17 PM, Guillaume Chate= let <span dir=3D"ltr">&lt;<a href=3D"mailto:chatelet.guillaume gmail.com" t= arget=3D"_blank">chatelet.guillaume gmail.com</a>&gt;</span> wrote:<br><blo= ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c= cc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On 07/14/12 11:41, Vladimir Pantele= ev wrote:<br> &gt; On Friday, 13 July 2012 at 18:00:05 UTC, Gor Gyolchanyan wrote:<br> &gt;&gt; Which doesn&#39;t make sense, IMO. What do you guys think about th= is? Who<br> &gt;&gt; makes<br> &gt;&gt; more sense me or DMD 2.059?<br> &gt;<br> &gt; <a href=3D"http://d.puremagic.com/issues/show_bug.cgi?id=3D1175" targe= t=3D"_blank">http://d.puremagic.com/issues/show_bug.cgi?id=3D1175</a><br> &gt; <a href=3D"https://github.com/D-Programming-Language/dmd/pull/889" tar= get=3D"_blank">https://github.com/D-Programming-Language/dmd/pull/889</a><b= r> &gt;<br> <br> </div></div>So I marked 8389 as a duplicate of 1175 and closed the issue ( = as 1175<br> has been resolved too)<br> I hope you don&#39;t mind Gor. Feel free to reopen if needed.<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> Guillaume<br> </font></span></blockquote></div><br>Sure, it&#39;s fine. :-) As long as th= e damn thing works. :-D<div><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<= br> </div> --bcaec554deb209b6fb04c4c9bded--
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--bcaec554d8426fd12404c4cd0501
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 8:17 PM, deadalnix <deadalnix gmail.com> wrote:

 On 14/07/2012 08:27, Gor Gyolchanyan wrote:

 On Sat, Jul 14, 2012 at 12:31 AM, Andrei Alexandrescu

 <SeeWebsiteForEmail erdani.org
<mailto:SeeWebsiteForEmail **erdani.org<SeeWebsiteForEmail erdani.org>


On 7/13/12 3:49 PM, Gor Gyolchanyan wrote: On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org <mailto:SeeWebsiteForEmail **erdani.org<SeeWebsiteForEmail erdani.org>

<mailto:SeeWebsiteForEmail **erdani.org<SeeWebsiteForEmail erdani.org>



wrote: On 7/13/12 3:36 PM, Gor Gyolchanyan wrote: The initial question was: why does DMD 2.059 reject this if this makes sense? It's not even a new feature. It's a (possibly) new (and apparently sensible) use case of an existing feature. I think the simple answer is there was no provision for it. The feature copies the Java feature, and I don't think Java has something like what you defined. Andrei Well, the nested classes are pretty much useless without this feature. Except for translating Java code. If I had multiple inheritance, I'd just make the Apple as base class and have all the seeds virtually derive from it. Not having multiple inheritance drove me to try the next best think. And after it failed, I complained about it.. And here we are. Is it a difficult thing to fix? I don't know, you may want to submit an enhancement request. Andrei http://d.puremagic.com/issues/**show_bug.cgi?id=8389<http://d.puremagic.com/issues/show_bug.cgi?id=8389> Anyone who thinks this is important, please vote up. -- Bye, Gor Gyolchanyan.

This is something to do, but I don't know if it is really that important.

It's already fixed and will be in DMD 2.060 -- Bye, Gor Gyolchanyan. --bcaec554d8426fd12404c4cd0501 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 8:17 PM, deadalnix <span= dir=3D"ltr">&lt;<a href=3D"mailto:deadalnix gmail.com" target=3D"_blank">d= eadalnix gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quot= e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> On 14/07/2012 08:27, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On Sat, Jul 14, 2012 at 12:31 AM, Andrei Alexandrescu<div class=3D"im"><br> &lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org" target=3D"_blank">SeeW= ebsiteForEmail erdani.org</a> &lt;mailto:<a href=3D"mailto:SeeWebsiteForEma= il erdani.org" target=3D"_blank">SeeWebsiteForEmail <u></u>erdani.org</a>&g= t;&gt;<br> wrote:<br> <br> =C2=A0 =C2=A0 On 7/13/12 3:49 PM, Gor Gyolchanyan wrote:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 On Fri, Jul 13, 2012 at 11:41 PM, Andrei Alexan= drescu<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;<a href=3D"mailto:SeeWebsiteForEmail erdani= .org" target=3D"_blank">SeeWebsiteForEmail erdani.org</a><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href=3D"mailto:SeeWebsiteForEmail= erdani.org" target=3D"_blank">SeeWebsiteForEmail <u></u>erdani.org</a>&gt;= <br></div> =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href=3D"mailto:SeeWebsiteForEmail= " target=3D"_blank">SeeWebsiteForEmail </a>__<a href=3D"http://erdani.org"= target=3D"_blank">e<u></u>rdani.org</a><div class=3D"im"><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href=3D"mailto:SeeWebsiteForEmail= erdani.org" target=3D"_blank">SeeWebsiteForEmail <u></u>erdani.org</a>&gt;= &gt;&gt;<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 wrote:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0On 7/13/12 3:36 PM, Gor Gyo= lchanyan wrote:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The initial q= uestion was: why does DMD 2.059 reject<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 this if this<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0makes<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sense?<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0It&#39;s not = even a new feature. It&#39;s a (possibly) new (and<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 apparently<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sensible) use= case of an existing feature.<br> <br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0I think the simple answer i= s there was no provision for it. The<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0feature copies the Java fea= ture, and I don&#39;t think Java has<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0something like what you def= ined.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Andrei<br> <br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Well, the nested classes are pretty much useles= s without this<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 feature.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Except for translating Java code. If I had mult= iple inheritance, I&#39;d<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 just make the Apple as base class and have all = the seeds virtually<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 derive from it. Not having multiple inheritance= drove me to try<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 the next<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 best think. And after it failed, I complained a= bout it.. And here we<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 are. Is it a difficult thing to fix?<br> <br> <br> =C2=A0 =C2=A0 I don&#39;t know, you may want to submit an enhancement reque= st.<br> <br> =C2=A0 =C2=A0 Andrei<br> <br> <br> </div><div class=3D"im"><a href=3D"http://d.puremagic.com/issues/show_bug.c= gi?id=3D8389" target=3D"_blank">http://d.puremagic.com/issues/<u></u>show_b= ug.cgi?id=3D8389</a><br> <br> Anyone who thinks this is important, please vote up.<br> <br> --<br> Bye,<br> Gor Gyolchanyan.<br> </div></blockquote> <br> This is something to do, but I don&#39;t know if it is really that importan= t.<br> </blockquote></div><br>It&#39;s already fixed and will be in DMD 2.060<br c= lear=3D"all"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --bcaec554d8426fd12404c4cd0501--
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d042c5ed7845f3c04c4cd6191
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 9:12 PM, Benjamin Thaut <code benjamin-thaut.de>wrote:

 The only problem about this is:

 class Fruit
 {
   class Seed {
     void SetFruit(Fruit fruit)
     {
       this.outer = fruit;
     }
   }
 }

 class Apple: Fruit
 {
   void AppleOnlyMethod(){ ... }

   class AppleSeed: Fruit.Seed {
     void DoSomething()
     {
       AppleOnlyMethod();
     }
   }

   auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut

make sense to have it an lvalue, because the object is specifically created out of the initial outer object. -- Bye, Gor Gyolchanyan. --f46d042c5ed7845f3c04c4cd6191 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 9:12 PM, Benjamin Thaut = <span dir=3D"ltr">&lt;<a href=3D"mailto:code benjamin-thaut.de" target=3D"_= blank">code benjamin-thaut.de</a>&gt;</span> wrote:<br><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> The only problem about this is:<br> <br> class Fruit<br> {<br> =C2=A0 class Seed {<br> =C2=A0 =C2=A0 void SetFruit(Fruit fruit)<br> =C2=A0 =C2=A0 {<br> =C2=A0 =C2=A0 =C2=A0 this.outer =3D fruit;<br> =C2=A0 =C2=A0 }<br> =C2=A0 }<br> }<br> <br> class Apple: Fruit<br> {<br> =C2=A0 void AppleOnlyMethod(){ ... }<br> <br> =C2=A0 class AppleSeed: Fruit.Seed {<br> =C2=A0 =C2=A0 void DoSomething()<br> =C2=A0 =C2=A0 {<br> =C2=A0 =C2=A0 =C2=A0 AppleOnlyMethod();<br> =C2=A0 =C2=A0 }<br> =C2=A0 }<br> <br> =C2=A0 auto GetNewSeed() { return new AppleSeed(); }<br> }<br> <br> auto apple =3D new Apple();<br> auto seed =3D apple.GetNewSeed();<br> seed.SetFruit(new Fruit());<br> seed.DoSomething(); //what happens here?<br> <br> Kind Regards<span class=3D"HOEnZb"><font color=3D"#888888"><br> Benjamin Thaut<br> <br> </font></span></blockquote></div><br>I think this.outer is not an lvalue, w= hich solves the problem. It wouldn&#39;t make sense to have it an lvalue, b= ecause the object is specifically created out of the initial outer object.<= br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --f46d042c5ed7845f3c04c4cd6191--
Jul 14 2012
prev sibling next sibling parent kenji hara <k.hara.pg gmail.com> writes:
2012/7/15 Benjamin Thaut <code benjamin-thaut.de>:
 The only problem about this is:

 class Fruit
 {
   class Seed {
     void SetFruit(Fruit fruit)
     {
       this.outer = fruit;

Setting to pseudo variable 'outer' should be rejected in compilation. Please report it to bugzilla.
     }
   }
 }

 class Apple: Fruit
 {
   void AppleOnlyMethod(){ ... }

   class AppleSeed: Fruit.Seed {
     void DoSomething()
     {
       AppleOnlyMethod();
     }
   }

   auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut

Kenji Hara
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--bcaec554deb203eebc04c4cd8e2d
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut <code benjamin-thaut.de>wrote:

 Am 14.07.2012 19:21, schrieb kenji hara:

 2012/7/15 Benjamin Thaut <code benjamin-thaut.de>:

  The only problem about this is:
 class Fruit
 {
    class Seed {
      void SetFruit(Fruit fruit)
      {
        this.outer = fruit;

Setting to pseudo variable 'outer' should be rejected in compilation. Please report it to bugzilla. }
    }
 }

 class Apple: Fruit
 {
    void AppleOnlyMethod(){ ... }

    class AppleSeed: Fruit.Seed {
      void DoSomething()
      {
        AppleOnlyMethod();
      }
    }

    auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut


(template) for inner classes ;-) Kind Regards Benjamin Thaut

get fixed anyway, so you better start replacing your custom new operator. -- Bye, Gor Gyolchanyan. --bcaec554deb203eebc04c4cd8e2d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut = <span dir=3D"ltr">&lt;<a href=3D"mailto:code benjamin-thaut.de" target=3D"_= blank">code benjamin-thaut.de</a>&gt;</span> wrote:<br><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> Am 14.07.2012 19:21, schrieb kenji hara:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> 2012/7/15 Benjamin Thaut &lt;<a href=3D"mailto:code benjamin-thaut.de" targ= et=3D"_blank">code benjamin-thaut.de</a>&gt;:<div class=3D"im"><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> The only problem about this is:<br> <br> class Fruit<br> {<br> =C2=A0 =C2=A0class Seed {<br> =C2=A0 =C2=A0 =C2=A0void SetFruit(Fruit fruit)<br> =C2=A0 =C2=A0 =C2=A0{<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0this.outer =3D fruit;<br> </blockquote> <br></div><div class=3D"im"> Setting to pseudo variable &#39;outer&#39; should be rejected in compilatio= n.<br> Please report it to bugzilla.<br> <br> </div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"> =C2=A0 =C2=A0 =C2=A0}<br> =C2=A0 =C2=A0}<br> }<br> <br><div class=3D"im"> class Apple: Fruit<br> {<br> =C2=A0 =C2=A0void AppleOnlyMethod(){ ... }<br> <br> =C2=A0 =C2=A0class AppleSeed: Fruit.Seed {<br> =C2=A0 =C2=A0 =C2=A0void DoSomething()<br> =C2=A0 =C2=A0 =C2=A0{<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0AppleOnlyMethod();<br> =C2=A0 =C2=A0 =C2=A0}<br> =C2=A0 =C2=A0}<br> <br> =C2=A0 =C2=A0auto GetNewSeed() { return new AppleSeed(); }<br> }<br> <br> auto apple =3D new Apple();<br> auto seed =3D apple.GetNewSeed();<br> seed.SetFruit(new Fruit());<br> seed.DoSomething(); //what happens here?<br> <br> Kind Regards<br> Benjamin Thaut<br> <br> </div></blockquote> <br> Kenji Hara<br> <br> </blockquote> <br> I will not report this, beacuse it will break my custom new operator (templ= ate) for inner classes ;-)<br> <br> Kind Regards<span class=3D"HOEnZb"><font color=3D"#888888"><br> Benjamin Thaut<br> <br> </font></span></blockquote></div><br>That&#39;s most unwise, because if it&= #39;s not supposed to be like that it will get fixed anyway, so you better = start replacing your custom new operator.<br clear=3D"all"><div><br></div> -- <br>Bye,<br>Gor Gyolchanyan.<br> --bcaec554deb203eebc04c4cd8e2d--
Jul 14 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d04088ee5cc944d04c4dc8255
Content-Type: text/plain; charset=UTF-8

On Sun, Jul 15, 2012 at 1:41 PM, Benjamin Thaut <code benjamin-thaut.de>wrote:

 Am 15.07.2012 02:02, schrieb Timon Gehr:

  On 07/15/2012 12:55 AM, Benjamin Thaut wrote:
 Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:

 On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de**>> wrote:

 Am 14.07.2012 19:21, schrieb kenji hara:

 2012/7/15 Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de**>>:

 The only problem about this is:

 class Fruit
 {
 class Seed {
 void SetFruit(Fruit fruit)
 {
 this.outer = fruit;


 Setting to pseudo variable 'outer' should be rejected in
 compilation.
 Please report it to bugzilla.

 }
 }
 }

 class Apple: Fruit
 {
 void AppleOnlyMethod(){ ... }

 class AppleSeed: Fruit.Seed {
 void DoSomething()
 {
 AppleOnlyMethod();
 }
 }

 auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut


 Kenji Hara


 I will not report this, beacuse it will break my custom new operator
 (template) for inner classes ;-)

 Kind Regards
 Benjamin Thaut


 That's most unwise, because if it's not supposed to be like that it will
 get fixed anyway, so you better start replacing your custom new
 operator.

 --
 Bye,
 Gor Gyolchanyan.

Replacing my custom new operator exactly by what? Overloading the build in new is deprecated...

class D{ } } void main(){ auto c = new C; auto buf = new void[__traits(**classInstanceSize, C.D)]; (cast(byte[])buf)[] = typeid(C.D).init[]; auto d = cast(C.D)buf.ptr; static if(is(typeof(d.__ctor()))) d.__ctor(); enum offset=d.outer.offsetof; static assert(offset%C.sizeof==0); (cast(C[])buf)[offset/C.**sizeof]=c; assert(d.outer is c); }

Yes of course I can assign the reference by computing the address and then using that to assign it. But the point here is, that this is currently the only bug that is hepling me in what I'm doing, and I rather want the 7 other bugs I reported so far to be fixed, rather then the one that helps me. Kind Regards Benjamin Thaut

anything else for that matter) if it's a bug - it's gonna be fixed. If you decided to abuse a bug - it's your problem and your problem alone. The earlier you start getting rid of that design, the easier it will be when the bug gets inevitable fixed. -- Bye, Gor Gyolchanyan. --f46d04088ee5cc944d04c4dc8255 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sun, Jul 15, 2012 at 1:41 PM, Benjamin Thaut = <span dir=3D"ltr">&lt;<a href=3D"mailto:code benjamin-thaut.de" target=3D"_= blank">code benjamin-thaut.de</a>&gt;</span> wrote:<br><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> Am 15.07.2012 02:02, schrieb Timon Gehr:<div><div class=3D"h5"><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On 07/15/2012 12:55 AM, Benjamin Thaut wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut &lt;<a href=3D"mailto:code = benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de</a><br> &lt;mailto:<a href=3D"mailto:code benjamin-thaut.de" target=3D"_blank">code= benjamin-thaut.de</a><u></u>&gt;&gt; wrote:<br> <br> Am 14.07.2012 19:21, schrieb kenji hara:<br> <br> 2012/7/15 Benjamin Thaut &lt;<a href=3D"mailto:code benjamin-thaut.de" targ= et=3D"_blank">code benjamin-thaut.de</a><br> &lt;mailto:<a href=3D"mailto:code benjamin-thaut.de" target=3D"_blank">code= benjamin-thaut.de</a><u></u>&gt;&gt;:<br> <br> The only problem about this is:<br> <br> class Fruit<br> {<br> class Seed {<br> void SetFruit(Fruit fruit)<br> {<br> this.outer =3D fruit;<br> <br> <br> Setting to pseudo variable &#39;outer&#39; should be rejected in<br> compilation.<br> Please report it to bugzilla.<br> <br> }<br> }<br> }<br> <br> class Apple: Fruit<br> {<br> void AppleOnlyMethod(){ ... }<br> <br> class AppleSeed: Fruit.Seed {<br> void DoSomething()<br> {<br> AppleOnlyMethod();<br> }<br> }<br> <br> auto GetNewSeed() { return new AppleSeed(); }<br> }<br> <br> auto apple =3D new Apple();<br> auto seed =3D apple.GetNewSeed();<br> seed.SetFruit(new Fruit());<br> seed.DoSomething(); //what happens here?<br> <br> Kind Regards<br> Benjamin Thaut<br> <br> <br> Kenji Hara<br> <br> <br> I will not report this, beacuse it will break my custom new operator<br> (template) for inner classes ;-)<br> <br> Kind Regards<br> Benjamin Thaut<br> <br> <br> That&#39;s most unwise, because if it&#39;s not supposed to be like that it= will<br> get fixed anyway, so you better start replacing your custom new<br> operator.<br> <br> --<br> Bye,<br> Gor Gyolchanyan.<br> </blockquote> <br> Replacing my custom new operator exactly by what? Overloading the build<br> in new is deprecated...<br> <br> </blockquote> <br> class C{<br> =C2=A0 =C2=A0 =C2=A0class D{<br> <br> =C2=A0 =C2=A0 =C2=A0}<br> }<br> void main(){<br> =C2=A0 =C2=A0 =C2=A0auto c =3D new C;<br> =C2=A0 =C2=A0 =C2=A0auto buf =3D new void[__traits(<u></u>classInstanceSize= , C.D)];<br> =C2=A0 =C2=A0 =C2=A0(cast(byte[])buf)[] =3D typeid(C.D).init[];<br> =C2=A0 =C2=A0 =C2=A0auto d =3D cast(C.D)buf.ptr;<br> =C2=A0 =C2=A0 =C2=A0static if(is(typeof(d.__ctor()))) d.__ctor();<br> =C2=A0 =C2=A0 =C2=A0enum offset=3Dd.outer.offsetof;<br> =C2=A0 =C2=A0 =C2=A0static assert(offset%C.sizeof=3D=3D0);<br> =C2=A0 =C2=A0 =C2=A0(cast(C[])buf)[offset/C.<u></u>sizeof]=3Dc;<br> =C2=A0 =C2=A0 =C2=A0assert(d.outer is c);<br> }<br> </blockquote> <br></div></div> Yes of course I can assign the reference by computing the address and then = using that to assign it. But the point here is, that this is currently the = only bug that is hepling me in what I&#39;m doing, and I rather want the 7 = other bugs I reported so far to be fixed, rather then the one that helps me= .<br> <br> Kind Regards<span class=3D"HOEnZb"><font color=3D"#888888"><br> Benjamin Thaut<br> <br> </font></span></blockquote></div><br>Don&#39;t you understand? It doesn&#39= ;t matter how much a bug helps you (or anything else for that matter) if it= &#39;s a bug - it&#39;s gonna be fixed. If you decided to abuse a bug - it&= #39;s your problem and your problem alone. The earlier you start getting ri= d of that design, the easier it will be when the bug gets inevitable fixed.= <br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --f46d04088ee5cc944d04c4dc8255--
Jul 15 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0407160bd3242f04c4dc8d3c
Content-Type: text/plain; charset=UTF-8

On Sun, Jul 15, 2012 at 1:41 PM, Benjamin Thaut <code benjamin-thaut.de>wrote:

 Am 15.07.2012 02:02, schrieb Timon Gehr:

  On 07/15/2012 12:55 AM, Benjamin Thaut wrote:
 Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:

 On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de**>> wrote:

 Am 14.07.2012 19:21, schrieb kenji hara:

 2012/7/15 Benjamin Thaut <code benjamin-thaut.de
 <mailto:code benjamin-thaut.de**>>:

 The only problem about this is:

 class Fruit
 {
 class Seed {
 void SetFruit(Fruit fruit)
 {
 this.outer = fruit;


 Setting to pseudo variable 'outer' should be rejected in
 compilation.
 Please report it to bugzilla.

 }
 }
 }

 class Apple: Fruit
 {
 void AppleOnlyMethod(){ ... }

 class AppleSeed: Fruit.Seed {
 void DoSomething()
 {
 AppleOnlyMethod();
 }
 }

 auto GetNewSeed() { return new AppleSeed(); }
 }

 auto apple = new Apple();
 auto seed = apple.GetNewSeed();
 seed.SetFruit(new Fruit());
 seed.DoSomething(); //what happens here?

 Kind Regards
 Benjamin Thaut


 Kenji Hara


 I will not report this, beacuse it will break my custom new operator
 (template) for inner classes ;-)

 Kind Regards
 Benjamin Thaut


 That's most unwise, because if it's not supposed to be like that it will
 get fixed anyway, so you better start replacing your custom new
 operator.

 --
 Bye,
 Gor Gyolchanyan.

Replacing my custom new operator exactly by what? Overloading the build in new is deprecated...

class D{ } } void main(){ auto c = new C; auto buf = new void[__traits(**classInstanceSize, C.D)]; (cast(byte[])buf)[] = typeid(C.D).init[]; auto d = cast(C.D)buf.ptr; static if(is(typeof(d.__ctor()))) d.__ctor(); enum offset=d.outer.offsetof; static assert(offset%C.sizeof==0); (cast(C[])buf)[offset/C.**sizeof]=c; assert(d.outer is c); }

Yes of course I can assign the reference by computing the address and then using that to assign it. But the point here is, that this is currently the only bug that is hepling me in what I'm doing, and I rather want the 7 other bugs I reported so far to be fixed, rather then the one that helps me. Kind Regards Benjamin Thaut

forbidding. It's about not breaking a working mechanism. You can't cast a function pointer into a class object not because the type system says so (which it does), but because that'll result in an undefined behavior, which will result in an immediate crash in the best scenario. Go ahead and change the outer via those hacks. But then don't get surprised when your program crashes for no reason (because the compiler assumed it not to change and ended up being wrong). -- Bye, Gor Gyolchanyan. --f46d0407160bd3242f04c4dc8d3c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sun, Jul 15, 2012 at 1:41 PM, Benjamin Thaut = <span dir=3D"ltr">&lt;<a href=3D"mailto:code benjamin-thaut.de" target=3D"_= blank">code benjamin-thaut.de</a>&gt;</span> wrote:<br><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> Am 15.07.2012 02:02, schrieb Timon Gehr:<div><div class=3D"h5"><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On 07/15/2012 12:55 AM, Benjamin Thaut wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut &lt;<a href=3D"mailto:code = benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de</a><br> &lt;mailto:<a href=3D"mailto:code benjamin-thaut.de" target=3D"_blank">code= benjamin-thaut.de</a><u></u>&gt;&gt; wrote:<br> <br> Am 14.07.2012 19:21, schrieb kenji hara:<br> <br> 2012/7/15 Benjamin Thaut &lt;<a href=3D"mailto:code benjamin-thaut.de" targ= et=3D"_blank">code benjamin-thaut.de</a><br> &lt;mailto:<a href=3D"mailto:code benjamin-thaut.de" target=3D"_blank">code= benjamin-thaut.de</a><u></u>&gt;&gt;:<br> <br> The only problem about this is:<br> <br> class Fruit<br> {<br> class Seed {<br> void SetFruit(Fruit fruit)<br> {<br> this.outer =3D fruit;<br> <br> <br> Setting to pseudo variable &#39;outer&#39; should be rejected in<br> compilation.<br> Please report it to bugzilla.<br> <br> }<br> }<br> }<br> <br> class Apple: Fruit<br> {<br> void AppleOnlyMethod(){ ... }<br> <br> class AppleSeed: Fruit.Seed {<br> void DoSomething()<br> {<br> AppleOnlyMethod();<br> }<br> }<br> <br> auto GetNewSeed() { return new AppleSeed(); }<br> }<br> <br> auto apple =3D new Apple();<br> auto seed =3D apple.GetNewSeed();<br> seed.SetFruit(new Fruit());<br> seed.DoSomething(); //what happens here?<br> <br> Kind Regards<br> Benjamin Thaut<br> <br> <br> Kenji Hara<br> <br> <br> I will not report this, beacuse it will break my custom new operator<br> (template) for inner classes ;-)<br> <br> Kind Regards<br> Benjamin Thaut<br> <br> <br> That&#39;s most unwise, because if it&#39;s not supposed to be like that it= will<br> get fixed anyway, so you better start replacing your custom new<br> operator.<br> <br> --<br> Bye,<br> Gor Gyolchanyan.<br> </blockquote> <br> Replacing my custom new operator exactly by what? Overloading the build<br> in new is deprecated...<br> <br> </blockquote> <br> class C{<br> =C2=A0 =C2=A0 =C2=A0class D{<br> <br> =C2=A0 =C2=A0 =C2=A0}<br> }<br> void main(){<br> =C2=A0 =C2=A0 =C2=A0auto c =3D new C;<br> =C2=A0 =C2=A0 =C2=A0auto buf =3D new void[__traits(<u></u>classInstanceSize= , C.D)];<br> =C2=A0 =C2=A0 =C2=A0(cast(byte[])buf)[] =3D typeid(C.D).init[];<br> =C2=A0 =C2=A0 =C2=A0auto d =3D cast(C.D)buf.ptr;<br> =C2=A0 =C2=A0 =C2=A0static if(is(typeof(d.__ctor()))) d.__ctor();<br> =C2=A0 =C2=A0 =C2=A0enum offset=3Dd.outer.offsetof;<br> =C2=A0 =C2=A0 =C2=A0static assert(offset%C.sizeof=3D=3D0);<br> =C2=A0 =C2=A0 =C2=A0(cast(C[])buf)[offset/C.<u></u>sizeof]=3Dc;<br> =C2=A0 =C2=A0 =C2=A0assert(d.outer is c);<br> }<br> </blockquote> <br></div></div> Yes of course I can assign the reference by computing the address and then = using that to assign it. But the point here is, that this is currently the = only bug that is hepling me in what I&#39;m doing, and I rather want the 7 = other bugs I reported so far to be fixed, rather then the one that helps me= .<br> <br> Kind Regards<span class=3D"HOEnZb"><font color=3D"#888888"><br> Benjamin Thaut<br> <br> </font></span></blockquote></div><br>Not being able to assign is not about = some sort of authoritative forbidding. It&#39;s about not breaking a workin= g mechanism. You can&#39;t cast a function pointer into a class object not = because the type system says so (which it does), but because that&#39;ll re= sult in an undefined behavior, which will result in an immediate crash in t= he best scenario. Go ahead and change the outer via those hacks. But then d= on&#39;t get surprised when your program crashes for no reason (because the= compiler assumed it not to change and ended up being wrong).<br clear=3D"a= ll"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --f46d0407160bd3242f04c4dc8d3c--
Jul 15 2012
prev sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0401730b9e03c404c4dcff55
Content-Type: text/plain; charset=UTF-8

On Sun, Jul 15, 2012 at 3:35 PM, Benjamin Thaut <code benjamin-thaut.de>wrote:

 Am 15.07.2012 13:24, schrieb Gor Gyolchanyan:

 On Sun, Jul 15, 2012 at 1:41 PM, Benjamin Thaut <code benjamin-thaut.de

 <mailto:code benjamin-thaut.de**>> wrote:

     Am 15.07.2012 02:02, schrieb Timon Gehr:

         On 07/15/2012 12:55 AM, Benjamin Thaut wrote:

             Am 14.07.2012 19:30, schrieb Gor Gyolchanyan:

                 On Sat, Jul 14, 2012 at 9:23 PM, Benjamin Thaut
                 <code benjamin-thaut.de <mailto:code benjamin-thaut.de**>
                 <mailto:code benjamin-thaut.de

                 <mailto:code benjamin-thaut.de**>__>> wrote:

                 Am 14.07.2012 19:21, schrieb kenji hara:

                 2012/7/15 Benjamin Thaut <code benjamin-thaut.de
                 <mailto:code benjamin-thaut.de**>
                 <mailto:code benjamin-thaut.de
                 <mailto:code benjamin-thaut.de**>__>>:


                 The only problem about this is:

                 class Fruit
                 {
                 class Seed {
                 void SetFruit(Fruit fruit)
                 {
                 this.outer = fruit;


                 Setting to pseudo variable 'outer' should be rejected in
                 compilation.
                 Please report it to bugzilla.

                 }
                 }
                 }

                 class Apple: Fruit
                 {
                 void AppleOnlyMethod(){ ... }

                 class AppleSeed: Fruit.Seed {
                 void DoSomething()
                 {
                 AppleOnlyMethod();
                 }
                 }

                 auto GetNewSeed() { return new AppleSeed(); }
                 }

                 auto apple = new Apple();
                 auto seed = apple.GetNewSeed();
                 seed.SetFruit(new Fruit());
                 seed.DoSomething(); //what happens here?

                 Kind Regards
                 Benjamin Thaut


                 Kenji Hara


                 I will not report this, beacuse it will break my custom
                 new operator
                 (template) for inner classes ;-)

                 Kind Regards
                 Benjamin Thaut


                 That's most unwise, because if it's not supposed to be
                 like that it will
                 get fixed anyway, so you better start replacing your
                 custom new
                 operator.

                 --
                 Bye,
                 Gor Gyolchanyan.


             Replacing my custom new operator exactly by what?
             Overloading the build
             in new is deprecated...


         class C{
               class D{

               }
         }
         void main(){
               auto c = new C;
               auto buf = new void[__traits(__**classInstanceSize, C.D)];

               (cast(byte[])buf)[] = typeid(C.D).init[];
               auto d = cast(C.D)buf.ptr;
               static if(is(typeof(d.__ctor()))) d.__ctor();
               enum offset=d.outer.offsetof;
               static assert(offset%C.sizeof==0);
               (cast(C[])buf)[offset/C.__**sizeof]=c;

               assert(d.outer is c);
         }


     Yes of course I can assign the reference by computing the address
     and then using that to assign it. But the point here is, that this
     is currently the only bug that is hepling me in what I'm doing, and
     I rather want the 7 other bugs I reported so far to be fixed, rather
     then the one that helps me.

     Kind Regards
     Benjamin Thaut


 Not being able to assign is not about some sort of authoritative
 forbidding. It's about not breaking a working mechanism. You can't cast
 a function pointer into a class object not because the type system says
 so (which it does), but because that'll result in an undefined behavior,
 which will result in an immediate crash in the best scenario. Go ahead
 and change the outer via those hacks. But then don't get surprised when
 your program crashes for no reason (because the compiler assumed it not
 to change and ended up being wrong).

 --
 Bye,
 Gor Gyolchanyan.

Before your change suggestion it was absolutley save to assign to outer. Thats the whole point why I posted this here. I very well know that the bug will get fixed some time. But before your change suggestion it was not even a bug. Kind Regards Benjamin Thaut

would never get discovered. Even if the bug didn't get discovered for a long time, making designs around bugs is a very bad idea precisely for this reason. But it's not entirely your fault, because there's no reliable reference to D at the moment, so it's very hard to determine what is and is not supposed to work. That's one of the problems, that drive new commers away: lack of a reference material. -- Bye, Gor Gyolchanyan. --f46d0401730b9e03c404c4dcff55 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sun, Jul 15, 2012 at 3:35 PM, Benjamin Thaut = <span dir=3D"ltr">&lt;<a href=3D"mailto:code benjamin-thaut.de" target=3D"_= blank">code benjamin-thaut.de</a>&gt;</span> wrote:<br><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> Am 15.07.2012 13:24, schrieb Gor Gyolchanyan:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On Sun, Jul 15, 2012 at 1:41 PM, Benjamin Thaut &lt;<a href=3D"mailto:code = benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de</a><div class= =3D"im"><br> &lt;mailto:<a href=3D"mailto:code benjamin-thaut.de" target=3D"_blank">code= benjamin-thaut.de</a><u></u>&gt;&gt; wrote:<br> <br> =C2=A0 =C2=A0 Am 15.07.2012 02:02, schrieb Timon Gehr:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 On 07/15/2012 12:55 AM, Benjamin Thaut wrote:<b= r> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Am 14.07.2012 19:30, schrieb Gor = Gyolchanyan:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 On Sat, Jul 14, 201= 2 at 9:23 PM, Benjamin Thaut<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;<a href=3D"mail= to:code benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de</a> &lt= ;mailto:<a href=3D"mailto:code benjamin-thaut.de" target=3D"_blank">code be= njamin-thaut.de</a><u></u>&gt;<br></div> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href= =3D"mailto:code benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de= </a><div class=3D"im"><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href= =3D"mailto:code benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de= </a><u></u>&gt;__&gt;&gt; wrote:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Am 14.07.2012 19:21= , schrieb kenji hara:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 2012/7/15 Benjamin = Thaut &lt;<a href=3D"mailto:code benjamin-thaut.de" target=3D"_blank">code = benjamin-thaut.de</a><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href= =3D"mailto:code benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de= </a><u></u>&gt;<br></div> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href= =3D"mailto:code benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de= </a><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;mailto:<a href= =3D"mailto:code benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de= </a><u></u>&gt;__&gt;&gt;:<div><div class=3D"h5"><br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 The only problem ab= out this is:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 class Fruit<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 class Seed {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 void SetFruit(Fruit= fruit)<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 this.outer =3D frui= t;<br> <br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Setting to pseudo v= ariable &#39;outer&#39; should be rejected in<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 compilation.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Please report it to= bugzilla.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 class Apple: Fruit<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 void AppleOnlyMetho= d(){ ... }<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 class AppleSeed: Fr= uit.Seed {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 void DoSomething()<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 AppleOnlyMethod();<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto GetNewSeed() {= return new AppleSeed(); }<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto apple =3D new = Apple();<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto seed =3D apple= .GetNewSeed();<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 seed.SetFruit(new F= ruit());<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 seed.DoSomething();= //what happens here?<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Kind Regards<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Benjamin Thaut<br> <br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Kenji Hara<br> <br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 I will not report t= his, beacuse it will break my custom<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 new operator<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (template) for inne= r classes ;-)<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Kind Regards<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Benjamin Thaut<br> <br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 That&#39;s most unw= ise, because if it&#39;s not supposed to be<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 like that it will<b= r> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 get fixed anyway, s= o you better start replacing your<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 custom new<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 operator.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Bye,<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Gor Gyolchanyan.<br=

<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Replacing my custom new operator = exactly by what?<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Overloading the build<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 in new is deprecated...<br> <br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 class C{<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 class D{<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 void main(){<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto c =3D new C;<br></div=
</div>

aits(__<u></u>classInstanceSize, C.D)];<div class=3D"im"><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cast(byte[])buf)[] =3D ty= peid(C.D).init[];<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto d =3D cast(C.D)buf.pt= r;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 static if(is(typeof(d.__ct= or()))) d.__ctor();<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enum offset=3Dd.outer.offs= etof;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 static assert(offset%C.siz= eof=3D=3D0);<br></div> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cast(C[])buf)[offset/C.__= <u></u>sizeof]=3Dc;<div class=3D"im"><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(d.outer is c);<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> <br> <br> =C2=A0 =C2=A0 Yes of course I can assign the reference by computing the add= ress<br> =C2=A0 =C2=A0 and then using that to assign it. But the point here is, that= this<br> =C2=A0 =C2=A0 is currently the only bug that is hepling me in what I&#39;m = doing, and<br> =C2=A0 =C2=A0 I rather want the 7 other bugs I reported so far to be fixed,= rather<br> =C2=A0 =C2=A0 then the one that helps me.<br> <br> =C2=A0 =C2=A0 Kind Regards<br> =C2=A0 =C2=A0 Benjamin Thaut<br> <br> <br></div><div class=3D"im"> Not being able to assign is not about some sort of authoritative<br> forbidding. It&#39;s about not breaking a working mechanism. You can&#39;t = cast<br> a function pointer into a class object not because the type system says<br> so (which it does), but because that&#39;ll result in an undefined behavior= ,<br> which will result in an immediate crash in the best scenario. Go ahead<br> and change the outer via those hacks. But then don&#39;t get surprised when= <br> your program crashes for no reason (because the compiler assumed it not<br> to change and ended up being wrong).<br> <br> --<br> Bye,<br> Gor Gyolchanyan.<br> </div></blockquote> <br> Before your change suggestion it was absolutley save to assign to outer. Th= ats the whole point why I posted this here. I very well know that the bug w= ill get fixed some time. But before your change suggestion it was not even = a bug.<br> <br> Kind Regards<span class=3D"HOEnZb"><font color=3D"#888888"><br> Benjamin Thaut<br> <br> </font></span></blockquote></div><br>A bug remains a bug whether it was dis= covered or not. If it wasn&#39;t - it would never get discovered. Even if t= he bug didn&#39;t get discovered for a long time, making designs around bug= s is a very bad idea precisely for this reason. But it&#39;s not entirely y= our fault, because there&#39;s no reliable reference to D at the moment, so= it&#39;s very hard to determine what is and is not supposed to work. That&= #39;s one of the problems, that drive new commers away: lack of a reference= material.<br clear=3D"all"> <div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br> --f46d0401730b9e03c404c4dcff55--
Jul 15 2012