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

Re: predicate->char-set considered harmful



   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"
   problem?

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

   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 ...

Yep, the spec doesn't give you any of these guarantees.

Don't fight the system. Be one with the system.
    -Olin