On Thu, Aug 22, 2013 at 6:39 PM, John Cowan <[email protected]> wrote:
> Michele La Monaca scripsit:
>
>> I think eval usage (and limitations) can be avoided: For example:
>>
>> (define-syntax eping
>> (syntax-rules ()
>> ((_ h)
>> (handle-exceptions exn
>> (_eping (symbol->string '|h|))
>> (let ((t h)) (_eping t))))))
>
> That traps all exceptions, not just undefined-variable ones. In
> addition, you need to quote the use of h in the last line, as
> it is not a variable.
Nope. That's exactly what I want to test (ie. whether h is a variable or not).
An implementation of my bound? predicate is possibly this macro
(define-syntax bound?
(syntax-rules ()
((_ exp) (handle-exceptions exn #f (atom? exp) #t))))
consequently the eping macro becomes something like that:
(define-syntax eping
(syntax-rules ()
((_ h)
(if (bound? h)
(_eping h)
(_eping (symbol->string 'h))))))
This way all these cases are encompassed:
(define host "example.com")
(eping host)
(eping "localhost")
(eping "127.0.0.1")
(eping (string-append "127.0.0." "1"))
(eping localhost)
(eping example.com)
(eping 127.0.0.1)
with the caveat that the last one is not (re)strict(ed) scheme standard.
Thoughts?
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users