[racket] P4P

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Sun Sep 19 18:09:20 EDT 2010

I know I'm in the minority, but I would love early support for
contracts. I'm not sure how to fit it in the syntax you've got so far,
but something like

deffun: copy(img, num) =
    with-contract: image?, number? -> image
    if: numeq(num, 1)
        img
    else:
        beside(img, copy(img, -(num, 1)))

would be nice. By, the way, why'd you decide on "numeq" instead of
"number=?". Or, alternatively, why not use "as:" in place of the "="
in the first line and then you can use "=" as a function on numbers.

If I had my druthers, I'd fake run-time types by defining Image and
Number as image? and number? in the student languages, but only allow
them in contracts, but that's secondary to providing run-time checking
of argument types *before* we call other functions that might trigger
errors. Since we don't have stack traces in student languages, knowing
the first point at which a contract violation occurred would be a
godsend.

Todd

On Sat, Sep 18, 2010 at 2:30 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> For those of you who might be interested, I've been continuing to work
> on the P4P syntax experiment.  You can get it from github.  The code:
>
> http://github.com/shriram/p4p/
>
> The docs:
>
> http://shriram.github.com/p4p/
>
> I'm slowly growing this towards the full student languages.  Feature
> requests, etc., welcome.
>
> Shriram
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>


Posted on the users mailing list.