This may be of interest to you:
http://stackoverflow.com/questions/20076868/how-to-know-whether-a-racket-variable-is-defined-or-not

For methods, you can use this instead:
http://docs.racket-lang.org/reference/objectutils.html?q=method-in#%28def._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._method-in-interface~3f%29%29

For fields you can use:
http://docs.racket-lang.org/reference/objectutils.html?q=method-in#%28def._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._field-names%29%29

On the contrary to undefined identifiers, using an inexistant method will
not cause any error until it is called.

Laurent

On Sun, May 24, 2015 at 8:20 AM, Michael Tiedtke <
michael.tied...@o2online.de> wrote:

> I'm used to check for the presence of a definition of a given symbol with
>  (defined? symbol)
>
> Probably I still remember that from GNU Guile Scheme but I was not able
> to find an equivalent in Racket.
>
> I need something like that to check during runtime or at least at start-up
> for the existence of a definition before using it.  In particular I will
> need to
> *check for the presence of a given field or method by name/symbol* in
> an interface / class definition imported via require.
>
> Any ideas on how to do this with Racket?
>
> Then I'm afraid that Racket is going to lament the usage of an undefined
> symbol even though that part of code might never be reached because
> I had already checked for the presence of its definition.
>
> Example:
> In version 6.7 the /card-table/ class features a flag
> /call-handlers-after-snap-back/
> but version 6.5 does not have that flag. When the flag and its
> corresponding accessors
> are available it should use them, i.e. branch into parts of the code that
> can use them. If
> not they're not available it should ignore some parts / branches of the
> code.
>
> I can of course use /version/ to check for Racket's version but this
> doesn't take
> patches or third party libraries/modules into account.
>
> --
> 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