chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] ANN: eping


From: Michele La Monaca
Subject: Re: [Chicken-users] ANN: eping
Date: Thu, 22 Aug 2013 22:15:19 +0200

On Thu, Aug 22, 2013 at 6:39 PM, John Cowan <address@hidden> 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?



reply via email to

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