{"id":358,"date":"2013-08-07T09:45:50","date_gmt":"2013-08-07T07:45:50","guid":{"rendered":"https:\/\/altarica.labri.fr\/wp\/?page_id=358"},"modified":"2013-08-07T12:16:50","modified_gmt":"2013-08-07T10:16:50","slug":"constants","status":"publish","type":"page","link":"https:\/\/altarica.labri.fr\/wp\/?page_id=358","title":{"rendered":"AltaRica: Constants"},"content":{"rendered":"<p>Declarations of constants are introduced using the <code>const<\/code> keyword. A value is not necessarily assigned to a value. Three syntactic rules are allowed:<\/p>\n<pre>1 const const_id_1 = V;\r\n2\r\n3 const const_id_2 : Dom = V;\r\n4\r\n5 const const_id_3 : Dom;<\/pre>\n<p>The first case simply declares a constant <code>const_id_1<\/code> with the value <code>V<\/code> where <code>V<\/code> is any constant <a title=\"AltaRica: Basics\" href=\"https:\/\/altarica.labri.fr\/wp\/?page_id=333#Expressions\">expression<\/a>. The type associated to <code>const_id_1<\/code> is the type of <code>V<\/code>. The second case permits to declare the domain Dom of the constant <code>const_2<\/code>; this is mainly useful for integer variables. In the last case the value of <code>const_id_3<\/code> is not given; since no type inference exists in AltaRica a domain must be specified.<\/p>\n<p>The constant value <code>V<\/code> used to define a constant can refer to other constants. For instance, the following code defines an integer constant according to a Boolean flag:<\/p>\n<pre>1 const LARGE_MODEL : bool = true;\r\n2\r\n3 const SMALL_QUEUE_SIZE = 2;\r\n4 const LARGE_QUEUE_SIZE = 20;\r\n5\r\n6 const QUEUE_SIZE = if LARGE_QUEUE then LARGE_QUEUE_SIZE else SMALL_QUEUE_SIZE;\r\n7\r\n8 domain Queue = bool[QUEUE_SIZE];<\/pre>\n<p>Compound constants are specified between braces <code>{}<\/code>:<\/p>\n<ul>\n<li>For arrays, values are simply the elements of the array separated by commas;<\/li>\n<li>For structures, a list of field assignments separated by commas is given. The field name is prefixed with a dot (<code>.<\/code>).<\/li>\n<\/ul>\n<p>The following example defines a constant array and a constant structure:<\/p>\n<pre>1 const CST_ARRAY = { 1, 2 ,3 };\r\n2 const CST_STRUCT = { .flag = true, .values = CST_ARRAY };<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Declarations of constants are introduced using the const keyword. A value is not necessarily assigned to a value. Three syntactic rules are allowed: 1 const const_id_1 = V; 2 3 const const_id_2 : Dom = V; 4 5 const const_id_3 &hellip; <a href=\"https:\/\/altarica.labri.fr\/wp\/?page_id=358\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":25,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-358","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=\/wp\/v2\/pages\/358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=358"}],"version-history":[{"count":9,"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=\/wp\/v2\/pages\/358\/revisions"}],"predecessor-version":[{"id":432,"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=\/wp\/v2\/pages\/358\/revisions\/432"}],"up":[{"embeddable":true,"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=\/wp\/v2\/pages\/25"}],"wp:attachment":[{"href":"https:\/\/altarica.labri.fr\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}