HackerTrans
热门最新趋势评论往期问答秀出招聘

dfgdghdf

no profile record

评论

dfgdghdf
·5年前·讨论
This! My favourite thing about working with F# is the tiny delta between prototype script and production MVP.
dfgdghdf
·6年前·讨论
The author said in a comment here that it was written for an FP audience.

The example you gave is similar to a discriminated union in ML but it is not as robust because the language will not check that every match expression (probably an if-instanceof-ladder in Java) handles every case.
dfgdghdf
·6年前·讨论
> Every object is (or at least should be) "a description of what to do" in the exact sense you're using here. This is crucial to understand for properly using OOP.

I think you may have missed the point. In most OOP languages, an object exposes some capabilities (methods that can be called, properties that can be read, etc), but it does not describe itself very well at all. This is why we have RTTI, instanceof etc. to switch on what an object is. Alternatively, we can use the visitor pattern. As the OP states, these are not as elegant as DUs and matching.