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

Update performance-tips.md #22479

Merged
merged 5 commits into from
Jun 25, 2017
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/src/manual/performance-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ Here, we happened to know that the first element of `a` would be an [`Int32`](@r
an annotation like this has the added benefit that it will raise a run-time error if the
value is not of the expected type, potentially catching certain bugs earlier.

In the case that the type of `a[1]` is not known precisely, `x` can be declared via
`x = convert(Int32,a[1])::Int32`. The
Copy link
Member

Choose a reason for hiding this comment

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

Double space before "The" ?

use of the `convert` function allows `a[1]` to be any object convertible to an `Int32` (such as `UInt8`), thus
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps worth adding a reference to convert? E.g. [`convert`](@ref)

Copy link
Member

Choose a reason for hiding this comment

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

Also wrap lines at 92 chars.

increasing the genericity of the code by loosening the type requirement.
Notice that the `convert` function itself needs a type annotation in this context in order to achieve type stability.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps "Notice that convert itself..." ?

This is because the compiler cannot deduce the type of the return value of a function, even
`convert`, unless the types of all its arguments are known.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps "...the types of all the arguments...", since "its" could refer to the compiler in this sentence?


### Declare types of keyword arguments

Keyword arguments can have declared types:
Expand Down