How can I check if a symbol is bound to a value? I would like to do this:
(define host "example.com") (eping host) ; host is evaluated (eping localhost) ; localhost is treated as a symbol with a macro like that: (define-syntax eping (syntax-rules () ((_ h) (if (and (symbol? 'h) (bound? 'h)) (_eping h) (_eping (symbol->string '|h|)))))) Trying to evaluate the symbol seems to be an option: (handle-exceptions exn-unbound (set! host (symbol->string '|h|)) (eval 'h) (set! host h)) but maybe there's a better way. On Thu, Aug 22, 2013 at 12:24 PM, Michele La Monaca <mikele.chic...@lamonaca.net> wrote: > Forget the previous macro. Hopefully this one will do the intended job. > > (define-syntax eping > (syntax-rules () > ((_ h) > (_eping (symbol->string '|h|))) > ((_ h p1 p2 ...) (_eping (symbol->string '|h|) 'p1 p2 ...)))) > > > On Thu, Aug 22, 2013 at 11:29 AM, Michele La Monaca > <mikele.chic...@lamonaca.net> wrote: >> On Wed, Jun 26, 2013 at 2:22 PM, John Cowan <co...@mercury.ccil.org> wrote: >>> Michele La Monaca scripsit: >>> >>>> Happy pinging. >>> >>> Cool! >>> >>> I made a minor documentation change on the wiki to encourage strings over >>> symbols as hostnames, and to remove the suggestion to use dotted-decimal >>> symbols like '192.168.1.1. Such a symbol violates both R5RS and R7RS, >>> is not portable, and might stop working some day. (You could write it as >>> '|192.168.1.1|, but that is more verbose than the string form.) >> >> What about redefining eping as a macro to call the real eping function >> (_eping)? >> >> (define-syntax eping >> (syntax-rules () >> ((_ h p ...) (_eping (symbol->string '|h|) 'p ...)))) >> >> This way you can simply: >> >> (eping 192.168.1.1) >> >> or >> >> (eping example.com) >> >> Thoughts? >> >> Ciao, >> Michele _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users