Which reserved keyword in the F# language spec sho

2020-06-16 03:10发布

问题:

Now the FSharp v1 has gone into Beta it's time to ask about vNext.

The FSharp language spec defines the following reserved keywords:

atomic break checked component const constraint constructor    
continue eager fixed fori functor include    
method mixin object parallel params process protected pure    
sealed tailcall trait virtual volatile 

which of these would you like to see implemented and why?

One keyword per answer please.

回答1:

trait, assuming trait is something like Scala traits.



回答2:

My vote is for tailcall.

If I understand the intention correctly this would be a keyword to mark recursive functions the author would intend to be tail recursive. If for whatever reason the compiler cannot comply, a diagnostic message can be of great help.

As it stands now if you fail to structure your recursive function properly the first time you will be informed about this is the StackOverflow exception (No pan intended)



回答3:

I'm somehow not able to follow your link, but in case atomic applies to builtin software transactional memory, this is my favorite.



回答4:

Good question but hard to answer. You can't guess exactly the purpose of each reserved keyword, right?

From my perspective, I could see some useful use cases for fixed (fixed size buffers).



回答5:

I'd vote for eager, if it meant that evaluation was lazy by default (like in Haskell, but unlike current F#).



标签: f#