Re: delegate support in euphoria?

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
kobi said...

hello, I'm a beginner, I would like to know if Euphoria supports the delegate concept, also known as: callbacks, anonymous functions.

for example, a 'retain' function filters a sequence based on a predicate (a func that returns a boolean). retain would take the sequence and the predicate as its two parameters.

now the programmer can use this construct, as an abstraction for later work that only differs by the arguments. (no need to write the same code when the "block" can be passed from outside)

Yes. The function routine_id() can be used to get an handle to any procedure or function and then that handle can be passed as an argument to a routine, which would call the handle's routine using either the call_func() or call_proc() as appropriate.

There was a related thread a little while ago, talking about function composition in euphoria, which you might find interesting:

http://openeuphoria.org/forum/114817.wc

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu