Fun with PRIVATE


#1

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.


#2

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


#3
 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

#4

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


#5

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


#6

Extension methods are a formalized thing in…net