encyclopegia.org

Callable object

A callable object, in computer programming, is any object that can be called like a function.

A callable object, in computer programming, is any object that can be called like a function. import std; struct Foo { void operator()() const { std::println("Called."); } }; int main() { Foo instance; instance(); // This will output "Called." to the screen. } $a = array(3, 1, 4); usort($a, function ($x, $y) { return $x - $y; }); It is also possible in PHP 5.3+ to make objects invokable by adding a magic __invoke() method to their class: class Minus { public function __invoke($x, $y) { return $x - $y; } } $a = array(3, 1, 4); usort($a, new Minus()); class Foo: def __call__(self) -> None: print("Called.") class Bar: ... instance: Foo = Foo() instance() # Outputs "Called." to the screen assert(callable(instance)) # True since instance has __call__ assert(callable(zip)) # True since zip is a function, despite not having __call__ assert(callable(Bar)) # True since Bar is a class, despite not having __call__ assert(callable(lambda x: x)) # True since lambdas have __call__ A collections.abc.Callable type annotation can be used to declare that a given variable must be callable. A Callable[P, R] , where P is a list of types and R is a type, can be called with values matching P as arguments and returns a value of type R . Other values for P , such as a ParamSpec or ... , denote more flexible cases. def spam(ham: int, eggs: str) -> None: return None func: Callable[[int, str], None] = spam none: None = func(0, "foo") Callable objects are defined in Dart using the call() method. class WannabeFunction { call(String a, String b, String c) => '$a $b $c!'; } main() { var wf = new WannabeFunction(); var out = wf("Hi","there,","gang"); print('$out'); } struct CallableStruct { var value: Int func callAsFunction(_ number: Int, scale: Int) { print(scale * (number + value)) } } let callable = CallableStruct(value: 100) callable(4, scale: 2) callable.callAsFunction(4, scale: 2) // Both function calls print 208. ==References==

References

  1. A Tour of the Dart Language · retrieved 2019-03-24 · rev 1373121774
    Cite this reference

    MLA "A Tour of the Dart Language." 2019-03-24. https://www.dartlang.org/guides/language/language-tour. Accessed 24 November 2026.

    Chicago "A Tour of the Dart Language." 2019-03-24. https://www.dartlang.org/guides/language/language-tour.

    APA encyclopegia.org. (2019). A Tour of the Dart Language. Retrieved November 24, 2026, from https://www.dartlang.org/guides/language/language-tour

  2. Declarations — The Swift Programming Language (Swift 5.6) · retrieved 2022-02-27 · rev 1373121774
    Cite this reference

    MLA "Declarations — The Swift Programming Language (Swift 5.6)." "Declarations — The Swift Programming Language (Swift 5. 2022-02-27. https://docs.swift.org/swift-book/ReferenceManual/Declarations.html. Accessed 24 November 2026.

    Chicago "Declarations — The Swift Programming Language (Swift 5.6)." "Declarations — The Swift Programming Language (Swift 5. 2022-02-27. https://docs.swift.org/swift-book/ReferenceManual/Declarations.html.

    APA "Declarations — The Swift Programming Language (Swift 5. (2022). Declarations — The Swift Programming Language (Swift 5.6). Retrieved November 24, 2026, from https://docs.swift.org/swift-book/ReferenceManual/Declarations.html

  3. PHP Documentation on Magic Methods Wikipedia revision 1373121774, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1373121774
    Cite this reference

    MLA "PHP Documentation on Magic Methods Wikipedia revision 1373121774, retrieved 2026-11-18." 2026-11-17. http://php.net/manual/en/language.oop5.magic.php#object.invoke. Accessed 24 November 2026.

    Chicago "PHP Documentation on Magic Methods Wikipedia revision 1373121774, retrieved 2026-11-18." 2026-11-17. http://php.net/manual/en/language.oop5.magic.php#object.invoke.

    APA encyclopegia.org. (2026). PHP Documentation on Magic Methods Wikipedia revision 1373121774, retrieved 2026-11-18. Retrieved November 24, 2026, from http://php.net/manual/en/language.oop5.magic.php#object.invoke

  4. Built-in Functions § callable · retrieved 2026-08-31 · rev 1373121774
    Cite this reference

    MLA "Built-in Functions § callable." 2026-08-31. https://docs.python.org/3.14/library/functions.html#callable. Accessed 24 November 2026.

    Chicago "Built-in Functions § callable." 2026-08-31. https://docs.python.org/3.14/library/functions.html#callable.

    APA encyclopegia.org. (2026). Built-in Functions § callable. Retrieved November 24, 2026, from https://docs.python.org/3.14/library/functions.html#callable

  5. Glossary § callable · retrieved 2026-08-31 · rev 1373121774
    Cite this reference

    MLA "Glossary § callable." 2026-08-31. https://docs.python.org/3.14/glossary.html#term-callable. Accessed 24 November 2026.

    Chicago "Glossary § callable." 2026-08-31. https://docs.python.org/3.14/glossary.html#term-callable.

    APA encyclopegia.org. (2026). Glossary § callable. Retrieved November 24, 2026, from https://docs.python.org/3.14/glossary.html#term-callable

  6. typing — Support for type hints § Annotating callable objects · retrieved 2026-08-31 · rev 1373121774
    Cite this reference

    MLA "typing — Support for type hints § Annotating callable objects." 2026-08-31. https://docs.python.org/3.14/library/typing.html#annotating-callables. Accessed 24 November 2026.

    Chicago "typing — Support for type hints § Annotating callable objects." 2026-08-31. https://docs.python.org/3.14/library/typing.html#annotating-callables.

    APA encyclopegia.org. (2026). typing — Support for type hints § Annotating callable objects. Retrieved November 24, 2026, from https://docs.python.org/3.14/library/typing.html#annotating-callables

Cite this article

MLA

"Callable object." encyclopegia.org, 2026, https://encyclopegia.org/wiki/callable-object. Accessed 24 November 2026.

Chicago

"Callable object." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/callable-object.

APA

encyclopegia.org. (2026). Callable object. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/callable-object

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Pepsi Paloma

enwiki · references available

Thandolwethu Mnyaka

enwiki · references available

Chittenden & Eastman Company

enwiki · references available

David William Antonio

enwiki · references available

SCR Public School

enwiki · references available

Lalla Hirayama

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1373121774 · 0.5 · snapshot enwiki-001373121774

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.