Content deleted Content added
Importing Wikidata short description: "Multi-paradigm programming language" |
→Example: on balance - code footnotes and syntax highlighting trumps linked footnotes without highlighting. The choice of which (fake) lang works well may be tweaked, but this brings it more in line for readers |
||
Line 33:
== Example ==
The following example illustrates the "ontology-oriented" type and declarations style of Go!:<ref name=applied />
<syntaxhighlight lang="haskell">
person [[#interface|'''<~''']] {dayOfBirth:[] '''=>''' ''day''.▼
age:[] '''=>''' ''integer''.▼
sex:[] '''=>''' Sex.▼
name:[] '''=>''' ''string''.▼
home:[] '''=>''' ''string''.▼
lives:[''string'']{}}.▼
person:[''string'', ''day'', Sex, ''string''] [[#theory|'''$=''']] person.▼
person(Nm, Born, Sx, Hm)..{▼
dayOfBirth() '''=>''' Born.▼
age() '''=>''' yearsBetween(now(), Born).▼
sex() '''=>''' Sx.▼
name() '''=>''' Nm.▼
home() '''=>''' Hm.▼
lives(Pl) [[Prolog#Rules and facts|''':-''']] Pl '''=''' home().▼
yearsBetween:[''integer'', ''day''] '''=>''' integer.▼
yearsBetween(...) '''=>''' ..▼
}.▼
newPerson:[''string'', ''day'', Sex, ''string''] '''=>''' person.▼
newPerson(Nm, Born, Sx, Hm) '''=>''' $person(Nm, Born, Sx, Hm).▼
{{anchor|algebraic}}The <code>::=</code> rule defines a new [[algebraic data type]], a [[data type]] with only data constructors.▼
{{anchor|interface}}The <code><~</code> rule defines an interface type - it indicates what properties are characteristic of a <code>person</code> and also gives type constraints on these properties. It documents that <code>age</code> is a functional property with an integer value, that <code>lives</code> is a unary relation over strings, and that <code>dayOfBirth</code> is a functional property with a value that is an object of type <code>day</code>.▼
{{anchor|theory}}The <code>$=</code> type rule indicates that there is also a theory label, with the functor <code>person</code>, for a theory that defines the characteristic properties of the <code>person</code> type - implements the <code>person</code> interface - in terms of four given parameters of types <code>string</code>, <code>day</code> , <code>Sex</code>, and <code>string</code>.▼
</syntaxhighlight>
▲
▲
▲
==Conflict with Google==
|