On 6/6/11 8:29 AM, Rob Arnold wrote:
You can write record types directly in function signatures, right? That
is, can anonymous records can be used across function boundaries? I
think there's good value in not having to name the type.

IMHO, you only get a benefit in not having to name the type if the record type appears exactly once. Otherwise you're scattering the record type definition throughout the code, making it harder to e.g. add new fields if you need to. This is why, in practice, every record in the standard library and rustc has a typedef.

Now that I've had more sleep, I also think that tuples aren't quite a
good general replacement because you lose some documentation (the field
name) when converting from records to tuples. Knowing what x[1] is is
much harder than x.texture. This I definitely encountered in ML all the
time when reading students' compilers (particularly things like the
register allocation and other messy algorithmic stuff).

Tuples aren't a good *general* replacement for records; they're a good replacement for quick one-off records.

If you want the self-documenting aspect of records, then, well, use records :) In fact, having to give each record a name arguably improves their self-documenting nature.

Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to