JuliaDiff / JuliaDiff/BlueStyle

Prefer `where {T}` to `where T`?

Open
#69 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
519
Forks
34
PR merge metrics
No merged PRs in 30d

Description

As far as i can am aware, BlueStyle has no opinion on this.

even the example code in this style guide itself is inconsistent, sometimes using where {T} and othertimes where T (or where {T <: Int} and othertimes where T <: Int).

We could stick with having no preference, however, for the sake of running a formatter (https://github.com/domluna/JuliaFormatter.jl/issues/283, #7 ), what should a formatter do?

We have four options (to my mind, anyway)

  1. always prefer braces: where {T} to where T
  2. always prefer NO braces: where T to where {T} (when valid)
  3. sometimes prefer NO braces (in a subset of cases of the valid cases, based on some rule)
  4. do nothing

Option (4) is "do nothing". This isn't a great option for 2 reasons: (1) stylistically, we probably want a code-base to be consistent on this, it's one thing to say "either is fine", and another to say "both is fine". (2) effort-wise, the formatter can/does already fix these cases, so i see no reason to add functionality to leave a code-base less consistent.

I see no reason to come up with a subtle rule here (we've survived without it so far), so let's not do option (3), which is the most complicated.

This leaves options (1) and (2). Since we have no strong preference here (based on the current style guide), i say we stick with the decision made in https://github.com/domluna/JuliaFormatter.jl/issues/53 and go with option (1) -- it's the more common pattern in Julia Base, and it's what JuliaFormatter does right now -- so for the sake of the formatter, prefer where {T} to where T.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the BlueStyle guide's examples and the referenced JuliaFormatter issues #53 and #283 to confirm the intended convention. Done means the guide states one consistent preference for where {T} versus where T and its examples follow that preference.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.