Knowledge (XXG)

First-class citizen

Source đź“ť

80:
In ALGOL, a real number may appear in an expression or be assigned to a variable, and either of them may appear as an actual parameter in a procedure call. A procedure, on the other hand, may only appear in another procedure call either as the operator (the most common case) or as one of the actual
81:
parameters. There are no other expressions involving procedures or whose results are procedures. Thus in a sense procedures in ALGOL are second class citizens—they always have to appear in person and can never be represented by a variable or expression (except in the case of a formal parameter)...
550:
These allow varying forms of first-class access to the language implementation, and are, in general, manipulable in the same way as, and fully indistinguishable from, ordinary language objects. Because of this, their usage generally comes with some (cultural) stipulations and advice, as untested
516:- which allow the user to write code which handles code as data and evaluates it by discretion, enabling, for example, programs to write programs (or rewrite themselves) inside of the compiler, interpreter, or even the parser ( 136:
supports array assignment, and when they are passed as parameters, only the position of their first element is actually passed—their size is lost. C appears to support assignment of array
450:
Many programming languages support passing and returning function values, which can be applied to arguments. Whether this suffices to call function values first-class is disputed.
472:, functions (methods) are first-class objects, just like Smalltalk classes. Since Smalltalk operators (+, -, etc.) are methods, they are also first-class objects. 505:
family, reflection is a central feature of the language, rather than a special subsystem. Typically this takes the form of some set of the following features:
677: 498:
subsystem which allow access to internal implementation structures even though they are not accessible or manipulable in the same way as ordinary objects.
546:, in which the object system implements itself recursively via a system of metaclasses and metaobjects, which are themselves classes and objects. 812: 806: 457:
at runtime to call them 'first-class'. Under this definition, functions in C are not first-class objects; instead, they are sometimes called
357: 45:
is an entity which supports all the operations generally available to other entities. These operations typically include being passed as an
853: 858: 638: 495: 481: 551:
modification of the core programming system by users can easily undermine performance optimisations made by language implementers.
128:
and strings are not first-class: they cannot be assigned as objects or passed as parameters to a subroutine. For example, neither
46: 848: 160: 50: 769: 565: 290: 225: 221: 408: 404: 282: 261: 249: 229: 213: 311: 237: 233: 148: 531:
as a compiled tautologisation of itself, facilitating straightforward modification of the language without requiring a
543: 502: 431: 400: 315: 265: 253: 209: 54: 342: 196: 163:, or other metalanguage amenities enabling programs to implement extensions to their own implementation language. 674: 487: 286: 217: 509: 337: 140:, but in fact these are simply pointers to the array's first element, and again do not carry the array's size. 133: 693: 524: 109:
proposed definitions of second and third class values, but these definitions have not been widely adopted.
454: 156: 69:
in the 1960s. He did not actually define the term strictly, but contrasted real numbers and procedures in
445: 322: 378: 703::11 (2000); though published in 2000, these are notes from lectures Strachey delivered in August, 1967 829: 783: 560: 329: 191: 66: 38: 31: 630: 351: 272: 137: 422: 200: 118: 802: 634: 85: 794: 622: 462: 371: 297: 681: 302: 125: 623: 427: 307: 121:
data types, such as integer and floating-point numbers, are nearly always first-class.
106: 842: 532: 277: 167: 17: 798: 716:. in: D. Michie: Machine Intelligence 3, Edinburgh at the University Press, 1968 517: 412: 396: 367: 539: 387: 257: 144: 129: 469: 392: 383: 363: 205: 152: 461:, because they can still be manipulated in most of the above fashions (via 653:
Rod Burstall, "Christopher Strachey—Understanding Programming Languages",
159:
family often also feature first-class types, in the form of, for example,
88:
gave the following definition: All items have certain fundamental rights.
147:
are not first-class objects, though in some object-oriented languages,
740: 793:. Lecture Notes in Computer Science. Vol. 5520. pp. 57–99. 713: 513: 70: 65:
The concept of first- and second-class objects was introduced by
528: 241: 171: 491: 245: 174:-labels as objects at all, let alone as first-class objects. 770:
Type Inference for First-Class Messages with Match-Functions
629:. San Francisco, CA: Morgan Kaufmann Publishers. p.  791:
Language Engineering and Rigorous Software Development
98:
All items can be the subject of assignment statements
92:
All items can be the actual parameters of functions
453:Some authors require it be possible to create new 671:Structure and Interpretation of Computer Programs 95:All items can be returned as results of functions 542:- a special form of meta-circular evaluator for 527:- which provides a definition of the language's 763: 761: 694:Fundamental Concepts in Programming Languages 151:are first-class objects and are instances of 8: 741:"About first-,second- and third-class value" 712:R. J. Popplestone: The Design Philosophy of 501:In other languages, such as those in the 176: 669:Harold Abelson and Gerald Jay Sussman, 613: 577: 27:Concept in programming language design 698:Higher-Order and Symbolic Computation 655:Higher-Order and Symbolic Computation 101:All items can be tested for equality. 7: 727:Advanced Programming language Design 818:from the original on April 2, 2014 25: 782:Bove, Ana; Dybjer, Peter (2009). 767:Paritosh Shroff, Scott F. Smith. 482:Reflection (computer programming) 161:generalized algebraic data types 625:Programming Language Pragmatics 78:First and second class objects. 30:For the usage in society, see 1: 673:, 2nd edition, section 1.3.4 854:Programming language design 799:10.1007/978-3-642-03153-3_2 544:object-oriented programming 39:programming language design 875: 479: 443: 343:impredicative polymorphism 29: 859:Object (computer science) 784:"Dependent Types at Work" 124:In many older languages, 486:Some languages, such as 338:first-class polymorphism 692:Christopher Strachey, " 621:Scott, Michael (2006). 525:meta-circular evaluator 849:Programming constructs 535:different from itself; 166:Few languages support 157:functional programming 83: 446:First-class functions 323:first-class data type 75: 561:First-class function 459:second-class objects 192:first-class function 67:Christopher Strachey 53:, and assigned to a 32:Second-class citizen 540:metaobject protocol 494:, have an explicit 352:first-class message 273:first-class control 201:anonymous functions 155:. Languages in the 143:In most languages, 43:first-class citizen 680:2015-03-09 at the 594:first-class entity 590:first-class object 419:first-class proofs 105:During the 1990s, 49:, returned from a 18:First-class object 808:978-3-642-03152-6 745:stackoverflow.com 598:first-class value 463:function pointers 437: 436: 379:first-class class 86:Robin Popplestone 16:(Redirected from 866: 833: 827: 825: 823: 817: 788: 779: 773: 765: 756: 755: 753: 751: 736: 730: 723: 717: 710: 704: 690: 684: 667: 661: 651: 645: 644: 628: 618: 601: 586:first-class type 582: 510:syntactic macros 298:first-class type 177: 21: 874: 873: 869: 868: 867: 865: 864: 863: 839: 838: 837: 836: 821: 819: 815: 809: 786: 781: 780: 776: 766: 759: 749: 747: 739:Norman Ramsey. 738: 737: 733: 724: 720: 711: 707: 691: 687: 682:Wayback Machine 668: 664: 652: 648: 641: 620: 619: 615: 610: 605: 604: 583: 579: 574: 557: 484: 478: 448: 442: 330:Generic Haskell 303:dependent types 115: 63: 35: 28: 23: 22: 15: 12: 11: 5: 872: 870: 862: 861: 856: 851: 841: 840: 835: 834: 807: 774: 757: 731: 718: 705: 685: 662: 646: 639: 612: 611: 609: 606: 603: 602: 584:Also known as 576: 575: 573: 570: 569: 568: 563: 556: 553: 548: 547: 536: 521: 480:Main article: 477: 474: 444:Main article: 441: 438: 435: 434: 425: 420: 416: 415: 390: 381: 375: 374: 361: 360:(method calls) 354: 348: 347: 345: 340: 334: 333: 327: 325: 319: 318: 305: 300: 294: 293: 280: 275: 269: 268: 203: 194: 188: 187: 184: 181: 114: 111: 107:Raphael Finkel 103: 102: 99: 96: 93: 62: 59: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 871: 860: 857: 855: 852: 850: 847: 846: 844: 831: 814: 810: 804: 800: 796: 792: 785: 778: 775: 772: 771: 764: 762: 758: 746: 742: 735: 732: 728: 722: 719: 715: 709: 706: 702: 699: 695: 689: 686: 683: 679: 676: 672: 666: 663: 659: 656: 650: 647: 642: 640:9780126339512 636: 632: 627: 626: 617: 614: 607: 599: 595: 591: 587: 581: 578: 571: 567: 564: 562: 559: 558: 554: 552: 545: 541: 537: 534: 530: 526: 522: 519: 518:reader macros 515: 511: 508: 507: 506: 504: 499: 497: 493: 489: 483: 475: 473: 471: 466: 464: 460: 456: 451: 447: 439: 433: 429: 426: 424: 421: 418: 417: 414: 410: 406: 402: 398: 394: 391: 389: 385: 382: 380: 377: 376: 373: 369: 365: 362: 359: 355: 353: 350: 349: 346: 344: 341: 339: 336: 335: 331: 328: 326: 324: 321: 320: 317: 313: 309: 306: 304: 301: 299: 296: 295: 292: 288: 284: 281: 279: 278:continuations 276: 274: 271: 270: 267: 263: 259: 255: 251: 247: 243: 239: 235: 231: 227: 223: 219: 215: 211: 207: 204: 202: 198: 195: 193: 190: 189: 185: 182: 179: 178: 175: 173: 169: 168:continuations 164: 162: 158: 154: 150: 146: 141: 139: 135: 131: 127: 122: 120: 117:The simplest 112: 110: 108: 100: 97: 94: 91: 90: 89: 87: 82: 79: 74: 72: 68: 60: 58: 56: 52: 48: 44: 40: 33: 19: 820:. Retrieved 790: 777: 768: 750:14 September 748:. Retrieved 744: 734: 726: 721: 708: 700: 697: 688: 670: 665: 657: 654: 649: 624: 616: 597: 593: 589: 585: 580: 549: 533:metalanguage 500: 485: 467: 458: 452: 449: 423:proof object 165: 142: 123: 116: 104: 84: 77: 76: 64: 42: 36: 725:Finkel, R. 675:footnote 64 566:Reification 413:Common Lisp 397:Objective-C 372:Common Lisp 368:Objective-C 183:Description 153:metaclasses 37:In a given 843:Categories 660::52 (2000) 608:References 496:reflection 476:Reflection 388:metaobject 258:JavaScript 186:Languages 145:data types 130:Fortran IV 529:evaluator 470:Smalltalk 455:functions 440:Functions 393:Smalltalk 384:metaclass 364:Smalltalk 206:Smalltalk 830:archived 813:Archived 678:Archived 555:See also 358:messages 356:dynamic 332:, C++11 197:closures 138:pointers 113:Examples 55:variable 51:function 47:argument 222:Haskell 180:Concept 149:classes 61:History 828:(also 822:8 June 805:  729:, p 73 637:  514:fexprs 409:Delphi 405:Python 283:Scheme 262:Delphi 250:Python 230:Kotlin 214:Scheme 126:arrays 119:scalar 816:(PDF) 787:(PDF) 714:POP-2 696:" in 596:, or 572:Notes 312:Idris 238:Swift 234:Scala 71:ALGOL 824:2015 803:ISBN 752:2013 635:ISBN 503:Lisp 490:and 488:Java 432:Agda 401:Ruby 386:and 316:Agda 266:Rust 254:Raku 242:Perl 210:Dart 199:and 172:GOTO 170:and 132:nor 41:, a 795:doi 631:140 512:or 492:PHP 468:In 465:). 428:Coq 308:Coq 246:PHP 845:: 811:. 801:. 789:. 760:^ 743:. 701:13 658:13 633:. 592:, 588:, 538:a 523:a 520:); 430:, 411:, 407:, 403:, 399:, 395:, 370:, 366:, 314:, 310:, 291:F# 289:, 287:ML 285:, 264:, 260:, 256:, 252:, 248:, 244:, 240:, 236:, 232:, 228:, 226:F# 224:, 220:, 218:ML 216:, 212:, 208:, 73:: 57:. 832:) 826:. 797:: 754:. 643:. 600:. 134:C 34:. 20:)

Index

First-class object
Second-class citizen
programming language design
argument
function
variable
Christopher Strachey
ALGOL
Robin Popplestone
Raphael Finkel
scalar
arrays
Fortran IV
C
pointers
data types
classes
metaclasses
functional programming
generalized algebraic data types
continuations
GOTO
first-class function
closures
anonymous functions
Smalltalk
Dart
Scheme
ML
Haskell

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

↑