Dev

Microsoft’s F# gets computation expressions enhancement


Microsoft has introduced a while! keyword with its open source F# language, providing a refined approach to loops in computation expressions.

This keyword, spoken as “while bang,” is intended to minimize boilerplate, boost clarity, and enhance expressiveness, Microsoft said in a blog post on September 20. With while!, specifying an asynchronous condition in loops now is feasible. Microsoft cites the elimination of a mutant variable, a reduction in total lines of code, and a decrease in overall cyclomatic complexity as a result of while!. The while! construct does not require a builder method but instead invokes .Bind in the same manner as let! does; so there is no additional work needed when authoring new computation expressions.  Constructs are composable and can be nested.

The while! feature is to be incorporated into F# 8, which is likely to officially arrive this November with the .NET 8 software development platform. Developers can experiment with the capability now using this flag: --langversion:preview. The flag can be passed to the dotnet fsi invocation or inserted into an .fsproj file.

The new keyword was added by an external contributor to the language outside of Microsoft. F# is positioned as a language for writing “performant” code, offering first-class functions, type inference, pattern matching, and object support.

Copyright © 2023 IDG Communications, Inc.



READ SOURCE

This website uses cookies. By continuing to use this site, you accept our use of cookies.