[pitch] "import" declaration, support for comma-separated modules


(Charles Constant) #1

How would we all feel about allowing multiple modules with one import
statement?

Eg: the option to write

    *import Cocoa, Foo, Bar.Baz *

in addition to just:

    *import Cocoa *
    *import Foo *
    *import Bar.Baz *

When I'm writing smaller files that import a few modules, I'd prefer to
lump the imports together like this. Doesn't seem like a feature that would
require much effort to implement either.


(Erica Sadun) #2

I'm fine with this. I'd also like `import as` to handle namespacing simplification and conflict resolution

`import Bar.Baz as Bif`

-- E

···

On Oct 15, 2016, at 6:41 PM, Charles Constant via swift-evolution <swift-evolution@swift.org> wrote:

How would we all feel about allowing multiple modules with one import statement?

Eg: the option to write

    import Cocoa, Foo, Bar.Baz

in addition to just:

    import Cocoa
    import Foo
    import Bar.Baz

When I'm writing smaller files that import a few modules, I'd prefer to lump the imports together like this. Doesn't seem like a feature that would require much effort to implement either.


(Rien) #3

Specifically, I don’t care much. Say -0.1 :slight_smile:

In general I am against “savings lines”.
While very short modules (< 10) do indeed profit from having fewer lines, most modules don’t.
Having a few more lines, even empty ones, can do a lot to improve code readability imo.
Probably my Ada experience showing through….

Rien.

···

On 16 Oct 2016, at 02:41, Charles Constant via swift-evolution <swift-evolution@swift.org> wrote:

How would we all feel about allowing multiple modules with one import statement?

Eg: the option to write

    import Cocoa, Foo, Bar.Baz

in addition to just:

    import Cocoa
    import Foo
    import Bar.Baz

When I'm writing smaller files that import a few modules, I'd prefer to lump the imports together like this. Doesn't seem like a feature that would require much effort to implement either.

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Anton Zhilin) #4

Purely additive feature, not for Swift 4 Phase 1.
And a -1 from me for reasons already mentioned.


#5

+1. Since we can do `let a, b, c, ...`, it makes sense for `import` to support comma-separated lists.

-Richard

···

On Oct 15, 2016, at 20:24, Erica Sadun via swift-evolution <swift-evolution@swift.org> wrote:

On Oct 15, 2016, at 6:41 PM, Charles Constant via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

How would we all feel about allowing multiple modules with one import statement?

Eg: the option to write

    import Cocoa, Foo, Bar.Baz

in addition to just:

    import Cocoa
    import Foo
    import Bar.Baz

When I'm writing smaller files that import a few modules, I'd prefer to lump the imports together like this. Doesn't seem like a feature that would require much effort to implement either.

I'm fine with this. I'd also like `import as` to handle namespacing simplification and conflict resolution

`import Bar.Baz as Bif`

-- E

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Nicholas Maccharoli) #6

+1

2016年10月16日日曜日、Rien via swift-evolution<swift-evolution@swift.org>さんは書きました:

···

Specifically, I don’t care much. Say -0.1 :slight_smile:

In general I am against “savings lines”.
While very short modules (< 10) do indeed profit from having fewer lines,
most modules don’t.
Having a few more lines, even empty ones, can do a lot to improve code
readability imo.
Probably my Ada experience showing through….

Rien.

> On 16 Oct 2016, at 02:41, Charles Constant via swift-evolution < > swift-evolution@swift.org <javascript:;>> wrote:
>
> How would we all feel about allowing multiple modules with one import
statement?
>
> Eg: the option to write
>
> import Cocoa, Foo, Bar.Baz
>
> in addition to just:
>
> import Cocoa
> import Foo
> import Bar.Baz
>
> When I'm writing smaller files that import a few modules, I'd prefer to
lump the imports together like this. Doesn't seem like a feature that would
require much effort to implement either.
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org <javascript:;>
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <javascript:;>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Jay) #7

-1 - I don't like this.

I never understood the desire for *extreme* vertical conciseness, it tends
to make code less readable in general and definitely makes diffs a lot
harder harder to read.

···

On Sun, 16 Oct 2016 at 11:26 Anton Zhilin via swift-evolution < swift-evolution@swift.org> wrote:

Purely additive feature, not for Swift 4 Phase 1.
And a -1 from me for reasons already mentioned.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Robert Widmann) #8

