You could do it with dynamic-require:

(let ([point-pict (dynamic-require 'plot 'point-pict (λ () #f))])
  (when point-pict
    (point-pict ...)))

-Philip

On Sat, Feb 17, 2018 at 7:57 PM, Alex Harsanyi <alexharsa...@gmail.com>
wrote:

>
> The recent plot library introduces a new function, `point-pict` which is
> not yet available as part of a Racket distribution, and the plot package
> has to be installed separately from GitHub for this function.
>
> In my code I would like to be able to check if this function is available
> before calling it, so my code compiles correctly even if the function is
> not available.  In Emacs Lisp (the only other language I know), I would do:
>
>    (when (fbounp 'point-pict)
>       (funcall 'point-pict ...)
>
> but I did not find anything equivalent for Racket.  Is there a way to to
> get similar functionality in Racket?
>
>
> For reference, the problematic commit is this one:
>
>     https://github.com/alex-hhh/ActivityLog2/commit/
> f2f505409b9ee7f30c77090045f1d6bb6ff1b191
>
> And this is how the build fails:
>
>     https://travis-ci.org/alex-hhh/ActivityLog2/builds/
> 342890465?utm_source=github_status&utm_medium=notification
>
> Note that, in the running application, the problematic function would
> never be called anyway, since the code checks first if the plot package has
> the new functionality by checking for the presence of the
> `set-mouse-event-callback` method in a plot snip object.
>
> Thanks,
> Alex.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to