Skip to content

[RFC FS-1046] Wildcard self identifier. Allow single underscore in members.#6829

Merged
KevinRansom merged 4 commits intodotnet:release/fsharp47from
gusty:patch-1
May 27, 2019
Merged

[RFC FS-1046] Wildcard self identifier. Allow single underscore in members.#6829
KevinRansom merged 4 commits intodotnet:release/fsharp47from
gusty:patch-1

Conversation

@gusty
Copy link
Copy Markdown
Contributor

@gusty gusty commented May 23, 2019

This allows writing a single underscore in member definitions, ie member _.DoSomething().

@dnfclas
Copy link
Copy Markdown

dnfclas commented May 23, 2019

CLA assistant check
All CLA requirements met.

@cartermp
Copy link
Copy Markdown
Contributor

@gusty is there a language suggestion change that maps to this? Generally I'm in favor.

Another interesting one (if you're digging around in there) is for __ in do:

image

Error message kinda sucks, and the resolution is a double _.

@gusty
Copy link
Copy Markdown
Contributor Author

gusty commented May 23, 2019

Yes, it's approved in principle, see fsharp/fslang-suggestions#333

I've never thought about the for _ in, I will dig into it, in a separate PR.

@cartermp
Copy link
Copy Markdown
Contributor

@gusty Thanks!

@matthid
Copy link
Copy Markdown
Contributor

matthid commented May 23, 2019

Thanks a lot for trying to take care of this wart ;)

@cartermp
Copy link
Copy Markdown
Contributor

@gusty
Copy link
Copy Markdown
Contributor Author

gusty commented May 23, 2019

Actually for the renamer you suggested it won't cause problems. I was thinking in the warning mechanisms. For the identifiers starting with underscore it won't be a problem, but for existing member x. we could issue a warning once this feature is added, but as I said it would be sort of a breaking change.

I had a look at how it works right now and it already considers unused bindings everything that doesn't start with an underscore, so we're good to change the renamer too.

@gusty gusty changed the title [WIP] Add Underscore Dot rule Allow single underscore wildcard self identifier in members May 23, 2019
@gusty
Copy link
Copy Markdown
Contributor Author

gusty commented May 23, 2019

@cartermp I adjusted the renamer, as you suggested.

@gusty gusty changed the title Allow single underscore wildcard self identifier in members [RFC FS-1046] Wildcard self identifier. Allow single underscore in members. May 23, 2019
@KevinRansom KevinRansom changed the base branch from master to release/fsharp47 May 26, 2019 23:12
@KevinRansom
Copy link
Copy Markdown
Contributor

targeting fsharp47

Copy link
Copy Markdown
Contributor

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice,

thx

Copy link
Copy Markdown
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, thanks a lot @gusty

@KevinRansom KevinRansom merged commit 53c2828 into dotnet:release/fsharp47 May 27, 2019
@cartermp cartermp added this to the .NET Core 3.0 milestone Jun 17, 2019
@cartermp cartermp modified the milestones: .NET Core 3.0, 16.3 Aug 5, 2019
@human-bean-555
Copy link
Copy Markdown

Love this update, however I noticed that it doesn't work with an accessibility modifier:

type MyType =
    { Hello : string }
    member private __.WorldOk = "World ok"
    member private _.WorldOhNo = "World not ok"

Do you want me to open a separate issue?

@gusty
Copy link
Copy Markdown
Contributor Author

gusty commented Sep 26, 2019

Good catch !

I've just added a PR (#7631) that will cover that case.

brettfo pushed a commit to brettfo/fsharp that referenced this pull request Sep 26, 2019
…mbers. (dotnet#6829)

* Add Underscore Dot rule

* Update tests

* Revert line where x is used

* Code fix rename to single underscore
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
…mbers. (dotnet#6829)

* Add Underscore Dot rule

* Update tests

* Revert line where x is used

* Code fix rename to single underscore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants