[plt-scheme] Naming style

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Feb 14 17:08:32 EST 2009

1. is the historically accurate reason.


On Sat, Feb 14, 2009 at 4:04 PM, Eli Barzilay <eli at barzilay.org> wrote:
> On Feb 13, Will Duquette wrote:
>> Warning: I am a clueless newbie when it comes to PLT-Scheme (though I
>> have some slight background with Lisp-like languages).
>> I've just started glancing at "An Introduction to Scheme with
>> Pictures", which uses something called "#lang slideshow".  Almost
>> immediately I see the function "hc-append".  When I go look at the
>> docs, as suggested, I see that it's one of a family of functions, all
>> of which follow this naming convention:
>>     <options>-<operation>
>> Thus, this command appends pictures together horizontally ("h"),
>> centering them vertically. ("c").
>> This strikes me as a very add way to name functions; I'd have
>> thought that having one function, "append", with arguments
>> indicating the alignment, would make more sense.  On the other hand,
>> someone implemented it this way on purpose, and given that it's used
>> in a document for newbies like me I presume it's good style.  Would
>> someone care to explain to me *why* it's good style?
> There are two arguments for this that I can think of (disclaimer: I'm
> not the one who wrote that interface...):
> 1. It was designed before PLT had an organized way for using keyword
>   arguments, which are one of the obvious ways to make a more
>   convenient interface.
> 2. Having separate bindings for `hc-append' and `vc-append' (for
>   example) mean that you'll get feedback of whether you wrote the
>   right thing immediately: if there is no `vc-append' (or if you made
>   some typo) then the code wouldn't even compile, and you'll know
>   that you need to fix it.
>   OTOH, you could have a mode argument, and have `append' check it
>   and either use the mode or throw an error -- that means that you
>   only get an error when you try to run the code.  BTW, there is also
>   an option of:
>     (define (append mode blah ...)
>       (let ([horiz (eq? mode 'horizontal)])
>         ...))
>   which means that a user typo like
>     (append 'horiz)
>   will silently use vertical mode, which can be very confusing.
> --
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                  http://www.barzilay.org/                 Maze is Life!
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.