开发者

What was the reason to choose the current syntax `import foo.bar.{Baz => _}` to exclude something from import?

开发者 https://www.devze.com 2023-01-01 01:31 出处:网络
I wonder if there is a good reason for this optical mismatch between e. g. pattern matching, which uses 开发者_如何学Pythona simple

I wonder if there is a good reason for this optical mismatch between e. g. pattern matching, which uses 开发者_如何学Pythona simple

case foo =>

to denote that no action should be taken.

Wouldn't it be reasonable to have something like

import foo.bar.{Baz => }

instead of

import foo.bar.{Baz => _}

considering that _ is used as an "import everything" in the same statement?


I would suggest it's for symmetry with renamed imports:

import java.util.{Collection => JCollection, _}

If we want to import to an inaccessible identifier:

import java.util.{Collection => _          , _}

(I know, _ is a valid identifier, but on the right hand side of => you should think of it as a black-hole from which the incoming identifier cannot escape.)

0

精彩评论

暂无评论...
验证码 换一张
取 消