[plt-dev] some Racket proposals & implementation

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sat Apr 3 22:31:32 EDT 2010

On Sat, Apr 3, 2010 at 8:14 PM, Eli Barzilay <eli at barzilay.org> wrote:
> On Apr  3, Sam Tobin-Hochstadt wrote:
>> On Sat, Apr 3, 2010 at 10:01 PM, Eli Barzilay <eli at barzilay.org> wrote:
>> >
>> >> They are not anywhere close to easily-enough distinguishable that they
>> >> should be the same form.  This is just asking for confusion.
>> >
>> > I'm talking about the one that looks like a lambda:
>> I know.  I think these look *much* too similar:
>> (define-struct (m x y))
>> (define-struct m (x y))
>> since they have *totally* different semantics.
> Unless Jay added something that I didn't see, they don't have
> different semantics -- the only difference is in the names that get
> bound (`m' vs `make-m').  And from a user perspective, the similarity
> to a function definition makes it natural to expect the first form to
> bind `m'.
> If anything, then this is what I think could be confusing (also not
> because of different semantics):
>  (define-struct (m n) (x))
>  (define-struct (m x))
> but even that kind of confusion can be rare -- it should be easy to
> see what it is if there is more than one field, or with the name of
> the struct that is usually very different from the name of a field.

I don't like supporting both because it makes errors become usages of
the other form.

If I write (define-struct (child parent)) [forgetting the field
names], I've just made a struct named 'child' with a field 'parent'.

If I write (define-struct (struct field1) (field2)) [inserting another
list somehow], I've just made a struct 'struct' with parent 'field1'
and field 'field2'.

That confusion seems bad to me.


Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the dev mailing list.