chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] read-byte, etc.


From: Alex Shinn
Subject: Re: [Chicken-users] read-byte, etc.
Date: Wed, 29 Mar 2006 19:06:40 -0600
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI)

At Thu, 30 Mar 2006 02:42:36 +0200, Hans Bulfone wrote:
> 
> i'm porting the rfc.mime library from gauche to chicken.
> 
> in the library the procedures read-byte, peek-byte and
> write-byte are used to read/write bytes which are given
> as integers.
> 
> at the moment, i'm using
> 
> (define (read-byte . args)
>   (let ((ch (apply read-char args)))
>     (if (eof-object? ch)
>         ch
>         (char->integer ch))))
> 
> and similar definitions which seem to work, but i wonder
> if they are still correct with the utf8 egg.

The utf8 egg is a syntax-case module, so even if some other module is
using it, your code will see the original READ-CHAR.

People can (import utf8) into the top-level if they want, but this
isn't always guaranteed to play well with other people's code.  If you
want to guard against this you can:

(define read-byte
  (let ((read-char read-char))
    (lambda args
      (let ((ch (apply read-char args)))
        (if (eof-object? ch)
          ch
          (char->integer ch))))))

which will do the right thing no matter what.

-- 
Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]