[CM] determining existence of function

rm@fabula.de rm@fabula.de
Sat, 2 Oct 2004 17:14:33 +0200


On Sat, Oct 02, 2004 at 03:20:48AM -0400, Terrence Brannon wrote:
> I defined the function row->matrix via C-x C-e and then went to the 
> Listener and attempted to verify that I did by typing row->matrix into the 
> Listener window. With most Schemes I have used, I get something like:
> #<function row->matrix>
> 
> But with guile-scheme I got this:
> 
> CM[1]>
> CM[2]>
> CM[3]> row->matrix
> 
> *** - EVAL: variable ROW->MATRIX has no value

??? That doesn't look like Guile at all! That looks like some
sort of LISP.

> The following restarts are available:
> STORE-VALUE    :R1      You may input a new value for ROW->MATRIX.
> USE-VALUE      :R2      You may input a value to be used instead of 
> ROW->MATRIX.
> 
> *** - UNIX error 13 (EACCES): Permission denied
> The following restarts are available:
> STORE-VALUE    :R1      You may input a new value for ROW->MATRIX.
> USE-VALUE      :R2      You may input a value to be used instead of 
> ROW->MATRIX.

Bo, that's a condition system unheard of in Guile - CLISP maybe?

> 
> Break 1 CM[4]> (pprint (row->matrix albans-row))
> 
> ((0 3 7 11 2 5 9 1 4 6 8 10) (9 0 4 8 11 2 6 10 1 3 5 7)
>  (5 8 0 4 7 10 2 6 9 11 1 3) (1 4 8 0 3 6 10 2 5 7 9 11)
>  (10 1 5 9 0 3 7 11 2 4 6 8) (7 10 2 6 9 0 4 8 11 1 3 5)
>  (3 6 10 2 5 8 0 4 7 9 11 1) (11 2 6 10 1 4 8 0 3 5 7 9)
>  (8 11 3 7 10 1 5 9 0 2 4 6) (6 9 1 5 8 11 3 7 10 0 2 4)
>  (4 7 11 3 6 9 1 5 8 10 0 2) (2 5 9 1 4 7 11 3 6 8 10 0))
> 
> Break 1 CM[4]>
> 
> ====
> the fact that I can run the function implies that the C-x C-e on the 
> function definition did in fact define it. However, I do not understand why 
> I could test for the existence of the function by typing it into the REPL.

Iff this is in fact a LISP you are working with you can try:

 CM[1]> #'row->matrix 

 
which is just a convenient reader macro for

 CM[2]> (symbol-function 'row->matrix)

HTH Ralf Mattes