On Mon, Jun 6, 2011 at 9:21 AM, Patrick Walton <[email protected]> wrote:
> 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. If you get type-inferred lambdas then does this case become more common? > > 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. > I think I would be ok with this if we have pattern matching so that I can name the tuple components. Is that a planned feature for Rust? > 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. I want to avoid the case of coming up with awkward names for these types which are local to a particular module or function. -Rob
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
