Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 27, 2019

Conversation

gusty
Copy link
Contributor

@gusty gusty commented May 23, 2019

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

@dnfclas
Copy link

dnfclas commented May 23, 2019

CLA assistant check
All CLA requirements met.

@cartermp
Copy link
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
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
Contributor

@gusty Thanks!

@matthid
Copy link
Contributor

matthid commented May 23, 2019

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

@cartermp
Copy link
Contributor

@gusty
Copy link
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
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
Member

targeting fsharp47

Copy link
Member

@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
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
@pauldorehill
Copy link

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

None yet

6 participants