[racket-dev] API naming conventions (Push #25466)

From: Michael Wilber (mwilber at uccs.edu)
Date: Wed Oct 17 12:54:33 EDT 2012


I wonder if we couldn't find a way to mirror the distinction between
(define x ...) and (define (x) ...) somehow, combining the functionality
of match-define and define/match. After all, we don't have define-var
and define-fun, right?

(match/define (list x y z) '(1 2 3))

x --> 1

(match/define (do-x (list 2 _ y))
  (list 1 2 y))

(do-x '(2 3 4)) --> '(1 2 4)

where the second one expands into
(define do-x (match-lambda [(list 2 _ y) ...]))
or something like that. Too bad there's ambiguity...

Robby Findler <robby at eecs.northwestern.edu> writes:
> For the record, I find having two things that combine match and define
> in different ways where the name difference is - vs / and swapping the
> order of the words to be quite unfortunate.
> Plus, we should just have match built into all of the binding forms.
> Robby
> On Tue, Oct 16, 2012 at 5:48 PM, Eli Barzilay <eli at barzilay.org> wrote:
>> A few minutes ago, Matthias Felleisen wrote:
>>> Eli, can you explain again -- perhaps in different words -- why
>>> define/match is a bad name? I understand that we have match-define
>>> and define/match now. While I agree that having two of these forms
>>> with remotely related functionality is possibly confusing, I don't
>>> see why match-define is really a better kind of name than
>>> define/match.
>> Well, I suggested `match-define' (before I realized that there was
>> already one) because it follows the same naming convention for the
>> rest of the library.
>>> If you are saying, that define/match is bad because it is too
>>> distinct from match-define I understand the name argument.
>> If that was the only issue, then I wouldn't have objected so strongly
>> to it -- but the fact that there *is* an existing `match-define', and
>> the fact that it does something different, mean that the match
>> interface becomes extremely confusing.  And that's not only for
>> newbies -- I can easily see myself not remembering which one of them
>> is doing which job.
>> A bit later, John Clements wrote:
>>> Violent agreement; I'm saying that the *names* are the same (modulo
>>> a stylistic choice), not that the meanings are the same.
>> As for an attempt to explain why they're a bad combination, John
>> indeed put it nicely here.  We have two forms whose meaning is a
>> combination of a `define' and a `match', and hanging the difference on
>> the order of the two terms (and a `/' vs a `-') means that for human
>> readers, the difference is far from apparent.
>> And Matthias Felleisen added:
>>> (I really dislike match-define. But it's historic so we're stuck.)
>> I completely agree -- I'd prefer a `define-match' or a `define/match',
>> in the same way that I'd also prefer a `let-match' etc.  (And I also
>> agree that the historic choice is an important restriction.)
>> --
>>           ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>>                     http://barzilay.org/                   Maze is Life!
>> _________________________
>>   Racket Developers list:
>>   http://lists.racket-lang.org/dev
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.