about summary refs log tree commit diff stats
path: root/html/999spaces.cc.html
Commit message (Expand)AuthorAgeFilesLines
* 1885Kartik K. Agaram2015-07-291-1/+1
* 1853Kartik K. Agaram2015-07-251-2/+2
* 1818Kartik K. Agaram2015-07-181-2/+4
* 1631 - update html versionsKartik K. Agaram2015-06-231-4/+4
* 1549Kartik K. Agaram2015-06-091-2/+2
* 1517Kartik K. Agaram2015-05-301-2/+2
* 1461 - descriptions/table of contents for the layersKartik K. Agaram2015-05-261-0/+12
* 1291Kartik K. Agaram2015-05-061-1/+1
* 1289Kartik K. Agaram2015-05-061-0/+56
href='/akkartik/mu/blame/059to_text.mu?h=hlt&id=ef7d834fdd826977cd8d43253052a7b8e1c5aa72'>^
db01afa8 ^



a0331a9b ^
db01afa8 ^
4a48bedc ^
db01afa8 ^



431bbb1a ^
db01afa8 ^



a0331a9b ^
431bbb1a ^
db01afa8 ^

b75d9d45 ^

08f4628e ^
b75d9d45 ^
4a48bedc ^
b75d9d45 ^




08f4628e ^

a0331a9b ^
b75d9d45 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
                                                                             


                                                                              
                                       


                                                                             
                                    
             
             



                                                                
                                              
             
             



                                                         
                           



                                                               
                                 
                                

                                    

                                                 
                              
             
             




                                     

                          
                          



                            
# A couple of variants of 'to-text' that we'll use implicitly in stashes (see
# later layers).
#
# Mu code might specialize them to be smarter, but I don't anticipate any need
# beyond specializing 'to-text' itself.

# 'shorter' variant of to-text, when you want to enable some sort of trimming
# define it to be identical to 'to-text' by default
def to-text-line x:_elem -> y:text [
  local-scope
  load-inputs
  y <- to-text x
]

# variant for arrays (since we can't pass them around otherwise)
def array-to-text-line x:&:@:_elem -> y:text [
  local-scope
  load-inputs
  y <- to-text *x
]

scenario to-text-line-early-warning-for-static-dispatch [
  x:text <- to-text-line 34
  # just ensure there were no errors
]

scenario array-to-text-line-early-warning-for-static-dispatch [
  n:&:@:num <- new number:type, 3
  x:text <- array-to-text-line n
  # just ensure there were no errors
]

# finally, a specialization for single characters
def to-text c:char -> y:text [
  local-scope
  load-inputs
  y <- new character:type, 1/capacity
  *y <- put-index *y, 0, c
]

scenario character-to-text [
  1:char <- copy 111/o
  2:text <- to-text 1:char
  3:@:char <- copy *2:text
  memory-should-contain [
    3:array:character <- [o]
  ]
]