Knowledge (XXG)

Callable object

Source 📝

1207: 28: 1248: 1277: 1267: 111: 45: 1192: 92: 49: 64: 1241: 536: 896: 71: 715: 38: 78: 1234: 60: 1165: 1272: 1214: 316: 187: 129: 1103: 300: 169: 150: 1218: 85: 163: 157: 17: 1141: 294: 179: 1261: 27: 1206: 133: 1116: 411:
It is also possible in PHP 5.3+ to make objects invokable by adding a magic
312: 21: 182:
that can hold any callable object that matches its signature.
1166:"Declarations — The Swift Programming Language (Swift 5.6)" 1222: 280:// This will output "Called." to the screen. 602:# This will output "Called." to the screen. 52:. Unsourced material may be challenged and removed. 543:method can be called using function-call syntax. 1242: 8: 1249: 1235: 319:that can be used e.g. as parameter to the 194:may be called using function-call syntax. 132:, is any object that can be called like a 112:Learn how and when to remove this message 1096: 899:, callable objects are defined using 7: 1203: 1201: 50:adding citations to reliable sources 1221:. You can help Knowledge (XXG) by 1104:PHP Documentation on Magic Methods 14: 1117:"What is a "callable" in Python?" 1082:// Both function calls print 208. 1205: 714:Callable objects are defined in 26: 37:needs additional citations for 1: 1142:"A Tour of the Dart Language" 190:the function call operator 1294: 1278:Computer programming stubs 1200: 15: 1268:Object (computer science) 905: 724: 611: 545: 417: 325: 196: 415:method to their class: 186:In C++, any class that 1217:-related article is a 140:In different languages 317:first-class functions 1215:computer-programming 1193:C++ Callable concept 130:computer programming 46:improve this article 578:"Called." 241:"Called." 151:pointer to function 850:"there," 539:any object with a 1230: 1229: 1121:StackOverflow.com 609:Another example: 301:lambda expression 170:lambda expression 122: 121: 114: 96: 61:"Callable object" 1285: 1251: 1244: 1237: 1209: 1202: 1180: 1179: 1177: 1176: 1162: 1156: 1155: 1153: 1152: 1146:www.dartlang.org 1138: 1132: 1131: 1129: 1127: 1115:Bösch, Florian. 1112: 1106: 1101: 1083: 1080: 1077: 1074: 1071: 1068: 1065: 1062: 1059: 1056: 1053: 1050: 1047: 1044: 1041: 1038: 1035: 1032: 1029: 1026: 1023: 1020: 1017: 1014: 1011: 1008: 1005: 1002: 999: 996: 993: 990: 987: 984: 981: 978: 975: 972: 969: 966: 963: 960: 957: 954: 951: 948: 945: 942: 939: 936: 933: 930: 927: 924: 921: 918: 915: 912: 909: 902: 884: 881: 878: 875: 872: 869: 866: 863: 860: 857: 856:"gang" 854: 851: 848: 845: 842: 839: 836: 833: 830: 827: 824: 821: 818: 815: 812: 809: 806: 803: 800: 797: 794: 791: 788: 785: 782: 779: 776: 773: 770: 767: 764: 761: 758: 755: 752: 749: 746: 743: 740: 737: 734: 731: 728: 721: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 645: 642: 639: 636: 633: 630: 627: 624: 621: 618: 615: 603: 600: 597: 594: 591: 588: 585: 582: 579: 576: 573: 570: 567: 564: 561: 558: 555: 552: 549: 542: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 496: 493: 490: 487: 484: 481: 478: 475: 472: 469: 466: 463: 460: 457: 454: 451: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 414: 407: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 371: 368: 365: 362: 359: 356: 353: 350: 347: 344: 341: 338: 335: 332: 329: 322: 284: 281: 278: 275: 272: 269: 266: 263: 260: 257: 254: 251: 248: 245: 242: 239: 236: 233: 230: 227: 224: 221: 218: 215: 212: 209: 206: 203: 202:<iostream> 200: 193: 177: 117: 110: 106: 103: 97: 95: 54: 30: 22: 1293: 1292: 1288: 1287: 1286: 1284: 1283: 1282: 1258: 1257: 1256: 1255: 1198: 1189: 1184: 1183: 1174: 1172: 1164: 1163: 1159: 1150: 1148: 1140: 1139: 1135: 1125: 1123: 1114: 1113: 1109: 1102: 1098: 1093: 1087: 1085: 1084: 1081: 1078: 1075: 1072: 1069: 1066: 1063: 1060: 1057: 1054: 1051: 1048: 1045: 1042: 1039: 1036: 1033: 1030: 1027: 1024: 1021: 1018: 1015: 1012: 1009: 1006: 1003: 1000: 997: 994: 991: 988: 985: 982: 979: 976: 973: 970: 967: 964: 961: 958: 955: 952: 949: 946: 943: 940: 937: 934: 931: 928: 925: 922: 919: 916: 913: 910: 907: 900: 893: 886: 885: 882: 879: 876: 873: 870: 867: 864: 861: 858: 855: 852: 849: 846: 843: 840: 837: 834: 831: 828: 825: 823:WannabeFunction 822: 819: 816: 813: 810: 807: 804: 801: 798: 795: 792: 789: 786: 783: 780: 777: 774: 771: 768: 765: 762: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 730:WannabeFunction 729: 726: 719: 712: 707: 706: 703: 700: 697: 694: 691: 688: 685: 682: 679: 676: 673: 670: 667: 664: 661: 658: 655: 652: 649: 646: 643: 640: 637: 634: 631: 628: 625: 622: 619: 616: 613: 605: 604: 601: 598: 595: 592: 589: 586: 583: 580: 577: 574: 571: 568: 565: 562: 559: 556: 553: 550: 547: 540: 533: 528: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 412: 409: 408: 405: 402: 399: 396: 393: 390: 387: 384: 381: 378: 375: 372: 369: 366: 363: 360: 357: 354: 351: 348: 345: 342: 339: 336: 333: 330: 327: 320: 310: 291: 286: 285: 282: 279: 276: 273: 270: 267: 264: 261: 258: 255: 252: 249: 246: 243: 240: 237: 234: 231: 228: 225: 222: 219: 216: 213: 210: 207: 204: 201: 198: 191: 175: 158:member function 147: 142: 126:callable object 118: 107: 101: 98: 55: 53: 43: 31: 20: 18:Function object 12: 11: 5: 1291: 1289: 1281: 1280: 1275: 1270: 1260: 1259: 1254: 1253: 1246: 1239: 1231: 1228: 1227: 1210: 1196: 1195: 1188: 1187:External links 1185: 1182: 1181: 1170:docs.swift.org 1157: 1133: 1107: 1095: 1094: 1092: 1089: 1058:callAsFunction 1010:CallableStruct 932:callAsFunction 911:CallableStruct 906: 901:callAsFunction 892: 889: 844:"Hi" 725: 711: 708: 612: 546: 532: 529: 418: 326: 309: 306: 305: 304: 298: 290: 287: 197: 184: 183: 180:template class 173: 167: 161: 154: 146: 143: 141: 138: 120: 119: 34: 32: 25: 13: 10: 9: 6: 4: 3: 2: 1290: 1279: 1276: 1274: 1271: 1269: 1266: 1265: 1263: 1252: 1247: 1245: 1240: 1238: 1233: 1232: 1226: 1224: 1220: 1216: 1211: 1208: 1204: 1199: 1194: 1191: 1190: 1186: 1171: 1167: 1161: 1158: 1147: 1143: 1137: 1134: 1122: 1118: 1111: 1108: 1105: 1100: 1097: 1090: 1088: 904: 898: 890: 888: 723: 717: 709: 610: 607: 544: 538: 530: 416: 324: 318: 314: 307: 302: 299: 296: 293: 292: 288: 195: 189: 181: 176:std::function 174: 171: 168: 165: 162: 159: 155: 152: 149: 148: 144: 139: 137: 135: 131: 127: 116: 113: 105: 94: 91: 87: 84: 80: 77: 73: 70: 66: 63: –  62: 58: 57:Find sources: 51: 47: 41: 40: 35:This article 33: 29: 24: 23: 19: 1223:expanding it 1212: 1197: 1173:. Retrieved 1169: 1160: 1149:. Retrieved 1145: 1136: 1126:24 September 1124:. Retrieved 1120: 1110: 1099: 1086: 894: 887: 713: 608: 606: 596:foo_instance 584:foo_instance 534: 410: 311: 274:foo_instance 268:foo_instance 185: 125: 123: 108: 99: 89: 82: 75: 68: 56: 44:Please help 39:verification 36: 1273:Subroutines 617:Accumulator 156:pointer to 1262:Categories 1175:2022-02-28 1151:2019-03-25 1091:References 718:using the 541:__call__() 413:__invoke() 323:function: 192:operator() 72:newspapers 16:See also: 531:In Python 315:5.3+ has 188:overloads 1052:callable 1028:callable 1004:callable 891:In Swift 662:__call__ 626:__init__ 560:__call__ 435:__invoke 432:function 370:function 295:delegate 238:<< 217:operator 199:#include 134:function 102:May 2017 722:method. 710:In Dart 321:usort() 164:functor 86:scholar 983:number 941:number 908:struct 793:!' 760:String 751:String 742:String 720:call() 695:return 537:Python 456:return 429:public 391:return 308:In PHP 205:struct 145:In C++ 88:  81:  74:  67:  59:  1213:This 1070:scale 1040:scale 1016:value 989:value 974:scale 968:print 953:scale 920:value 897:Swift 877:' 868:' 862:print 772:' 769:=> 727:class 614:class 572:print 548:class 522:Minus 507:usort 483:array 423:Minus 420:class 358:usort 334:array 289:In C# 223:const 178:is a 128:, in 93:JSTOR 79:books 1219:stub 1128:2017 929:func 802:main 736:call 716:Dart 698:self 680:self 668:self 644:self 632:self 566:self 525:()); 256:main 235:cout 220:()() 214:void 65:news 1022:100 1001:let 959:Int 947:Int 926:Int 917:var 895:In 874:out 832:out 829:var 826:(); 820:new 811:var 659:def 623:def 590:Foo 557:def 551:Foo 535:In 519:new 513:$ a 477:$ a 465:$ y 459:$ x 447:$ y 441:$ x 406:}); 400:$ y 394:$ x 382:$ y 376:$ x 364:$ a 328:$ a 313:PHP 277:(); 265:Foo 253:int 229:std 208:Foo 48:by 1264:: 1168:. 1144:. 1119:. 992:)) 903:. 880:); 871:$ 859:); 838:wf 814:wf 805:() 787:$ 781:$ 775:$ 689:+= 677:): 641:): 599:() 593:() 569:): 504:); 355:); 259:() 250:}; 232::: 136:. 124:A 1250:e 1243:t 1236:v 1225:. 1178:. 1154:. 1130:. 1079:) 1076:2 1073:: 1067:, 1064:4 1061:( 1055:. 1049:) 1046:2 1043:: 1037:, 1034:4 1031:( 1025:) 1019:: 1013:( 1007:= 998:} 995:} 986:+ 980:( 977:* 971:( 965:{ 962:) 956:: 950:, 944:: 938:_ 935:( 923:: 914:{ 883:} 865:( 853:, 847:, 841:( 835:= 817:= 808:{ 799:} 796:; 790:c 784:b 778:a 766:) 763:c 757:, 754:b 748:, 745:a 739:( 733:{ 704:n 701:. 692:x 686:n 683:. 674:x 671:, 665:( 656:n 653:= 650:n 647:. 638:n 635:, 629:( 620:: 587:= 581:) 575:( 563:( 554:: 516:, 510:( 501:4 498:, 495:1 492:, 489:3 486:( 480:= 474:} 471:} 468:; 462:- 453:{ 450:) 444:, 438:( 426:{ 403:; 397:- 388:{ 385:) 379:, 373:( 367:, 361:( 352:4 349:, 346:1 343:, 340:3 337:( 331:= 303:. 297:; 283:} 271:; 262:{ 247:} 244:; 226:{ 211:{ 172:. 166:; 160:; 153:; 115:) 109:( 104:) 100:( 90:· 83:· 76:· 69:· 42:.

Index

Function object

verification
improve this article
adding citations to reliable sources
"Callable object"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
computer programming
function
pointer to function
member function
functor
lambda expression
template class
overloads
delegate
lambda expression
PHP
first-class functions
Python
Dart
Swift
PHP Documentation on Magic Methods
"What is a "callable" in Python?"
"A Tour of the Dart Language"

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.