[racket] 'Adult' Racket? (was rackunit vs test-engine)

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Aug 8 12:24:11 EDT 2012

On Aug 8, 2012, at 11:48 AM, mike at goblin.punk.net wrote:

> On Tue, Aug 07, 2012 at 09:00:19PM -0400, Matthias Felleisen wrote:
>> -- test-engine provides test support for the teaching languages of DrRacket.
>> -- rackunit is for 'adult' programmers, meaning programmers who have outgrown
> teaching languages.
> 
> I wish that I had known about rackunit earlier.  What other
> 'adult' features of Racket should people would you recommend to
> readers of HtDP?

That is a good question. The key step is to think of modules (#lang, provide, require). For that, the most important feature -- other than rackunit -- is the use of checked contracts at module boundaries and the shift of purpose statements from the definition site to the module boundary. This way you can figure out what services the module supports w/o reading its implementation. 

Suppose you are writing a distributed program based on universe in the style of '2e'. You might find yourself writing a *SL program and here is also how to express this as an adult. 

*SL program fragment: 
---------------------

(define s0 ...)
(define s1 ...)

;; S-expression Symbol Symbol -> S-expression 
;; replace old with new in s 

(check-expect (subst s0 'a 'z) s1)

(define (subst s old new) ...)

adult program fragment: 
-----------------------

#lang racket 

;; - 99x 
;; interface 
(provide/contract
  ;; replace old with new in s
  [subst (-> s-expr? symbol? symbol? s-expr?)])

;; - 99x 
;; implementation 

(require 2htdp/universe 2htdp/image rackunit)

(define s0 ...)
(define s0-with-z-for-a ...)

(check-equal (subst s0 'a 'z) s0-with-z-for-a)

(define (subst s old new) ...) 


  
All of this provide/require/contract material is so important that I intend to pull these ideas into *SL. 

-- Matthias

p.s. Note that the checked signatures of DMdA, also available in HtDL *SLs, are distinct from contracts and are distinctly not adult. They are the transition point to Typed Racket. 




-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20120808/e53096a6/attachment.p7s>

Posted on the users mailing list.