[racket] contracts ->i optional keyword syntax

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Aug 24 17:09:18 EDT 2014

On Aug 24, 2014, at 4:59 PM, Kevin Forchione wrote:

> 
> On Aug 23, 2014, at 10:24 PM, dfeltey at ccs.neu.edu wrote:
> 
>> Keywords should be followed by an id+ctc as described in the documentation, so something like the following should work
>> 
>> (->i ([lst list?])
>>       (#:foo [foo (lst) foo?])
>>      (result list?))
>> 
>> 
>> Hope this helps
>> Dan
> 
> Yes, neither reference nor guide provided an example for this case, and it seems I need to get more familiar with the BNF notation of the reference! 
> 
> Even after more than 30 years in computer programming I find the journey continues to be one of simultaneously pulling oneself up by one’s bootstraps while shrinking the wholes in the swiss cheese of my knowledge, with the haunting suspicion that I’ve somehow failed to grasp some vital concepts that elude me like Monty Python’s Holy Grail. So in that quest every little helps. :)


Before you make fondue, ask. As you can see, people answer and answer quickly. Indeed, Robby added an example to the Guide as he responded and pushed it out into the repo. The next release will have an example due to your posts. Thanks! 

Having said that, Racket is created by people who focus on systematic design of software. The contract system is an example of this; 

 -- it serves the purpose of creating software systematically (continuing the so-called Design by Contract line of work) 
 -- it itself is developed systematically with inquires into the semantics of contracts because we took contracts way beyond the primitive notion from the 1980s and 1990s. 

But, the existence of ->i and ->d should give you a hint that we occasionally make mistakes and we try to correct them without modifying existing code. ->d is mostly okay, but ->i is better. When Robby created ->i, he also used his experience with ->d to force programmers to list dependency variables explicitly. That's why you have to say "(lst)", for example. In addition, the language grows and with it, we have to grow the contract system. Keyword arguments is an example of that kind. 

As for the philosophy behind our contract system, I think the guide's opening section on boundaries brings across the idea that separates our contracts from old-style stuff. It may not become immediately clear, but when you program with contracts for a while, you will appreciate it. 

-- Matthias




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140824/441b08f7/attachment-0001.html>

Posted on the users mailing list.