[racket-dev] [plt] Push #27090: master branch updated

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Jul 7 00:08:19 EDT 2013

Yesterday, Sam Tobin-Hochstadt wrote:
> On Fri, Jul 5, 2013 at 6:50 PM,  <eli at racket-lang.org> wrote:
> >
> >
> > f90fe4c Eli Barzilay <eli at racket-lang.org> 2013-07-05 18:08
> > :
> > | Get rid of the `#:function' keyword.
> > |
> > | These problems are always dealt with via an internal function instead of
> > | making the name argument part of the visible API.
> > :
> >   M pkgs/racket-pkgs/racket-doc/json/json.scrbl | 10 ++------
> >   M racket/lib/collects/json/main.rkt           | 33 +++++++++++++++-----------
> 
> I think we should keep the name argument part of the API.  Imagine
> that I had a another function that used `read-json` or `write-json`
> internally, and I wanted the same good error messages that
> `jsexpr->bytes` has. Then I'd have to either perform string
> replacement on the exception, or create do something else equally
> ugly.

I disagree with keeping this (but not with solving it) for two
different reasons:

1. This is not a problem that is unique to this case, so a local
   solution is best avoided if there's a general one.

2. Generalizing this in some way, ie, adding `#:function' to functions
   that should fake their error messages is bad in exactly the way
   that justifies parameters.

It would be nice to have some way of doing it with contracts, but
that's obviously impractical -- so I think that a good way to solve it
and other such problems is to add a parameter for the name used in
read errors, and making `raise-read-error' behave in a similar way to
`raise-syntax-error' with the parameter used as the `foo:' part of the
error message.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.