I just finished reading the section on extension members in Framework Design Guidelines 2nd Ed., by Krzysztof Cwalina and Brad Abrams, and didn't find an example for this. My question concerns a super and sub class in an F# library, but I expect the answer is relevant to all .NET languages.
F# has two types, the super type Expr
and the sub type Expr<'a>
where the latter is just a wrapper for a typed version of the former. These are the types used for quotation expressions.
If I wanted to define extension methods on these types for evaluating them, which would be a better design:
EvalUntyped() : Expr -> obj
on Expr
and Eval() : Expr<'a> -> 'a
on Expr<'a>
.Eval() : Expr -> obj
on Expr
and Eval() : Expr<'a> -> 'a
on Expr<'a>
.The second option seems more correct to me, but I'd like to follow whatever design guidelines there may be: is there any authoritative precedence for this (supposing they got it "wrong" in the PowerPack)?
There may not be a definitive answer to this. However, unless you truly believe the F# PowerPack did get the design "wrong", I'd follow their style for two reasons:
Your analogy in your reply to Tomas is a good one, but I'd assume any other developers using this code may not pay as much attention to the design as you have. Best to keep consistent with official style and be explicit in your intentions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With