O$6.0.3 – Calling a method using a private method as a parameter
Omnis will execute any method “embedded” in your code ( embedded might not the right word, but it’s as far as my english
goes, sorry) if it complies to 3 compulsory conditions
– it’s named $xxxx, because without the $ sign Omnis will assume it’s a variable and fail finding the method
– it is in the $ctask (the defaut) or $cinst scope at runtime
– it MUST return a value
Quit method ‘you called me’
The method above can be called in differents ways :
Do method mymethod($callme) ;; example 1
If $callme()=’you called me’ ;;;; example 2
;; i was in $callme
Calculate #S1 as con($ctask.$callme(),’ first’) ;; example 3
;; You may notice the () after the method name is optional.
Le 02/06/2017 à 22:10, firstname.lastname@example.org a écrit :
> What I ‘really’ want to do is be able to define a parameter as taking a generic function. Something akin to defining a parameter as a function that takes two doubles returns a double. When making the actual call I could supply any function/method that is of type ‘takes two doubles and returns a double’.
> That said, for the time being I’d be happy to just be able to supply a call to a private method as a parameter :-).
>> On Jun 2, 2017, at 3:07 PM, “email@example.com” <firstname.lastname@example.org> wrote:
>> Assuming a single class, I want to a call a method and use an inline call to a private method as a parameter value. I can successfully use a public method as the parameter (e.g. do method callMe($cinst.$someMethod)) but I don’t really want to make $someMethod part of the public API. I want to make the call the equivalent of: do method callMe(do method someMethod). I realize I could pass the private method name as text and then perform a do method [passedValue] inside the receiving method but the calling syntax is less expressive that way, more prone to typos, and doesn’t pass my personal ‘this is clearly a hack’ test. There are certainly times when passing the method name as text is an appropriate solution (delayed execution etc) but in this case not so much.
>> Any thoughts?
>> Manage your list subscriptions at lists.omnis-dev.com
> Manage your list subscriptions at lists.omnis-dev.com
Manage your list subscriptions at lists.omnis-dev.com