Fun with PRIVATE

Although it’s common knowledge that Clarion class methods have an implicit (SELF) object as the first parameter, it hadn’t occurred to me to try something like the attached program before. Look in the constructor in PrivateClass.clw. If you want really private methods, this seems like it could be a good way to keep them from being exposed.

SuperPrivateTest.zip (2.3 KB)

A downside is that code completion doesn’t work with “methods” declared this way.

I’m on my phone can you please
Paste the actual code here vs attaching a zip

My guess is you wrote an extension method

 Member
  
  Include('PrivateClass.inc'),ONCE
  
  MAP
   PrivateMethod(MyPrivateClass pMP,LONG pIn,LONG pOut),LONG
  END


MyPrivateClass.Construct PROCEDURE

  CODE
 
  SELF.Result =  SELF.PrivateMethod(12,40) !Notice that the SELF works here.


PrivateMethod  Procedure(MyPrivateClass pMP,LONG pIn,LONG pOut)!,LONG

   Code

  Return pIn ^ pOUt

Thanks
Yes that’s a what I meant by an extension method

Thanks Mark. I guess there’s a name for everything! :slight_smile:

Extension methods are a formalized thing in…net