From 5db553526711c1127abccc422ba92efd6e3e70ea Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 29 Aug 2023 21:55:12 -0500 Subject: Update to just be CHICKEN --- .dir-locals.el | 4 +++ README.md | 44 +++++++++------------------ chicanery.egg | 11 ++++--- chicanery.scm | 94 ++++++++++++++++------------------------------------------ 4 files changed, 48 insertions(+), 105 deletions(-) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..9c78ce8 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,4 @@ +;;; Directory Local Variables -*- no-byte-compile: t -*- +;;; For more information see (info "(emacs) Directory Variables") + +((scheme-mode . ((geiser-scheme-implementation . chicken)))) diff --git a/README.md b/README.md index 6c720b7..71083ad 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,33 @@ -# Chicanery: subtle, opinionated improvements to R7RS Scheme (in CHICKEN) +# Chicanery: subtle, opinionated improvements to R7RS Scheme for CHICKEN -While I was reading the [R7RS -specification](https://standards.scheme.org/official/r7rs.pdf), I was a little -annoyed by how broken up the standard library seemed to be. While the most -egregious example is maybe `(scheme case-lambda)`, which exports ... only -`case-lambda`, the other libraries like `(scheme write)` for `display`, `(scheme -cxr)` for functions like `caddr` but not `cddr`, and the rest didn't really seem -logical to me. Plus, in CHICKEN scheme, the one I usually use, `utf8` is an egg -you need to install separately... +While I was reading the [R7RS specification][r7rs], I was a little annoyed by how broken up the standard library seemed to be. While the most egregious example is maybe `(scheme case-lambda)`, which exports ... only `case-lambda`, the other libraries like `(scheme write)` for `display`, `(scheme cxr)` for functions like `caddr` but not `cddr`, and the rest didn't really seem logical to me. Plus, in CHICKEN scheme, the one I usually use, `utf8` is an egg you need to install separately... To ameliorate these minor warts in what I otherwise consider to be an excellent language, `chicanery` was born. It's kind of like a prelude, I suppose? It imports all `r7rs` modules and re-exports their identifiers, and makes sure the -implementation is Unicode-aware. It also includes a few extras ;) +implementation is Unicode-aware. ## Chicanery extras -I also thought it was strange that `map`, `for-each`, and `append` apply to -lists only, while `vector-map` and `string-for-each`, exist, for example. -`chicanery` prefixes the default `map`, `for-each`, and `append` functions with -`list-`, and redefines those identifiers to functions that are generic over -Scheme's base collection types (lists, strings, vectors, bytevectors where -applicable). I didn't make the functions fully-generic to keep them efficient -and because I don't know how to do that, but you can still use `vector-append` -or `list-map` if you know what type you need and want speed. +The following are included in the chicanery library because I like them. -In a similar vein, I've also added generic functions `ref` and `copy` that -dispatch to `string-ref`, `list-copy`, and the like. - -Other extras include - -- `(atom? x)` determines whether `x` is an atom (i.e., not a pair or null) -- `(read-port)`, `(read-port port)` reads a port until hitting end-of-file (IDK - why this isn't in R7RS!), in chunks of `read-port-chunk-size` -- `(defined? x)` returns whether the symbol `x` is bound to a variable +- `(atom? x)` determines whether `x` is an atom (i.e., not a pair or null) +- `(slurp [port])` reads a port until hitting end-of-file (IDK + why this isn't in R7RS!) - `(with-input-from-string str thunk)` calls `thunk` with `str` bound as the current-input-port. - `(with-output-to-string thunk)` calls `thunk` and returns a string of the output. - `(displayed x)`, `(->string x)` returns `x` as a string (via `display`) - `(written x)` returns `x` as a string (via `write`) -- `(print x ...)` displays `x ...` followed by a newline +- `(print . xs)` displays `xs` followed by a newline ## Todo -- Support multiple scheme implementations. I tried doing this (see the [multiple-impls](https://git.acdw.net/chicanery/?h=multiple-impls) branch), but it kept not working in weird ways, plus it was like whack-a-mole with all the different schemes and just exhausting. +- Support multiple scheme implementations. I tried doing this (see the [multiple-impls][] branch), but it kept not working in weird ways, plus it was like whack-a-mole with all the different schemes and just exhausting. ## License -This software is licensed under the GWL, v. 1.0. See [COPYING](https://git.acdw.net/chicanery/tree/COPYING) for details. +This software is licensed under the GWL, v 1.0. See [COPYING][copying] for details. + +[r7rs]: https://standards.scheme.org/official/r7rs.pdf +[multiple-impls]: https://git.acdw.net/chicanery/?h=multiple-impls +[copying]: https://git.acdw.net/chicanery/tree/COPYING diff --git a/chicanery.egg b/chicanery.egg index 2bce2f1..d894ab2 100644 --- a/chicanery.egg +++ b/chicanery.egg @@ -1,5 +1,3 @@ -;; chicanery -*- scheme -*- - ((synopsis "Subtly breaking scheme expectations.") (author "Case Duckworth") (version "0.3.0") @@ -9,8 +7,9 @@ (components (extension chicanery (source chicanery.scm) - (types-file) ; I don't know what this does ... + (types-file) (inline-file) - (csc-options "-X" "r7rs" "-R" "r7rs" - "-X" "utf8" "-R" "utf8" - "-no-warnings")))) + (csc-options -X r7rs -R r7rs + -X utf8 -R utf8 + -no-warnings) + (source-dependencies extras.scm)))) diff --git a/chicanery.scm b/chicanery.scm index 0fc71e4..4dba4ca 100644 --- a/chicanery.scm +++ b/chicanery.scm @@ -1,9 +1,9 @@ -;;; chicanery --- subtly breaking scheme expectations +(module chicanery () + (import scheme + (chicken module) + (chicken platform)) + (import r7rs utf8) -(import (r7rs)) - -(define-library chicanery - ;; All the scheme stuff in one place (import (scheme base)) (import (scheme case-lambda)) (import (scheme char)) @@ -19,69 +19,25 @@ (import (scheme repl)) (import (scheme time)) (import (scheme write)) - (import utf8) - (export * + - / <= < >= = > abs and #;append apply assoc assq assv begin - binary-port? boolean? boolean=? bytevector bytevector-append - bytevector-copy bytevector-copy! bytevector-length bytevector-u8-ref - bytevector-u8-set! bytevector? car cdr caar cadr cdar cddr - call-with-current-continuation call/cc call-with-port call-with-values - case ceiling char-ready? char->integer integer->char char=? char? char<=? char>=? char? close-input-port close-output-port - close-port complex? cond cond-expand cons current-input-port - current-output-port current-error-port define define-record-type - define-syntax define-values denominator numerator do dynamic-wind - eof-object eof-object? eq? eqv? equal? error error-object-irritants - error-object-message error-object? even? odd? exact inexact - exact-integer-sqrt exact-integer? exact? inexact? exp expt features - file-error? floor floor/ floor-quotient floor-remainder - flush-output-port #;for-each gcd lcm get-output-bytevector - get-output-string guard if import import-for-syntax include include-ci - input-port-open? output-port-open? input-port? output-port? integer? - lambda length let let* letrec letrec* let-values let*-values let-syntax - letrec-syntax list list-copy list-ref list-set! list-tail list? - list->vector make-bytevector make-list make-parameter make-string - make-vector #;map max min member memq memv modulo remainder negative? - positive? newline not null? number->string string->number number? - open-input-bytevector open-output-bytevector open-input-string - open-output-string or pair? parameterize peek-char peek-u8 port? - procedure? quasiquote quote quotient remainder raise raise-continuable - rational? rationalize read-bytevector read-bytevector! read-char - read-error? read-line read-string read-u8 real? reverse round set! - set-car! set-cdr! square string string->list list->string string->utf8 - utf8->string string->symbol symbol->string string->vector - string-append string-copy string-copy! string-fill! string-for-each - string-length string-map string-ref string-set! string=? string? string<=? string>=? string? substring symbol=? symbol? - syntax-error syntax-rules textual-port? truncate truncate/ - truncate-quotient truncate-remainder u8-ready? unless #;unquote - #;unquote-splicing values vector vector-append vector-copy vector-copy! - vector-fill! vector-for-each vector-length vector-map vector-ref - vector-set! vector->list vector->string vector? when - with-exception-handler write-bytevector write-char write-string - write-u8 zero?) - (export case-lambda) - (export char-alphabetic? char-ci<=? char-ci=? - char-ci>? char-downcase char-foldcase char-lower-case? char-numeric? - char-upcase char-upper-case? char-whitespace? digit-value string-ci<=? - string-ci=? string-ci>? string-downcase - string-foldcase string-upcase) - (export angle imag-part magnitude make-polar make-rectangular real-part) - (export caaaar caaadr caaar caadar caaddr caadr cadaar cadadr cadar caddar - cadddr caddr cdaaar cdaadr cdaar cdadar cdaddr cdadr cddaar cddadr - cddar cdddar cddddr cdddr) - (export environment eval) - (export call-with-input-file call-with-output-file delete-file file-exists? - open-binary-input-file open-binary-output-file open-input-file - open-output-file with-input-from-file with-output-to-file) - (export acos asin atan cos exp finite? infinite? log nan? sin sqrt tan) - (export delay delay-force force make-promise promise?) - (export load) - (export command-line emergency-exit exit get-environment-variable - get-environment-variables) - (export read) - (export interaction-environment) - (export current-jiffy current-second jiffies-per-second) - (export display write write-shared write-simple) - (include "chicanery.extras.scm")) + (reexport r7rs) + (reexport (scheme base)) + (reexport (scheme case-lambda)) + (reexport (scheme char)) + (reexport (scheme complex)) + (reexport (scheme cxr)) + (reexport (scheme eval)) + (reexport (scheme file)) + (reexport (scheme inexact)) + (reexport (scheme lazy)) + (reexport (scheme load)) + (reexport (scheme process-context)) + (reexport (scheme read)) + (reexport (scheme repl)) + (reexport (scheme time)) + (reexport (scheme write)) + (reexport utf8) + + (include "extras.scm") + (register-feature! #:chicanery)) -- cgit 1.4.1-21-gabe81