unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* How do I determine if a function is defined?
@ 2002-04-28 18:05 Bruce Korb
  2002-04-28 19:15 ` Clinton Ebadi
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Korb @ 2002-04-28 18:05 UTC (permalink / raw)



Hi,

I keep trying obvious things, like:

  (if (function? mumble) (mumble))

and get:

  ERROR: Unbound variable: mumble

and then it dies.  I just want to do one thing if it is
a function and another if it is either undefined or even
anything else.  How to do that seems completely non-obvious.
Thank you.

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I determine if a function is defined?
  2002-04-28 19:58   ` Bill Gribble
@ 2002-04-28 19:09     ` Bruce Korb
  2002-04-29  1:28       ` Rob Browning
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Korb @ 2002-04-28 19:09 UTC (permalink / raw)
  Cc: Clinton Ebadi, guile-devel

Bill Gribble wrote:
> 
> On Sun, 2002-04-28 at 14:15, Clinton Ebadi wrote:
> > Try (if (procedure? 'mumble) (mumble)). Remember to quote the variable you
> > want to test!
> 
> No, (procedure? 'mumble) is always #f, because 'mumble is a symbol, not
> a procedure, even if there is a procedure bound to the variable mumble.
> 
> What are you trying to do in the larger scheme of things?  It's pretty
> darn unusual to really need to write code that doesn't know which
> symbols are bound.  And sketchy.

I have a program that defines the procedure ``set-writable''

 http://www.gnu.org/manual/autogen-5.3.6/html_chapter/autogen_3.html#SEC62

but I added that procedure only recently.  I want to use it if it is
available, but skip it if it is not.  That way, I do not require
that people have an AutoGen version more recent than a year old.

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I determine if a function is defined?
  2002-04-28 18:05 How do I determine if a function is defined? Bruce Korb
@ 2002-04-28 19:15 ` Clinton Ebadi
  2002-04-28 19:58   ` Bill Gribble
  0 siblings, 1 reply; 6+ messages in thread
From: Clinton Ebadi @ 2002-04-28 19:15 UTC (permalink / raw)


On Sunday 28 April 2002 14:05, Bruce Korb wrote:
> Hi,
>
> I keep trying obvious things, like:
>
>   (if (function? mumble) (mumble))
>
> and get:
>
>   ERROR: Unbound variable: mumble
>
> and then it dies.  I just want to do one thing if it is
> a function and another if it is either undefined or even
> anything else.  How to do that seems completely non-obvious.
> Thank you.

Try (if (procedure? 'mumble) (mumble)). Remember to quote the variable you 
want to test!

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I determine if a function is defined?
  2002-04-28 19:15 ` Clinton Ebadi
@ 2002-04-28 19:58   ` Bill Gribble
  2002-04-28 19:09     ` Bruce Korb
  0 siblings, 1 reply; 6+ messages in thread
From: Bill Gribble @ 2002-04-28 19:58 UTC (permalink / raw)
  Cc: Bruce Korb, guile-devel

On Sun, 2002-04-28 at 14:15, Clinton Ebadi wrote:
> Try (if (procedure? 'mumble) (mumble)). Remember to quote the variable you 
> want to test!

No, (procedure? 'mumble) is always #f, because 'mumble is a symbol, not
a procedure, even if there is a procedure bound to the variable mumble. 

What are you trying to do in the larger scheme of things?  It's pretty
darn unusual to really need to write code that doesn't know which
symbols are bound.  And sketchy. 

b.g.







_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I determine if a function is defined?
  2002-04-28 19:09     ` Bruce Korb
@ 2002-04-29  1:28       ` Rob Browning
  2002-04-29  1:34         ` Bruce Korb
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Browning @ 2002-04-29  1:28 UTC (permalink / raw)
  Cc: Bill Gribble, Clinton Ebadi, guile-devel

Bruce Korb <bkorb@pacbell.net> writes:

> I have a program that defines the procedure ``set-writable''
>
>  http://www.gnu.org/manual/autogen-5.3.6/html_chapter/autogen_3.html#SEC62
>
> but I added that procedure only recently.  I want to use it if it is
> available, but skip it if it is not.  That way, I do not require
> that people have an AutoGen version more recent than a year old.

Try

  (if (defined? 'set-writable)
   ...)

Though you could also handle this during the make process via .in
files if you didn't want to have to run all the conditionals on every
load.

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I determine if a function is defined?
  2002-04-29  1:28       ` Rob Browning
@ 2002-04-29  1:34         ` Bruce Korb
  0 siblings, 0 replies; 6+ messages in thread
From: Bruce Korb @ 2002-04-29  1:34 UTC (permalink / raw)
  Cc: Bill Gribble, Clinton Ebadi, guile-devel

Rob Browning wrote:

> Try
> 
>   (if (defined? 'set-writable)
>    ...)
> 
> Though you could also handle this during the make process via .in
> files if you didn't want to have to run all the conditionals on every
> load.

This is actually used in "make check" for fixincludes for GCC.
If you have the sources, it's the last line of
gcc/fixinc/check.tpl.  :-)  Thanks.

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-04-29  1:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-28 18:05 How do I determine if a function is defined? Bruce Korb
2002-04-28 19:15 ` Clinton Ebadi
2002-04-28 19:58   ` Bill Gribble
2002-04-28 19:09     ` Bruce Korb
2002-04-29  1:28       ` Rob Browning
2002-04-29  1:34         ` Bruce Korb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).