private method access for 'semi-static' object

Posted by Admin on 03-Aug-2011 07:31

Trying  to find an workaround for getting a memptr allocated by a static method  (it keep pointing to the same memory area if the mamptr variable is  defined in the static method) I've ended-up having a 'fake' all-static  object, meaning a singleton is used behind the scene to serve those  'nasty' static malloc/free mehtods


The object looks something like that

class Foo   : 
   define private static property this as Foo no-undo
      get:
         if not valid-object(this) then
            this = new Foo().
         return this.
      end get.
      set.   
   method private void _Test ():    end method.
   method public static void Test ():       this:_Test().    end method.
end class.
 


Now, that compiles and run just fine up to version OE 10.2B where it  complains that a private method is being accessed from outside the class  which leaves me with no options than to make that method public as well. Still, I do not really see it as public and because of a private constructor can never be public but it just looks strange... what are  your feeling about that?

Note that the Java equivalent  works just fine and that strangely enough even prior to 10.2B if the  instance method access level is changed to 'protected' the compiler  complains that it can only access the protected method from it's class  hierarchy

All Replies

Posted by Peter Judge on 03-Aug-2011 07:51

Marian,

There was a thread or 2 on the whole question of class-private and instance-private members some time ago.

More at http://communities.progress.com/pcom/message/91930#91930

-- peter

Posted by Admin on 03-Aug-2011 11:28

Thanks Peter,

indeed I've had missed that and I can only say I'm definitively with Bruce on that subject but one can choose he's own implementation so I guess we'll have to leave with it

It  was fun to see Mike's surprise on finding that C# has the same 'bug'  and I wonder if he took action and log it as such for C# development  team

On the other hand even if I was counting on accessing private instance members from static class members I didn't quite expected to be able to do the same from other instance of the same class.

class Foo :

   method private void _Test ():

   end method.

   method public void Test (obj as Foo):

      obj:_Test().

   end method.

end class.

Posted by Admin on 03-Aug-2011 11:36

It was fun to see Mike's surprise on finding that C# has the same 'bug' and I wonder if he took action and log it as such for C# development team

No, I didn't log anything with Microsoft.

All the .NET specs are public domain. If someone has time, he could read up if it's spec'ed like this. In that case it's not a bug ... I

Posted by Admin on 03-Aug-2011 11:59

No, I didn't log anything with Microsoft.

All the .NET specs are public domain. If someone has time, he could read up if it's spec'ed like this. In that case it's not a bug ... I

Hehehe... clearly something that works as specified isn't a bug (is it???) but what if isn't specified or one think those specs could have been different?

This thread is closed