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

Implement private access modifier for modules / functions #21

Open
moxvallix opened this issue Dec 4, 2024 · 0 comments
Open

Implement private access modifier for modules / functions #21

moxvallix opened this issue Dec 4, 2024 · 0 comments

Comments

@moxvallix
Copy link
Contributor

It would be really useful to be able to have "private" functions as a concept. This would allow users to write functions that only their codebase should be using, which is very helpful for library datapacks.

I would propose that "private" functions would generate in the private module of the zoglin namespace. For example:

namespace example

module api {
	# example:api/public_fn
	fn public_fn() {}

	# zoglin:private/example/api/private_fn
	private fn private_fn() {}
}

Whilst moving it to the Zoglin namespace is a little opaque, I think ultimately the path is still predictable enough for developers.

Zoglin resources should treat private functions as if they are defined in the same spot as a public function.

Accessing variables from a private function probably doesnt need to have this help however, they should refer to the full private path outside of their own function.

Accessing variables between private functions might get confusing from that however, so maybe we need to think more on that.

Every child of a private module will also be private.

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

No branches or pull requests

1 participant