guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

integer? as generic function


From: Marco Maggi
Subject: integer? as generic function
Date: Fri, 19 May 2006 20:50:50 +0100

Ciao,

  when I execute The Code:

(define-generic   gee-gmp-oop-integer?)

(let ((integer? integer?))
  (define-method (gee-gmp-oop-integer? (o <number>))
    (integer? o)))

(set! integer? gee-gmp-oop-integer?)

in a script I get no error.

If I put The Code in a module and then load it in a
script, I get no error.

If I put The Code in a module and load it from a
module, loaded from a script, I get:

Backtrace:
In unknown file:
   ?: 10  (let ((var1 #) (var2 #)) (if (not #) (begin # #)))
    ...
   ?: 11  (begin (if # #) (let* # #))
   ?: 12* (if (not duplicates-interface) (begin # #))
   ?: 13  (begin # #)
   ?: 14* (set! duplicates-interface
(make-duplicates-interface))
   ?: 15* [make-duplicates-interface]
   ?: 16  (let* ((m #)) (set-module-kind! m (quote
custom-interface)) ...)
   ?: 17* [make-module]
   ?: 18  (letrec (#) (if # #) (let # # # ...))
   ?: 19  (let (# # #) (if # #) (if # #) ...)
   ?: 20* (if (not (integer? size)) (error "Illegal size to
make-module." size))
   ?: 21* [not ...
   ?: 22* [gee-gmp-oop-integer? 31]
   ?: 23*
Exception during displaying of backtrace: misc-error

<unnamed port>: In procedure gee-gmp-oop-integer? in
expression (integer? (cadddr x)):
<unnamed port>: mutex already locked by current thread

the line that causes the error is:

(set! integer? gee-gmp-oop-integer?)

if I comment it out the module loads, but I cannot
define the generic method. Trying to define a generic
method without "the trick" I get:

#<primitive-procedure integer?> is not a valid generic function

When I import the modules I use:

(define-module (gee gmp mpfr-oop)
  #:use-module (srfi srfi-10)
  #:use-module (ice-9 syncase)
  #:use-module (ice-9 optargs)
  #:use-module ((gee gmp mpfr)
                #:renamer (symbol-prefix-proc 'smob-))
  #:duplicates merge-generics
  #:use-module (oop goops)
  #:use-module (gee gmp oop)
  #:esport (...))

(gee gmp oop) is the module that contains The Code,
and in the script:

(define-module (mpfr-goops-test)
  #:use-module (gee gmp mpfr-oop)
  #:duplicates merge-generics)

The modules (mpfr-goops-test) and (gee gmp mpfr-oop)
have no opportunity do to anything, because the error
happens when #:use-module loads (gee gmp oop).

Is there a way to circumvent that problem (whatever
it is) and have INTEGER? as generic function?

I'm using the same code with a number of other
functions (nan?, inf?, abs, round, sin, cos, ...)
but INTEGER? is the only one that causes problems.

--
Marco Maggi






reply via email to

[Prev in Thread] Current Thread [Next in Thread]