-1. This is not going to work particularly well with qualified import syntax (import {class|struct|enum|typealias} Module.Decl) and blurs disparate imports with each other. I'd rather see grouping of related imports than save a few lines.

~Robert Widmann

2016/10/16 3:14、Richard Wei via swift-evolution <swift-evolution@swift.org> のメッセージ:

···

+1. Since we can do `let a, b, c, ...`, it makes sense for `import` to support comma-separated lists.

-Richard

On Oct 15, 2016, at 20:24, Erica Sadun via swift-evolution <swift-evolution@swift.org> wrote:

On Oct 15, 2016, at 6:41 PM, Charles Constant via swift-evolution <swift-evolution@swift.org> wrote:

How would we all feel about allowing multiple modules with one import statement?

Eg: the option to write

    import Cocoa, Foo, Bar.Baz

in addition to just:

    import Cocoa
    import Foo
    import Bar.Baz

When I'm writing smaller files that import a few modules, I'd prefer to lump the imports together like this. Doesn't seem like a feature that would require much effort to implement either.

I'm fine with this. I'd also like `import as` to handle namespacing simplification and conflict resolution

`import Bar.Baz as Bif`

-- E

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Charles Constant) #9

Having one import per line is much more readable and maintainable

This depends on how much importance you give to "import" declarations. If
you feel they equally important as the rest of your code, I can understand
why you would want to see them. I don't.

My preference is to see as much of the rest of my code as possible. I don't
spend nearly as much time checking which modules I imported, as I do
editing functions and classes. I'd almost always prefer to have another
three lines of a protocol visible, than three lines of imports. Except that
the imports will be visible anyways, just - and even this is arguable in
many cases - harder to read.

I never understood the desire for *extreme* vertical conciseness

It's probably *because* I use more vertical space than most people, that
losing screen real-estate to "import" declarations bothers me.

On Mon, Oct 17, 2016 at 8:40 AM, Said Sikira via swift-evolution <

···

swift-evolution@swift.org> wrote:

-1. I disagree.

Having one import per line is much more readable and maintainable
especially when you have statements like `import func Framework.someMethod`.

Being able to use `let a, b, c, …` doesn’t have to do anything with
importing modules since those are completely different features of the
language.

On October 17, 2016 at 5:22:02 PM, Jay Abbott via swift-evolution ( > swift-evolution@swift.org) wrote:

-1 - I don't like this.

I never understood the desire for *extreme* vertical conciseness, it tends
to make code less readable in general and definitely makes diffs a lot
harder harder to read.

On Sun, 16 Oct 2016 at 11:26 Anton Zhilin via swift-evolution < > swift-evolution@swift.org> wrote:

Purely additive feature, not for Swift 4 Phase 1.
And a -1 from me for reasons already mentioned.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Said Sikira) #10

-1. I disagree.

Having one import per line is much more readable and maintainable
especially when you have statements like `import func Framework.someMethod`.

Being able to use `let a, b, c, …` doesn’t have to do anything with
importing modules since those are completely different features of the
language.

-1 - I don't like this.

I never understood the desire for *extreme* vertical conciseness, it tends
to make code less readable in general and definitely makes diffs a lot
harder harder to read.

···

On October 17, 2016 at 5:22:02 PM, Jay Abbott via swift-evolution ( swift-evolution@swift.org) wrote:

On Sun, 16 Oct 2016 at 11:26 Anton Zhilin via swift-evolution < swift-evolution@swift.org> wrote:

Purely additive feature, not for Swift 4 Phase 1.
And a -1 from me for reasons already mentioned.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Georgios Moschovitis) #11

I'd almost always prefer to have another three lines of a protocolvisible, than three lines of imports.

Maybe you just need an editor that can fold the imports (e.g. JetBrains)


(Jean-Denis Muys) #12

I don't agree with the line of reasoning that goes something like that:

"Event though you have <some legitimate reason>, I want to forbid every one
from using additive feature X because I don't like it, given <some other
legitimate reason>"

I also don't understand why this would impede qualified import syntax. What
is wrong with:

import func Framework.someMethod, func OtherFramework.someOtherMethod

So far for me this is +1.

Because additive, not in scope for phase 1 of Swift 4, though, as most of
the topics on this list recently.

···

On 18 October 2016 at 08:01, Georgios Moschovitis via swift-evolution < swift-evolution@swift.org> wrote:

> I'd almost always prefer to have another three lines of a
protocolvisible, than three lines of imports.

Maybe you just need an editor that can fold the imports (e.g. JetBrains)
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution