Mercurial Hosting > luan
comparison src/luan/modules/Io.luan @ 1308:70eecde81820
remove fn,... to improve readability
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 23 Jan 2019 23:37:02 -0700 |
parents | 8432d20a2729 |
children | f41919741100 |
comparison
equal
deleted
inserted
replaced
1307:6c8ceca4a10b | 1308:70eecde81820 |
---|---|
59 function Io.print(...) | 59 function Io.print(...) |
60 Io.print_to(Io.stdout,...) | 60 Io.print_to(Io.stdout,...) |
61 end | 61 end |
62 | 62 |
63 | 63 |
64 function Io.output_to(out,fn,...) | 64 function Io.output_to(out,fn) |
65 local old_out = Io.stdout | 65 local old_out = Io.stdout |
66 return try( { | 66 return try { |
67 function(...) | 67 function() |
68 Io.stdout = out | 68 Io.stdout = out |
69 return fn(...) | 69 return fn() |
70 end; | 70 end |
71 finally = function() | 71 finally = function() |
72 Io.stdout = old_out | 72 Io.stdout = old_out |
73 end; | 73 end |
74 }, ... ) | 74 } |
75 end | 75 end |
76 | 76 |
77 local uri = Io.uri -- make local | 77 local uri = Io.uri -- make local |
78 | 78 |
79 function Io.output_of(fn,...) | 79 function Io.output_of(fn) |
80 local string_uri = uri "string:" | 80 local string_uri = uri "string:" |
81 local out = string_uri.text_writer() | 81 local out = string_uri.text_writer() |
82 Io.output_to(out,fn,...) | 82 Io.output_to(out,fn) |
83 out.close() | 83 out.close() |
84 return string_uri.read_text() | 84 return string_uri.read_text() |
85 end | 85 end |
86 | 86 |
87 | 87 |