Go! (programming language): Difference between revisions

Content deleted Content added
m Example: remove <pre> because of wikitext in the source code.
Line 34:
== Example ==
The following example illustrates the "ontology-oriented" type and declarations style of Go!:<ref name=applied />
 
<pre>
Gender [[#algebraic|'''::=''']] male | female.
Line 43:
home:[] '''=>''' ''string''.
lives:[''string'']{}}.
person:[''string'', ''day'', Gender, ''string''] [[#theory|'''$=''']] person.
person(Nm, Born, Sx, Hm)..{
dayOfBirth() '''=>''' Born.
Line 56:
yearsBetween(...) '''=>''' ..
}.
newPerson:[''string'', ''day'', Gender, ''string''] '''=>''' person.
newPerson(Nm, Born, Sx, Hm) '''=>''' $person(Nm, Born, Sx, Hm).
 
</pre>
{{anchor|algebraic}}The <code>::=</code> rule defines a new [[algebraic data type]], a [[data type]] with only data constructors.