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

[Feature Request] Add per file flag for #+package and #+local #174

Open
clsource opened this issue Dec 3, 2024 · 2 comments
Open

[Feature Request] Add per file flag for #+package and #+local #174

clsource opened this issue Dec 3, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@clsource
Copy link
Contributor

clsource commented Dec 3, 2024

  • #+package at the start of the file will mark any defined symbol as the package only scope. A file defined with #+package flag can use #local flag for scoping at the file level for individual symbols.

  • #+local at the start of the file will mark any defined symbol as the file only scope. A file defined with #+local flag can use #package flag for scoping at the package level for individual symbols.

A file with flags #+package or #+local cannot make its symbols public in any way. Another public file should be created.

Motivation

By using a file level fiag we can separate our APIs with public and private (package and file only) scopes, and avoid saturating our public files and symbols with scope attributes.

Example

By using this flag we can cleary separate scopes in our package.

- api.onyx // public apis
- api.pkg.onyx // package scope apis
- api.local.onyx // file (local) scope apis

Syntax

It was preferred the syntax #+ instead of //+ since it has less characters and promotes the meaning of a compiler directive instead of a comment.

@brendanfh brendanfh self-assigned this Dec 3, 2024
@brendanfh brendanfh added the enhancement New feature or request label Dec 3, 2024
@brendanfh brendanfh added this to the v0.1.14 milestone Dec 3, 2024
@brendanfh
Copy link
Collaborator

I think this is a great idea! I have designed many APIs like this where I have one "public" file, and many internal implementation files. I'm unsure if I like #+package, because every other directive so far is always # + a symbol. But I will have to think about what other wording it could be, as #package would be ambiguous.

@clsource
Copy link
Contributor Author

clsource commented Dec 3, 2024

Maybe since #private was used before can be reintroduced as #private for package scope and #private file for local scope

Or current directives be extended

  • #package file or #package.file
  • #local file or #local.file

Or a new #scope directive that can have a value

  • #scope(package)
  • #scope(file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants