1 # example program: copy one file into another, character by character 2 # BEWARE: this will modify your file system 3 # before running it, put some text into /tmp/mu-x 4 # after running it, check /tmp/mu-y 5 6 def main [ 7 local-scope 8 source-file:&:source:char <- start-reading 0/real-filesystem, [/tmp/mu-x] 9 sink-file:&:sink:char, write-routine:num <- start-writing 0/real-filesystem, [/tmp/mu-y] 10 { 11 ¦ c:char, done?:bool, source-file <- read source-file 12 ¦ break-if done? 13 ¦ sink-file <- write sink-file, c 14 ¦ loop 15 } 16 close sink-file 17 # make sure to wait for the file to be actually written to disk 18 # (Mu practices structured concurrency: http://250bpm.com/blog:71) 19 wait-for-routine write-routine 20 ]