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

Constants #194

Merged
merged 7 commits into from
Feb 19, 2020
Merged

Constants #194

merged 7 commits into from
Feb 19, 2020

Conversation

gdotdesign
Copy link
Member

This PR will add constants to the language (and resolve #169).

Constants can be added to a store, module or component using the following syntax:

module Math {
  constant PI = 3.141592653589793
}
  • constants can be accessed like variables inside the scope of the entity which defined them
  • constants can be accessed from the outside using the following syntax Math:PI

At this point I refrained from adding global constants, it can be added later if there is need.

@kennethnym
Copy link

kennethnym commented Feb 17, 2020

I still feel like the single colon syntax is a bit confusing..

Edit: how about

Module.myContant

?

@Namek
Copy link
Contributor

Namek commented Feb 17, 2020

I'd prefer const. It's typical for most languages and involves a bit less typing.

@gdotdesign
Copy link
Member Author

how about Module.myContant

With the current implementation we cannot do that because it conflicts with type ids (since they start with an uppercase letter and can contain dots .).

I'd prefer const. It's typical for most languages and involves a bit less typing.

I'm fine with that.

@gdotdesign gdotdesign merged commit 61c3a0d into master Feb 19, 2020
@gdotdesign gdotdesign deleted the constants branch February 26, 2020 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Is there a way to define global constants?
4 participants