Content deleted Content added
m Distinguish this sense of the term from its meaning in _mathematics_; readers may not know what category theory is. |
Rescuing 6 sources and tagging 0 as dead. #IABot (v1.5.5) |
||
Line 599:
== In Ruby ==
In [[Ruby (programming language)|Ruby]], several objects can be considered function objects, in particular Method and Proc objects. Ruby also has two kinds of objects that can be thought of as semi-function objects: UnboundMethod and block. UnboundMethods must first be bound to an object (thus becoming a Method) before they can be used as a function object. Blocks can be called like function objects, but to be used in any other capacity as an object (e.g. passed as an argument) they must first be converted to a Proc. More recently, symbols (accessed via the literal unary indicator <code>:</code>) can also be converted to <code>Proc</code>s. Using Ruby's unary <code>&</code> operator—equivalent to calling <code>to_proc</code> on an object, and [[duck typing|assuming that method exists]]—the [[Ruby Extensions Project]] [https://web.archive.org/web/20060425104650/http://blogs.pragprog.com
<source lang=Ruby>
Line 609:
</source>
Now, method <code>foo</code> can be a function object, i.e. a <code>Proc</code>, via <code>&:foo</code> and used via <code>takes_a_functor(&:foo)</code>. <code>Symbol.to_proc</code> was officially added to Ruby on June 11, 2006 during RubyKaiga2006. [https://web.archive.org/web/20060820025032/http://redhanded.hobix.com
Because of the variety of forms, the term Functor is not generally used in Ruby to mean a Function object.
Just a type of dispatch [[delegation (programming)|delegation]] introduced by the [https://web.archive.org/web/20070107205748/http://facets.rubyforge.org
<source lang=Ruby>
Line 656:
* [http://www.two-sdg.demon.co.uk/curbralan/papers/AsynchronousC++.pdf C++ Advanced Design Issues - Asynchronous C++] by [[Kevlin Henney]]
* [http://www.newty.de/fpt/index.html The Function Pointer Tutorials] by Lars Haendel (2000/2001)
* Article "[https://web.archive.org/web/20041009232434/http://www.cuj.com
* [http://jga.sourceforge.net/ Generic Algorithms for Java]
* [https://web.archive.org/web/20100330073950/http://www.amcgowan.ca
* [https://web.archive.org/web/20041013202445/http://www.parashift.com
{{DEFAULTSORT:Function Object}}
|