Re: [racket] Contract for methods with optional arguments

2013-08-31 Thread Robby Findler
You can simulate and ->im with ->i by adding a mandatory (first) argument with contract any/c. Robby On Sat, Aug 31, 2013 at 6:39 AM, Diego Sevilla Ruiz wrote: > Hi all: > > I have encountered a situation in which I don't know how to > specify the contract for a method that: > > 1. Has

Re: [racket] Contract for methods with optional arguments

2013-08-31 Thread Diego Sevilla Ruiz
Hi, Matthias: Yes, you're right about the "sum" types of the domain and range of functions. A small remark below (just to clarify myself too...) On 31/08/13 20:36, Matthias Felleisen wrote: On Aug 31, 2013, at 2:19 PM, Diego Sevilla Ruiz wrote: The example you give for C, you're right, it

Re: [racket] Contract for methods with optional arguments

2013-08-31 Thread Matthias Felleisen
On Aug 31, 2013, at 2:19 PM, Diego Sevilla Ruiz wrote: > The example you give for C, you're right, it is not appropriate for C because > C has a (lax) static type system. Let's call it what it is: unsound. Let's also agree that C's type system is so impoverished that it is simply useless to ta

Re: [racket] Contract for methods with optional arguments

2013-08-31 Thread Diego Sevilla Ruiz
Hi, Greg: On 31/08/13 17:16, Greg Hendershott wrote: If I knew the answer I'd tell you, and hopefully someone else will. Meanwhile, another way you could look at this: If it becomes too difficult to write a contract (or documentation) for a function, it might be good to revise the function. Fo

Re: [racket] Contract for methods with optional arguments

2013-08-31 Thread Diego Sevilla Ruiz
Ah, Matthew, thank you. Exactly what I need. I had the impression that I could use these, but I couldn't find examples in the documentation. Best regards, diego. On 31/08/13 17:53, Matthew Flatt wrote: I think want `case->`: (define/contract get-whatever (case->

Re: [racket] Contract for methods with optional arguments

2013-08-31 Thread Matthew Flatt
I think want `case->`: (define/contract get-whatever (case-> (-> (vectorof integer?)) (-> exact-nonnegative-integer? integer?)) (lambda ([pos #f]) (if (not pos) inner-vector-of-int (vector-ref inner-vector-o

Re: [racket] Contract for methods with optional arguments

2013-08-31 Thread Greg Hendershott
If I knew the answer I'd tell you, and hopefully someone else will. Meanwhile, another way you could look at this: If it becomes too difficult to write a contract (or documentation) for a function, it might be good to revise the function. For example, a function that takes an optional argument th

[racket] Contract for methods with optional arguments

2013-08-31 Thread Diego Sevilla Ruiz
Hi all: I have encountered a situation in which I don't know how to specify the contract for a method that: 1. Has a final optional argument 2. The value of the optional argument makes the method change the return type of the method. It is similar to this: (define/public (get-whatever (po