[Gambas-user] Optional parameters for Read accessors

bb adamnt42 at gmail.com
Mon Jun 21 04:08:11 CEST 2021

I'm pushing the boundaries again.

Sometimes we have a property that has more than one state variable. An
easy example is one where its original value or "at some point" is set
by the property Write accessor and its current state variable value is
variable perhaps based on user activity.

What I am trying to achieve is a way to have the property Read accessor
accept on optional parameter that will determine which of those values
is returned.

Of course, the obvious answer is to use another property or function to
return a specific state variable.

However it would be "neater" to have this in the natural accessor
  Private Sub MyProp_Read(Optional orig As Boolean=False) as Integer
    If orig then 
      Return $originalValue
      Return $currentValue
or something like that. In my current case the situation is much more
complex, hence the question, but that example encapsulates what I am
trying to achieve.

At the moment, trying this results in a "_Read declaration does not
match" error from the compiler, naturally. 

Is this viable? 


More information about the User mailing list