F# is a great functional language with same access as C# to all .NET resource/eco-system. It is Microsoft’s version of OCaml.
I am not suggesting F# is a necessity inclusion to Elements languages family. I am saying, if and only if RemObjects has the resource and is considering adding a functional language to the Elements languages family, F# IMHO, is a better choice than Erlang. That is all I meant.
Personally, I’d love to see F# to be available on Island platform. But I guess, NOT at the expense compromising the support of my beloved Oxygene!
I think a functional “version” of Oxygene would be good, particularly, the following new language features:
Currying (so we could have functional recursion)
Pattern Matching
Pipe
Additionally, it would be super cool to have F# added to Elements language family, ESPECIALLY, a LLVM-based F# that generates native code. I have always wanted to have a native F# (right now, the WinRT could generate some scope-limited native F# binary, though).
I just realized that all those functional elements are already available in Swift, such as higher order functions, partial function application, currying, pattern matching, and pipe forward operator etc.
And Elements family does support Swift… and for FREE!
I haven’t extensively used RemObjects Swift. Before I delve into it - I guess I have a dumb question: how RemObjects Swift compare to Apple’s original swift? Any “limitations”? Is it a sub-set, or super-set of Apple Swift?
If “sub” set, what is missing? @mh
It has generally good overlap, but both support features the other lacks.
I assume the features of Silver over Apple Swift are well documented in the language extensions section of the docs.
However, while there is a differences and limitations section it inaccurately implies that Apple Swift supports Type Extensions “(a) adding new fields or stored properties” and is incomplete:
I have been submitting bugs for the deficiencies of Silver with respect to Apple Swift, and I list the currently outstanding ones below (to my knowledge none of these are mentioned in the docs currently):
Thank you very much. I guess those functional elements (higher order functions, currying, pattern matching, discriminated union, Pipe forward operator) supported right? I am asking because I will need to port F# code to Swift
not implicitly, but does support closures / anonymous functions with implicit context
pattern matching
in switch, if case and catch statements
support discriminated union
enums with associated values
Pipe forward operator
not natively (unless Silver adds it)
but does support defining both custom operators and operator implementations
using (almost) any string of ascii punctuation (unless Silver doesn’t support such?)
There are half way solutions that can be defined, but no general solution as custom patterns cannot currently introduce variables.
The 2 general categories of half way are either extract into a tuple before matching or matching with a function (cannot create variables).
// extract into a tuple
extension Collection {
var headTail: (Element, SubSequence)? {
// possible implementation for Apple Swift
self.first.map { ($0, self[self.index(after: self.startIndex)...] }
}
}
switch aCollection.headTail {
case let (head, tail)? : break
default: break
}
matching with a function seems to not work in Silver, but here is an example:
// replace <Pattern> and <Value> with concrete types or generic parameters
func ~= (pattern: <Pattern>, value: <Value>) -> Bool {
return // does pattern match value?
}
// e.g.
func ~= (pattern: Bool, value: Int) -> Bool {
return (value != 0) == pattern
}
switch 5 {
case true: print("gets here")
case false: break
// This is still necessary in Apple Swift,
// because custom `~=` implementations are not
// required to be inlined before reachability diagnostics:
default: fatalError("shouldn't be reachable")
}
If it is C#, is it for .NET only, or will cover Island platform too?
Majority of C# 9 new features are functional style, seems they borrow from F#. If Oxygene supports those (e.g, Patterns and switch expression) that would be great (making Oxygene an alternative to F# in some sense)