unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* integer? as generic function
@ 2006-05-19 19:50 Marco Maggi
  0 siblings, 0 replies; 2+ messages in thread
From: Marco Maggi @ 2006-05-19 19:50 UTC (permalink / raw)


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




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


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

* Re: integer? as generic function
@ 2006-05-23 18:58 Marco Maggi
  0 siblings, 0 replies; 2+ messages in thread
From: Marco Maggi @ 2006-05-23 18:58 UTC (permalink / raw)


"marco.maggi-ipsu@poste.it" wrote:
>(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?)

It works if I do this:

     (define saved-integer? integer?)
     (define-generic integer?)
     (define-method (integer? (o <number>))
       (saved-integer? o)))

     (export integer?)

--
Marco Maggi




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


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

end of thread, other threads:[~2006-05-23 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-19 19:50 integer? as generic function Marco Maggi
  -- strict thread matches above, loose matches on Subject: below --
2006-05-23 18:58 Marco Maggi

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).