From d0a18b2b404896e42c1f05aee514ff033a1baa1f Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Tue, 28 Mar 2017 21:50:49 -0300 Subject: [PATCH] More on `sterror`. --- CHANGELOG.md | 2 +- sources/declarations.shen | 7 ++++--- sources/make.shen | 1 + sources/sys.shen | 3 +++ sources/types.shen | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3290e41..b436689 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) - Added `(for-each F List)`. Calls `F` on every element of `List` (in order), ignoring the results. - Added `(filter Predicate List)`. Returns a new lost with all elements to which `(Predicate Elt)` returns true. - Added `(exit ExitCode)`. Exits the program using the specified error code. The default implementation just ends the REPL loop, ports have to override `exit` if they want the exit code to have any effect. -- Added `*sterror*`, STDERR port. Defaults to an alias of `*stoutput*`. +- Added `*sterror*` and `(sterror)`, STDERR port. Defaults to an alias of `*stoutput*`. ### Changed - Changed `hash` so that 0 is a valid return value. diff --git a/sources/declarations.shen b/sources/declarations.shen index 6ccf2ed..50b8cb5 100644 --- a/sources/declarations.shen +++ b/sources/declarations.shen @@ -121,7 +121,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. address-> 3 put 4 reassemble 2 read-file-as-string 1 read-file 1 read 1 read-byte 1 read-from-string 1 receive 1 release 0 remove 2 require 3 reverse 1 set 2 - simple-error 1 snd 1 specialise 1 spy 1 step 1 stinput 0 stoutput 0 + simple-error 1 snd 1 specialise 1 spy 1 step 1 stinput 0 stoutput 0 sterror 0 string->n 1 string->symbol 1 string? 1 str 1 subst 3 sum 1 symbol? 1 systemf 1 tail 1 tl 1 tc 1 tc? 0 thaw 1 tlstr 1 track 1 trap-error 2 tuple? 1 type 2 @@ -146,7 +146,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (put (intern "shen") external-symbols [! } { --> <-- && : ; :- := _ - *language* *implementation* *stinput* *stoutput* *home-directory* *version* + *language* *implementation* *stinput* *stoutput* *sterror* + *home-directory* *version* *maximum-print-sequence-size* *macros* *os* *release* *property-vector* *port* *porters* *hush* @v @p @s @@ -157,7 +158,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. unify! unput unprofile undefmacro return type tuple? true trap-error track time thaw tc? tc tl tlstr tlv tail systemf synonyms symbol symbol? string->symbol sum subst - string? string->n stream string stinput + string? string->n stream string stinput sterror stoutput step spy specialise snd simple-error set save str run reverse remove release read receive read-file read-file-as-bytelist read-file-as-string read-byte diff --git a/sources/make.shen b/sources/make.shen index 66ae3f2..e3833f1 100644 --- a/sources/make.shen +++ b/sources/make.shen @@ -26,6 +26,7 @@ (systemf fold-right) (systemf filter) (systemf exit) +(systemf sterror) (define make -> (map (function make-file) diff --git a/sources/sys.shen b/sources/sys.shen index 1a16266..d29220d 100644 --- a/sources/sys.shen +++ b/sources/sys.shen @@ -594,6 +594,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (define stoutput -> (value *stoutput*)) +(define sterror + -> (value *sterror*)) + (define string->symbol S -> (let Symbol (intern S) (if (symbol? Symbol) diff --git a/sources/types.shen b/sources/types.shen index 91e0464..322908f 100644 --- a/sources/types.shen +++ b/sources/types.shen @@ -181,6 +181,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (declare spy [symbol --> boolean]) (declare step [symbol --> boolean]) (declare stinput [--> [stream in]]) +(declare sterror [--> [stream out]]) (declare stoutput [--> [stream out]]) (declare string? [A --> boolean]) (declare str [A --> string])