Thanks Georges, Matthias, and Philip for the further pointers:

Helped by your comments I inferred that I could construct a legitimate
unsupplied-arg case using case-lambda.

I think that this is the kind of illustration would be helpful in the docs:


#lang racket

(module server racket
  (provide (contract-out
            [f (->* (number?) (number?) number?)]
            [g (->i ([a real?])
                    ([b real?])
                    (result real?)
                    #:post (a b result)
                    (let ([B (if (unsupplied-arg? b) (default-b) b)])
                      (= (* (sgn a) (sgn B)) (sgn result))))]))

(define (default-b) 10)

(define f (case-lambda
            [(a) (+ a (default-b))]
            [(a b) (+ a b)]))

(define g (case-lambda
            [(a) (* a (default-b))]
            [(a b) (* a b)])))



(require 'server)

(f 10)
(f 10 -5)

(g 10)
(g 10 -5)

I suppose this falls into the class of learning challenges where certain
aspects of the design of a feature are explained by the existence of
"advanced" concepts that not everyone may be yet using routinely, or even
be familiar with.

Dan

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

Reply via email to