Regarding Object Oriented Programming F #

This dichotomy is how we can create classes in f # that really bother me. I can create classes using either implicit or explicit. But some of the features that I want are only available for use with an implicit format, and some are only available for use with an explicit format.

For example:

  • I cannot use only let inline* (or let) inside an explicitly defined class.

  • The only way (I know) to define immutable public fields (not properties *) inside an implicitly defined class is through syntax val bla : bla.

    But there is redundancy. Since in the end I get two copies of the same immutable data, one private, one public (because in implicit mode the constructor parameters are preserved throughout the entire existence of the class)

  • (Not so important) The need to use attributes for method overloading and for default values ​​for fields is rather not used.

Is there any way around this?

* For performance reasons

EDIT: It turns out I'm wrong on both points (thanks to Ganesha Sittampalam and MichaelGG).

  • Although I cannot use let inlineboth in the explicit and in the explicit definition of the class, I can use it member inlinejust fine, which I suppose does the same.

  • Apparently, with the last F # there is no more redundancy, since any parameters not used in the class cube are local to the constructor.

  • F #.

+5
2

, inline. " inline private" .

+5

let inline , , . , .

+1

All Articles