about summary refs log tree commit diff stats
path: root/real-files.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-18 09:06:34 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-18 09:09:00 -0700
commit4de96970f192bc2226250e52d1366e985db90ab5 (patch)
tree652073f7f234990d954724b0e896a92f75e51595 /real-files.mu
parent51ae6e61e2d14354e66b95cc028b8d1ebddfdc74 (diff)
downloadmu-4de96970f192bc2226250e52d1366e985db90ab5.tar.gz
3400
Undo commit 3340. Let's standardize names of non-core files to only have
dashes. That's also consistent with the edit/ and sandbox/ apps. Mu
programmers will tend to pervasively use dashes, just like Lisp
programmers.

Scripts will continue to use underscores..
Diffstat (limited to 'real-files.mu')
-rw-r--r--real-files.mu18
1 files changed, 18 insertions, 0 deletions
diff --git a/real-files.mu b/real-files.mu
new file mode 100644
index 00000000..78108fbe
--- /dev/null
+++ b/real-files.mu
@@ -0,0 +1,18 @@
+# example program: read a character from one file and write it to another
+# BEWARE: this will modify your file system
+# before running it, put a character into /tmp/mu-x
+# after running it, check /tmp/mu-y
+
+def main [
+  local-scope
+  f:num/file <- $open-file-for-reading [/tmp/mu-x]
+  $print [file to read from: ], f, 10/newline
+  c:char, eof?:boolean <- $read-from-file f
+  $print [copying ], c, 10/newline
+  f <- $close-file f
+  $print [file after closing: ], f, 10/newline
+  f <- $open-file-for-writing [/tmp/mu-y]
+  $print [file to write to: ], f, 10/newline
+  $write-to-file f, c
+  f <- $close-file f
+]