Jon Harrop

My feedback

  1. 3 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    2 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop commented  · 

    Implementing "nearest" will require the concept of distance, above and beyond a mere total ordering. OCaml provides a Set.split function that splits a set into two sets at the given element, returning a boolean if that element was present.

    I wish there were many more functions in Map and Set. I'd like a subset function for Map where you give it a Set of keys. And a merge function for Map that adds binding from one Map to another efficiently (can be done in sub-linear time with pure collections). FWIW, my preference would be for more jack-of-all-trades-and-master-of-none purely functional collections. Their performance inevitably sucks so their value is really ease of use and clarity.

  2. 37 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    4 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop commented  · 

    Mathematica can also do multivariate anonymous parameters in anonymous functions. So (fun (x, y, z) -> x*y+z) can be written #1*#2+#3& in Mathematica.

    Jon Harrop commented  · 

    @Gustavo: I think this is a separate idea. That idea was just a shorthand for a lambda that just invokes a property like (fun foo -> foo.Name) could be #Name. This idea is more general. You could do (_.Name) but with this you can also do (_ + 1) as a shorthand for ((+) 1).

    FWIW, Mathematica has the shorthand notation #+1& for this where # is an anonymous argument in an anonymous function that ends with &. The syntax really is quite hideous!

  3. 248 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    under review  ·  8 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop commented  · 

    Yes!

  4. 5 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    4 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop commented  · 

    Why not use try..finally?

  5. 453 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    40 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop commented  · 

    @Tomas: Macros are used to customise syntax. For example, you might want to replace the pattern "| Add(f, g) -> d f + d g" with "| f+g -> d f + d g".

  6. 23 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    4 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop supported this idea  · 
  7. 25 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    6 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop commented  · 

    FWIW, OCaml has functional object update.

    @WillSmith: Looking at your code I'm thinking you would want the ability to mark a record type as struct.

  8. 63 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    1 comment  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop shared this idea  · 
  9. 150 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    under review  ·  10 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop commented  · 

    FWIW, I used OCaml for many years and never once found a use for co/contravariance in real code. There are some corner cases in F# with interop with OO libs like WPF but these are rare IME.

    On a related note, I would like implicit upcast when creating a literal list or array of subtypes like let myControls : Control list = [Label(); Button()].

  10. 457 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    under review  ·  37 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop supported this idea  · 
    Jon Harrop commented  · 

    Doesn't SML use something like #Name?

  11. 131 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    under review  ·  11 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →
    Jon Harrop supported this idea  · 
    Jon Harrop commented  · 

    OCaml is rather grim in this respect. They got too fancy and let you have optional curried arguments that support partial specialization which leads to all kinds of inconveniences.

    I would like optional non-curried arguments to let-bound functions though.

  12. 311 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    23 comments  ·  F# Language  ·  Flag idea as inappropriate…  ·  Admin →

    I am generally in favour of addressing this in F# 4.x+. I would want seq { .. } and async { … } tailcalls to also be addressed.

    A more detailed design is needed and some trialling would be great. Jack’s work is a great start. However, this is not an easy piece of work to do in a non-invasive way and my own experiments in this area have not yet led to something I feel confident to include in the F# language design.

    An implementation and testing would need to be provided by someone in the F# community (possibly including Microsoft or Microsoft Research, though not limited to them).

    Currently, initial implementations of approved language design can be submitted as pull requests to the appropriate branch of https://github.com/Microsoft/visualfsharp. See http://fsharp.github.io/2014/06/18/fsharp-contributions.html for info on how to contribute to the F# language/core library design

    I encourage you to consider continue…

    Jon Harrop supported this idea  · 
    Jon Harrop commented  · 

    How would we handle mutual recursion or recursion via a function that was passed in?

    For example:

    let rec even n =
    odd(n-1)
    and odd n =
    even(n-1)

    or:

    let evenOne odd n = odd(n-1)
    let oddOne even n = even(n-1)
    let rec even n = evenOne (oddOne even) n

    Could we put this attribute on an entire module to check that all loops within the module require bounded stack space?

    Jon Harrop commented  · 

    @Andrew: "I think the compiler is smart enough"

    Consider:

    let f n = n+1
    let f n = f(n-1)

    is the latter definition of "f" recursive? Obviously it is impossible to tell. Hence the existence of the "rec" keyword.

    The alternative is to make everything recursive but then you must pollute your namespaces with, for example, "f1" and "f2" because you cannot supercede previous definitions.

Feedback and Knowledge Base