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

Fix misleading info on the difference between "using" and "import" #47614

Merged
merged 3 commits into from
Feb 10, 2023
Merged
Changes from all 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
11 changes: 7 additions & 4 deletions doc/src/manual/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -818,10 +818,13 @@ to strings); similarly, `repeat` can be used instead of `^` to repeat strings. T

### What is the difference between "using" and "import"?

There is only one difference, and on the surface (syntax-wise) it may seem very minor. The difference
between `using` and `import` is that with `using` you need to say `function Foo.bar(..` to
extend module Foo's function bar with a new method, but with `import Foo.bar`,
you only need to say `function bar(...` and it automatically extends module Foo's function bar.
There are several differences between `using` and `import`
(see the [Modules section](https://docs.julialang.org/en/v1/manual/modules/#modules)),
but there is an important difference that may not seem intuitive at first glance,
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps "including in particular one important difference that may not seem" instead of "but there is an important difference that may not seem"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding this sentence, where does using and import comes?

Can you please provide a complete suggestion so I see where the using and import comes in?

and on the surface (i.e. syntax-wise) it may seem very minor. When loading modules with `using`,
you need to say `function Foo.bar(...` to extend module `Foo`'s function `bar` with a new method,
but with `import Foo.bar`, you only need to say `function bar(...` and it automatically extends
module `Foo`'s function `bar`.

The reason this is important enough to have been given separate syntax is that you don't want
to accidentally extend a function that you didn't know existed, because that could easily cause
Expand Down