-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adopt Julia Style #10
Comments
I hate underscores!
… On Jan 23, 2018, at 4:58 PM, Keegan Lensink ***@***.***> wrote:
I think it would be a good idea to start following Julia's style conventions moving forward. We could slowly go back and change things that are already in place until we catch up.
I've quoted some sections of Julia's style guide for things that stand out to me:
Camel Casing
All of Julia's Base (and the vast majority of all packages) follow a particular style, so it might be difficult for users to adopt the package if we use a different style.
modules and type names use capitalization and camel case: module SparseArrays, struct UnitRange.
functions are lowercase (maximum(), convert()) and, when readable, with multiple words squashed together (isequal(), haskey()). When necessary, use underscores as word separators. Underscores are also used to indicate a combination of concepts (remotecall_fetch() as a more efficient implementation of fetch(remotecall(...))) or as modifiers (sum_kbn()).
conciseness is valued, but avoid abbreviation (indexin() rather than indxin()) as it becomes difficult to remember whether and how particular words are abbreviated.
Re-naming Outer Constructors
function getAffineScalingLayer(TYPE::Type, nData) return AffineScalingLayer{TYPE}(nData) end
Should be:
AffineScalingLayer(TYPE::type, nData) = AffineScalingLayer{TYPE}(nData)
Unnecessary Static Type Parameters
A function signature:
foo(x::T) where {T<:Real} = ...
should be written as:
foo(x::Real) = ...
or foo(x::Array{T, 2}) where {T<:Number} should be written as foo(x::Array{<:Number, 2}) if T is not used elsewhere.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'd put changing the style on low priority. let's focus on performance first. |
I agree that it is a low priority, but I just wanted to bring it up because keeping it in mind going forward will reduce the amount of changes we'll need to make later. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be a good idea to start following Julia's style conventions moving forward. We could slowly go back and change things that are already in place until we catch up.
I've quoted some sections of Julia's style guide for things that stand out to me:
All of Julia's Base (and the vast majority of all packages) follow a particular style, so it might be difficult for users to adopt the package if we use a different style.
function getAffineScalingLayer(TYPE::Type, nData) return AffineScalingLayer{TYPE}(nData) end
Should be:
AffineScalingLayer(TYPE::type, nData) = AffineScalingLayer{TYPE}(nData)
or
foo(x::Array{T, 2}) where {T<:Number}
should be written asfoo(x::Array{<:Number, 2})
ifT
is not used elsewhere.The text was updated successfully, but these errors were encountered: