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

Make the single-line use of [<Literal>] consistent #409

Closed
baronfel opened this issue Oct 20, 2016 · 14 comments
Closed

Make the single-line use of [<Literal>] consistent #409

baronfel opened this issue Oct 20, 2016 · 14 comments

Comments

@baronfel
Copy link
Contributor

baronfel commented Oct 20, 2016

Make the single-line use of [] consistent [7090326]

Submitted by Don Syme on 2/13/2015 12:00:00 AM
6 votes on UserVoice prior to migration

See dotnet/fsharp#229
Some declaration constructs allow attributes on the same line as the keyword for the declaration, e.g.

[<Measure>] type kg
[<Measure>] type m

However this doesn't work for "let" bindings, e.g.
img
Right now the consistent way to do things is always to use multiple lines, e.g.
img2
The suggestion is to make this consistent by allowing single-line use everywhere, if that is technically possible.

Response

by fslang-admin on 2/5/2016 12:00:00 AM

Closing as this idea (listed by me) as it has little support

Original UserVoice Submission
Archived Uservoice Comments

@Happypig375
Copy link
Contributor

Please resurrect this, I want this so bad 😢

@cartermp
Copy link
Member

Thanks for the ping. I'd like to relitigate this, since the closure was based on lack of vote count, which I don't really see as a valid reason to decline something.

@dsyme thoughts?

@baronfel
Copy link
Contributor Author

Edited the original submission for legibility/inline image expansion.

@FunctionalFirst
Copy link

This is already possible (or am I misunderstanding the suggestion?).

let [<Literal>] Foo = "foo"

@cartermp
Copy link
Member

@FunctionalFirst Correct, but it's a bit unexpected that it has to come after the let. If you do it as described in the issue, you get an offside warning:

image

Which is unexpected.

@smoothdeveloper
Copy link
Contributor

smoothdeveloper commented Jun 18, 2019

Note there is similar problem currently with attributes on types:

image

here I'm switching a module rec to a smaller set of anded types, and I have to move the [<RequireQualifiedAccess>] after the and.

I'm getting this before fixing it which is a bit misleading (attribute is valid on that language element):

image

If it ends up being similar change for both and could be fixed, it would make the language a bit more lenient on those particular syntactic bits.

edit: well, this makes me think, maybe it should work with a single preferred way (attribute next to the identifier I guess), and give a warning otherwise, instead of confusing / wrong error messages, this would be a more conservative approach.

@Happypig375
Copy link
Contributor

You mean #733?

@smoothdeveloper
Copy link
Contributor

@Happypig375 correct!

Also interesting, this comment from @dsyme regarding such changes in parser: #514 (comment)

@auduchinok
Copy link

Another case is indentation block for the binding/member:

Screenshot 2019-07-04 at 13 45 30

@abelbraaksma
Copy link
Member

Perhaps this and #514 can be merged, perhaps also #733 and #757, they basically all come down to the same thing:

  • unifying the way the indentation rules apply to declarations-with-attributes, by allowing the attributes before, after and above the keyword.

@dsyme
Copy link
Collaborator

dsyme commented Sep 25, 2021

My understanding is this has been addressed as part of FS-1108, currently in preview https://github.com/fsharp/fslang-design/blob/main/preview/FS-1108-undentation-frenzy.md

@dsyme dsyme closed this as completed Sep 25, 2021
@BentTranberg
Copy link

Ops, I'm late to the party. Again! On the same subject! Sorry if somebody is tired of me repeating this.

This is already possible (or am I misunderstanding the suggestion?).

let [<Literal>] Foo = "foo"

That's what I have been recommending on several occasions in various places, because it avoids code creep. By placing an attribute inside the language construct to which it applies, rather than somewhere outside (e.g. before on the same line), you considerably lessen the risk of the language construct and the attribute drifting away from each other, with all the bad consequences that can have.

@Happypig375
Copy link
Contributor

@dsyme I believe this should be closed as dupe of #514 rather than being considered completed, because this has not been fixed yet.

@dsyme
Copy link
Collaborator

dsyme commented Sep 27, 2021

@dsyme I believe this should be closed as dupe of #514 rather than being considered completed, because this has not been fixed yet.

OK, thank you

@dsyme dsyme removed the completed label Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants