chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] regex diff + how to check for foreign type?


From: felix
Subject: Re: [Chicken-users] regex diff + how to check for foreign type?
Date: Fri, 22 Nov 2002 11:30:51 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529

Joerg F. Wittenberger wrote:
Hi all,

it occured to me that the chicken regex module doesn't allow to
precompile regualr expressions.  Here some modifications which
apparently work.  Coding took me to the question how do I check for a
foreign type.  This code allows to use strings or precompiled regular
expressions.  But it only checks for strings and assumes otherwise the
argument to be a precompiled expression.  How could I improve the
situation?


You could check for a foreign-pointer object. But safer would be
to wrap the pointer in a record:

(define-record compiled-regex ptr)

...
(set! regex-compile
  (lambda (str) (make-compiled-regex (##regexp#compile str)) )
...

  (cond [(compiled-regex? x) ...]
        [(string? x) ...]
        [else <error>...] )


Thanks for the code, I'll check this out and add it to the
regex unit, if possible.


cheers,
felix






reply via email to

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