atomo-0.2: prelude/ports.atomo
current-output-port = Parameter new: Port standard-output
current-input-port = Parameter new: Port standard-input
(x: Object) print := current-output-port _? print: x
(x: Object) display := current-output-port _? display: x
read := current-input-port _? read
read-line := current-input-port _? read-line
read-char := current-input-port _? read-char
contents := current-input-port _? contents
ready? := current-input-port _? ready?
eof? := current-input-port _? eof?
with-output-to: (fn: String) do: b :=
{ Port (new: fn mode: @write) } wrap: @close do:
{ file |
with-output-to: file do: b
}
with-output-to: (p: Port) do: b :=
with: current-output-port as: p do: b
with-input-from: (fn: String) do: (b: Block) :=
{ Port (new: fn mode: @read) } wrap: @close do:
{ file |
with-input-from: file do: b
}
with-input-from: (p: Port) do: (b: Block) :=
with: current-input-port as: p do: b
with-all-output-to: (fn: String) do: b :=
{ Port (new: fn mode: @write) } wrap: @close do:
{ file |
with-all-output-to: file do: b
}
with-all-output-to: (p: Port) do: b :=
with-default: current-output-port as: p do: b
with-all-input-from: (fn: String) do: (b: Block) :=
{ Port (new: fn mode: @read) } wrap: @close do:
{ file |
with-all-input-from: file do: b
}
with-all-input-from: (p: Port) do: (b: Block) :=
with-default: current-input-port as: p do: b