[plt-scheme] Re: Style question

From: Tomasz Skutnik (tomasz.skutnik at gmail.com)
Date: Wed Jun 3 03:23:54 EDT 2009

>
> Well, if your concern is the end user, then the names that are used
> internally are irrelevant.  The debugging information is more
> important to you, the author of the code, so in that sense it is even
> better to get a "more correct" error message.  In other words, if I
> have this:
>
>  #lang scheme
>  (provide foo)
>  (define (foo x) ...stuff...)
>
> then as the author, I can just as well change it to:
>
>  #lang scheme
>  (provide foo)
>  (define (foo x) (bar x))
>  (define (bar x) ...stuff...)
>
> without thinking about the fact that the tail call mean that now
> errors will show `bar' -- the name is something that is relevant only
> to me.  In the same way, I think that there is no harm in
>
>  #lang scheme
>  (provide (rename-out [create-foo make-foo]))
>  (define-struct foo (x y z))
>  (define (create-foo ...) ... make-foo ...)
>
> since I could just as well do this:
>
>  #lang scheme
>  (provide make-foo)
>  (define-struct internal-foo (x y z))
>  (define (make-foo ...) ... make-internal-foo ...)
>
> There is a minor issue here with values printed as #<internal-foo>
> which is easily solved by either a custom writer, or some possible
> future extension (which should really be implemented, IMO):
>
>  #lang scheme
>  (provide make-foo)
>  (define-struct foo (x y z) #:constructor-name make-foo*)
>  (define (make-foo ...) ... make-foo* ...)
>

Thanks for clarification Eli. That expanded my understanding of the
naming problem. However, as I see it, the main issue is not with error
reporting during bug hunt (where "more correct" name is desirable).
It's about signaling of missing keyword parameters on function
invocation - which IMHO is rather common programming mistake.

For me, the best option would be using procedure-rename, if it would
retain keyword parameters. Otherwise, I'll stick with my original
create-pool, because it's name/purpose is equally clear and error
reporting is less conceptual burden for end-user (i.e. noticing at a
glance what procedure is missing what parameters, even if that
end-user is only me after 6 months into a project). Thanks anyway, all
of you have been very helpful.

Tomasz


Posted on the users mailing list.