What are First Class Citizens?
'First Class Citizen', I have gone through this sentence many times but never bothered on what does this really mean.
But yersterday while going through basics of 'Functional Programming', another programming paradigm, I stumbled upon 'Functions as First Class Citizens'. I recalled it was Objects and now it's Functions, How come? Are functions promoted? J.
In programming language design, a first-class citizen (also object, entity, or value) in a given programming language is an entity which supports all the operations generally available to other entities. These operations typically include being passed as a parameter, returned from a function, and assigned to a variable.Another similar definition, 'First Class Citizens' of a programming language can be:
- can be stored in variables and data structures
- can be passed as a parameter to a subroutine
- can be returned as the result of a subroutine
- can be constructed at run-time
- has intrinsic identity (independent of any given name)
Java FCC are Objects: True
Scala FCC are Functions: ? (I may have to evaluate Scala to check the validity of 4 & 5).
Scala FCC are Functions: ? (I may have to evaluate Scala to check the validity of 4 & 5).
No comments:
Post a Comment