My suggestion to Element

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!

No argument there, yes.

That said, probably not this year (for either F# or f(Oxy); we have a lot of other stuff on our plates :wink:

I didnt want Erlang. I wanted to a functional version of Oxygene that ran on the Beam VM.

From what I read the Erlang and Elixir are the 2 most popular.

Mind you Go seems to have a lot of functional features, the syntax is a lot easier to understand so Im learning that.

1 Like

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).

1 Like

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):

1 Like

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

  • higher order functions
    • yes
  • currying
    • 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?)
1 Like

Can you elaborate on what you mean bye this? I’m not sure I understand. Are you saying extensions cannot add new fields in Apple Swift, either?

Yes, extensions cannot add stored instance properties, even in Apple Swift.

Good to know, will adjust.

Thank you again for the headsup

Can Swift do pattern matching for collections like head:tail?

No.

Here are the Apple Swift pattern docs.

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")
}
1 Like

Thank you very much, and hats off to you.

Does RemObjects support C# 9 yet?

Will Oxygene support similar C# 9 feature in Patterns, and Immutable Record?

I’m working on record support. Most of the pattern support is already in but I think there’s 1 or 2 missing.

Oxygene, C# or both?

C# to start with. Not sure how to expose it in pascal yet. Possibly with an aspect.

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)

FTR: C# Evolution

Where ever feasible we will add these features for all platforms, and for all (applicable) languages.