[Pre-RFC] Associated field/constant accessors in traits

(Disclaimer: Just musing out loud here. Beware undigested thoughts.)

One version might be to use something more pattern-like here. Maybe fields in traits could be exposed more like a view type, so you provide not each field separately, but everything in a particular view together.

That way it would be relatively easy for the compiler to check (it's the same as it already does in a method today) and checking the consumption would be plausible too (as they would need to come from the same view).

Of course, at that point just returning a view type from a method becomes much more similar...

2 Likes