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

Re: predicate->char-set considered harmful

This page is part of the web mail archives of SRFI 14 from before July 7th, 2015. The new archives for SRFI 14 contain all messages, not just those from before July 7th, 2015.

>    From: Brad Lucier <lucier@xxxxxxxxxxxxxxx>
>    >    I hope you don't try to define predicate->bitset in a later SRFI ;-).
>    > 
>    > Well, I guess it's too late to put it into the lset-... suite of
>    > operations in SRFI 1...
>    My unstated (definitely understated) point is that predicate->bitset
>    will never return in the general case, which isn't much different from
>    how long it will take predicate->char-set to return on systems that use
>    a four-byte character representation.
> Yep, I understood. Just a little bit of wry academic humor there, on my
> part.
> Clearly people who use 4-byte char types will have to stear clear of
> ops that are linear in the type size.
>     -Olin

I'm trying to think of a way to embed an escape procedure into
predicate->char-set[!].  Is the following legal?  Does it solve
the "I only want to examine ASCII characters to build this set"

(define cs
  (let ((result (char-set)))
     (lambda (exit)
       (predicate->char-set! (lambda (ch) (or (char=? ch #\newline)
					      (and (> (char->integer ch) 127)

I suppose one would need a guarantee that characters are examined in
(char->integer ch) order, and it would have to add the character to
result immediately when the predicate returned true, and it isn't
linear update, and ...

Oh well.