scsh-users
[Top] [All Lists]

Re: slib

To: scsh-news@zurich.ai.mit.edu
Subject: Re: slib
From: Rolf-Thomas Happe <rthappe@mathematik.uni-freiburg.de>
Date: 03 Feb 2002 18:04:11 +0100
Organization: IAM * ALU Frg * Germ
RT Happe writes:
> Ed Kademan writes:
> > Does anyone have an example of how to use slib from scsh?  I took the
> > scsh.init file that came with slib, modified it for my site, and now
> > can actually invoke the format procedure---my immediate reason for
> > trying slib---but I am not doing things in what I believe is the
> > accepted way.  I can't seem to get "require" to work for example and
> > am getting annoying warning messages.  Here is what I have to do
> 
> I'd prefer to get rid of slib's PROVIDE and REQUIRE machinery
> and embrace s48's module system.  (The dark ages have to end some
> day.)  The PS below contains the --improvised-- module definitions 
> for that part of slib needed to FORMAT, like so:

Corrigenda:  The n-ary - and / don't take care of the required
singulary behaviour (- 6) ==> -6 etc.  (I dislike functions 
with freakish special cases that make me commit mistakes in 
public.)  Additionally, I run the FORMAT test suite too late:
it turned out that the implementation seems to assume ASCII
encoding.  The corrected module definitions in the PS delay 
the moment of failure somewhat.

  Welcome to scsh 0.6.0 (Chinese Democracy)
  Type ,? for help.
  > ,config ,load slib/packages.scm
  slib/packages.scm
  > ,in slib-format
  Load structure slib-format (y/n)? y
  slib-format> ,load slib/formatst.scm

  slib/formatst.scm
  SLIB Common LISP format version 3.0
    (C) copyright 1992-1994 by Dirk Lutzebaeck
    please send bug reports to `lutzeb@cs.tu-berlin.de'
  This implementation has flonums and complex numbers
  
10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,
  *Failed* ("~6,3f" 12345.7)
   returns  "12345.700"
   expected "12345.679"
  270,
  *Failed* ("~,3f" 12345.7)
   returns  "12345.700"
   expected "12345.679"
  280,
  FORMAT: error with call: (format #f "~f<===" ===>1e4 )
          argument is not a number or a number string

  *Failed* ("~f" 123.568)
   returns  "123.568"
   expected "123.56789"

  Error: error in format

rthappe

PS
;;; Dump slib's dependency mechanism in favour of s48's module system. 
;;; assuming this file resides in the slib source dir

;; interfaces

(define-interface slib-genewrite-iface
  (export generic-write
          reverse-string-append))
          
(define-interface slib-strcase-iface
  (export string-upcase string-downcase string-capitalize
          string-upcase! string-downcase! string-capitalize!
          string-ci->symbol symbol-append))

(define-interface slib-strport-iface
  (export call-with-output-string call-with-input-string))

(define-interface slib-iface            ; well ...
  (compound-interface (export format
                              pretty-print)
                      slib-genewrite-iface
                      slib-strcase-iface
                      slib-strport-iface))

;; structures

(define-structure nary-mindiv (export / -)
  (open scheme)
  ;; or maybe you prefer slib's mularg.scm?
  (begin
    (define minus -)
    (define divus /)
    (define (- x . xs)
      (if (null? xs)
          (minus x)
          (minus x (apply + xs))))
    (define (/ x . xs)
      (if (null? xs)
          (divus x)
          (divus x (apply * xs))))))

(define-structure slib-cruft
  (export require provide provided?
          slib:tab slib:form-feed
          slib:error
          current-error-port force-output output-port-width
          tmpnam delete-file
          ;; FORMAT seems to assume ASCII encoding ...
          char->integer integer->char
          )
  (open ascii                           ; ascii->char char->ascii
        scsh-level-0
        scheme)
  (begin
    (define (provide x) #f)
    (define (require x) #f)
    (define (provided? key)
      (case key
        ((inexact complex) #t)
        (else #f)))
    ;; taken from scsh.init (and modified)
    (define (output-port-width . arg) 79)
    (define (tmpnam)
      (create-temp-file "slib_"))
    (define slib:tab (ascii->char 9))
    (define slib:form-feed (ascii->char 12))
    (define slib:error error)
    ;; quite annoying, see comment in the interface form
    (define integer->char ascii->char)
    (define char->integer char->ascii)
    ))

(define-structure slib-genewrite slib-genewrite-iface
  (open slib-cruft scheme)
  (files genwrite))

(define-structure slib-strcase slib-strcase-iface
  (open slib-cruft scheme)
  (files strcase))

(define-structure slib-strport slib-strport-iface
  (open slib-cruft scheme)
  (files strport))

(define-structure slib-pp (export pretty-print)
  (open slib-genewrite
        slib-cruft 
        scheme)
  (files pp))

(define-structure slib-format (export format)
  (open slib-pp
        slib-strcase slib-strport
        slib-cruft
        nary-mindiv
        scheme)
  (files format))

(define-structure slib slib-iface
  (open slib-cruft
        slib-genewrite
        slib-strcase slib-strport
        slib-format slib-pp
        nary-mindiv))

<Prev in Thread] Current Thread [Next in Thread>
  • slib, Ed Kademan
    • Re: slib, Rolf-Thomas Happe
      • Re: slib, Rolf-Thomas Happe <=