[plt-scheme] optional arguments in function contracts
HI,
I'm trying to do a contract with an optional argument, but I'm stuck
(and can't find an example in the doc's, tests or 'plt-full' code)
my provide/contract is;
;; write-email accepts an email and optionally an output-port (2 or one args)
(provide/contract
(write-email (email? (or/c none/c output-port?) . -> . any))
)
and my function is
;; write-email : message [output-port] -> void
(define write-email
(lambda (message (out-port (current-output-port)))
(printf "~V:~V~N" message out-port)
)
)
but calling it I get the error; procedure write-email: expects 2
arguments, given 1:
Forgive me if this is a dumb question but I feel I'm missing something
fundamental about how I'm specifying the contract?
Cheers,
Stephen
--
Stephen De Gabrielle
s.degabrielle at cs.ucl.ac.uk
Telephone +44 (0)20 7679 0693 (x30693)
Mobile 079 851 890 45
Project: Making Sense of Information (MaSI)
http://www.uclic.ucl.ac.uk/annb/MaSI.html
UCL Interaction Centre
MPEB 8th floor
University College London
Gower Street
London WC1E 6BT