Ceylon (programming language): Difference between revisions

Content deleted Content added
Template:Infobox programming language update, parameters: move, add, fill. WP:LINK updates. Nonlead nonproper noun MOS:CAPS > low-case. Template:Cite web updates. Terms define before WP:ABBRs. Small WP:EoS WP:COPYEDITs.
m Cut needless carriage returns between lines (infobox, headings), in paragraph. Nonlead-word nonproper noun MOS:CAPS MOS:HEADings-MOS:HEADCAPS > low-case. Small WP:EoS WP:COPYEDIT.
Line 15:
| operating system =
| license = [[Apache License|Apache]] v2
 
 
 
 
 
 
 
 
 
| website = {{URL|ceylon-lang.org}}
| file ext = .ceylon<ref>{{cite web
Line 90 ⟶ 81:
Ceylon is heavily-influenced by [[Java (programming language)|Java]]'s syntax, but adds many new features.
 
=== Type Systemsystem ===
One of the most novel aspects of Ceylon is its [[type system]]. Ceylon foregoes Java's primitive types<ref>{{cite web|last1=King|first1=Gavin|title=Ceylon: Language Design FAQ|url=http://ceylon-lang.org/documentation/faq/language-design/}}</ref> and [[Object type|boxing]] in favor of a type system composed entirely of first-class objects. While this may cause boxing overhead in certainsome situations, it makes the type system more uniform.
 
Ceylon allows for union and intersection types, in a similar fashion to [[TypeScript]], [[Whiley (programming language)|Whiley]] and Flow.
 
Union types, written <code>A|B</code>, allow a variable to have more than one type. The following example shows a Ceylon function which may take either an [[Integer (computer science)|integer]] or a [[String (computer science)|string]]:
The following example shows a Ceylon function which may take either an [[Integer (computer science)|integer]] or a [[String (computer science)|string]]:
 
<source lang="ceylon">
Line 169 ⟶ 159:
</source>
 
==== Enumerated Typestypes ====
 
Similar to Java and many other languages, and with a similar mechanism as algebraic types, Ceylon supports enumerated types, otherwise known as enums. This is implemented in Ceylon with a pattern of limiting the instances of an abstract class at declaration to a limited set of objects (in this case, singleton instances). Another way to implement this pattern is with the new constructor feature in Ceylon 1.2 where the objects are implemented as different named constructor declarations.<ref>{{cite web|last=King|first=Gavin|title=The Ceylon Language: 4.5.8 Enumerated classes |url=http://ceylon-lang.org/documentation/1.2/spec/html/declarations.html#classeswithcases|access-date=6 December 2015}}</ref>
 
Line 224 ⟶ 213:
 
=== Entry point with names===
 
A Ceylon program must have a main function called run():
<source lang="ceylon">