about summary refs log blame commit diff stats
path: root/html/global.mu.html
blob: eef09bb13666e5c0d38fc95eb2632763dabd992b (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                                                          

                                                
                                   
                                        

                       
                                                                          
                                                                           

                             
                             
                            

        

       
     

                                                                                   
                                        
                                                                 
                                                                                                                                                                                              
                                                                       
                                                                                                                            


     
                                       
                                                             
                                                                                                     



       
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - global.mu</title>
<meta name="Generator" content="Vim/7.3">
<meta name="plugin-version" content="vim7.3_v6">
<meta name="syntax" content="none">
<meta name="settings" content="use_css">
<style type="text/css">
<!--
pre { font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-family: monospace; color: #eeeeee; background-color: #080808; }
.Special { color: #ff6060; }
.Constant { color: #00a0a0; }
.muRecipe { color: #ff8700; }
.Comment { color: #9090ff; }
-->
</style>
</head>
<body>
<pre>
<span class="Comment"># example program: creating and using global variables</span>

<span class="muRecipe">def</span> main [
  <span class="Comment"># allocate 5 locations for globals</span>
  <span class="Constant">global-space</span>:address:shared:array:location<span class="Special"> &lt;- </span>new <span class="Constant">location:type</span>, <span class="Constant">5</span>
  <span class="Comment"># read to globals by using /space:global</span>
  <span class="Special">1:number/space:global</span><span class="Special"> &lt;- </span>copy <span class="Constant">3</span>
  foo
]

<span class="muRecipe">def</span> foo [
  <span class="Comment"># ditto for writing to globals</span>
  $print <span class="Special">1:number/space:global</span>, <span class="Constant">10/newline</span>
]
</pre>
</body>
</html>