carbon-lang icon indicating copy to clipboard operation
carbon-lang copied to clipboard

Design idea: optional `package` keyword and optional package name in `package`

Open jonmeow opened this issue 3 years ago • 2 comments

There are several provisional ideas which were added by @josh11b to the design overview. I'm filing this to track the ideas.

Key sections are:

https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/README.md#package-declaration

  • If the package name is omitted, as in package library "Main" api;, the file contributes to the default package. No other package may import from the default package.

  • If a file has no package declaration at all, it is the api file belonging to the default package and default library. This is particularly for tests and smaller examples. No other library can import this library even from within the default package. It can be split across multiple impl files using a package impl; package declaration.

jonmeow avatar Oct 20 '22 17:10 jonmeow

Leads approved the overview update in #1347 so I assume this doesn't need to be a leads question, but it wasn't really discussed there so a specific design would be good.

jonmeow avatar Oct 20 '22 17:10 jonmeow

It was noted that #1136 comments on making package names optional on import, and that's really covered by #2001, so I'm trimming this down to be specific to the package keyword.

jonmeow avatar Oct 20 '22 21:10 jonmeow