What are the benefits of such flexible “self-identifiers” in F#?

前端 未结 2 1181
北荒
北荒 2020-12-15 18:47

While I understand self-identifiers in F#, I am puzzled as to the benefits of such flexibility. Why does F# not just support this.Blah as C# does and be done w

2条回答
  •  爱一瞬间的悲伤
    2020-12-15 19:12

    The only thing I can come up with (and it's not big) is that since the self-identifier must explicitly be referred to when calling an instance method, being able to name it lets you use something shorter than the word this. There is a lot of (valid or not) desire in languages on FP languages on which F# is based for conciseness (sometimes to the point of overdoing it) that may have prompted this. After all, you'll note this desire showing through in other places in F# where it wouldn't in e.g. C#--note function names like iteri that would probably be called IterateWithIndex in C#.

提交回复
热议问题