From b75d9d456cb36ad41ab735586473adbbf3444643 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 15 Sep 2016 13:46:13 -0700 Subject: 3365 - create strings out of arbitrary types The implementation is quite hacky. Let's see how future needs develop before we try to clean it up. --- 059to_text.mu | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to '059to_text.mu') diff --git a/059to_text.mu b/059to_text.mu index 207ade78..30761eb9 100644 --- a/059to_text.mu +++ b/059to_text.mu @@ -29,3 +29,20 @@ scenario array-to-text-line-early-warning-for-static-dispatch [ x:text <- array-to-text-line n # just ensure there were no errors ] + +# finally, a specialization for single characters +def to-text c:character -> y:text [ + local-scope + load-ingredients + y <- new character:type, 1/capacity + *y <- put-index *y, 0, c +] + +scenario character-to-text [ + 1:character <- copy 111/o + 2:text <- to-text 1:character + 3:array:character <- copy *2:text + memory-should-contain [ + 3:array:character <- [o] + ] +] -- cgit 1.4.1-2-gfad0