Re: [racket-users] How to specify fallbacks for generic interfaces without going into an infinite loop?

2015-07-06 Thread Jon Zeppieri
Use define/generic:

#lang racket/base

(require racket/generic)

(define-generics foo
  (a foo) (b foo) (c foo)
  #:fallbacks
  [(define/generic gen-a a)
   (define/generic gen-b b)

   (define (a foo)
 (displayln a-fallback)
 (gen-b foo))
   (define (b foo)
 (displayln b-fallback)
 (gen-a foo))])

(struct foo-struct ()
  #:methods gen:foo
  [(define (a foo) 1)])

(b (foo-struct))


On Mon, Jul 6, 2015 at 9:50 PM, Alexander D. Knauth
alexan...@knauth.org wrote:
 What is the proper way to do this?

 This goes into an infinite loop:

 #lang racket/base

 (require racket/generic)

 (define-generics foo
   (a foo) (b foo) (c foo)
   #:fallbacks
   [(define (a foo)
  (displayln a-fallback)
  (b foo))
(define (b foo)
  (displayln b-fallback)
  (a foo))])

 (struct foo-struct ()
   #:methods gen:foo
   [(define (a foo) 1)])

 (b (foo-struct))


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


[racket-users] How to specify fallbacks for generic interfaces without going into an infinite loop?

2015-07-06 Thread Alexander D. Knauth
What is the proper way to do this?

This goes into an infinite loop:

#lang racket/base

(require racket/generic)

(define-generics foo
  (a foo) (b foo) (c foo)
  #:fallbacks
  [(define (a foo)
 (displayln a-fallback)
 (b foo))
   (define (b foo)
 (displayln b-fallback)
 (a foo))])

(struct foo-struct ()
  #:methods gen:foo
  [(define (a foo) 1)])

(b (foo-struct))


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


Re: [racket-users] How to specify fallbacks for generic interfaces without going into an infinite loop?

2015-07-06 Thread Alexander D. Knauth
Thanks!

On Jul 6, 2015, at 9:53 PM, Jon Zeppieri zeppi...@gmail.com wrote:

 Use define/generic:
 
 #lang racket/base
 
 (require racket/generic)
 
 (define-generics foo
  (a foo) (b foo) (c foo)
  #:fallbacks
  [(define/generic gen-a a)
   (define/generic gen-b b)
 
   (define (a foo)
 (displayln a-fallback)
 (gen-b foo))
   (define (b foo)
 (displayln b-fallback)
 (gen-a foo))])
 
 (struct foo-struct ()
  #:methods gen:foo
  [(define (a foo) 1)])
 
 (b (foo-struct))
 
 
 On Mon, Jul 6, 2015 at 9:50 PM, Alexander D. Knauth
 alexan...@knauth.org wrote:
 What is the proper way to do this?
 
 This goes into an infinite loop:
 
 #lang racket/base
 
 (require racket/generic)
 
 (define-generics foo
  (a foo) (b foo) (c foo)
  #:fallbacks
  [(define (a foo)
 (displayln a-fallback)
 (b foo))
   (define (b foo)
 (displayln b-fallback)
 (a foo))])
 
 (struct foo-struct ()
  #:methods gen:foo
  [(define (a foo) 1)])
 
 (b (foo-struct))
 
 
 --
 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.