My comments may not be that relevant to rust as I haven't been following in 
detail, so please ignore if they aren't - but at the moment I write quite long 
functions that do a lot of transformations of data in ocaml - lists of data, 
pipelines of maps, folds, etc. The inability to have lightweight anonymous 
records means that I end up often using lists of tuples where lists of records 
would be preferable. In these cases the record type would only exist for the 
lifetime of the next map or fold, and the overhead of a type declaration 
(including thinking up a name) is too cumbersome.

Stefan

> Date: Sun, 5 Jun 2011 23:10:10 -0700
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> Subject: Re: [rust-dev] Proposal: nominal records
> 
> On 6/5/11 11:00 PM, Rob Arnold wrote:
> > I am sad to see anonymous records go since I use them frequently in my
> > ML and JavaScript programs where giving a type a name doesn't make sense
> > (perhaps if there's no type inference at function boundaries this
> > doesn't matter). Tuples obviously make sense in the vector example you
> > gave (which is what I usually point to as a use case for anonymous
> > records) but tuples don't handle the cases where the type changes over
> > time (specifically dropping fields). Also sometimes it's just awkward to
> > give a name to a type; this is one my frustrations with C-like languages.
> 
> Oh, I actually think anonymous records are a perfect fit for fully 
> type-inferred languages like ML. I miss SML's anonymous records a lot in 
> OCaml. It's just that in practice, every Rust record gets a name via a 
> typedef, since they spill across function boundaries so often and we 
> have to annotate function signatures.
> 
> Your point about dropping fields is interesting; in what kinds of 
> situations have you wanted to drop record fields?
> 
> Patrick
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
                                          
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to