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

First class scope support #13

Open
flaxed opened this issue Aug 24, 2019 · 0 comments
Open

First class scope support #13

flaxed opened this issue Aug 24, 2019 · 0 comments
Labels
feature Feature suggestion syntax Syntax work

Comments

@flaxed
Copy link
Contributor

flaxed commented Aug 24, 2019

A common scenario in development is to have fields or types to exist depending on constants set on the environment, usually Release and Debug environments.

This proposal is for a scope keyword, to work as a generic form of first class support for this case.

The scope will have the format of:

scope $(ConditionList)
{
    $(Contents)
}

The ConditionList is a comma separated list of Condition expressions. Each Condition will be a string Tag with an optional ! to negate it. Will other operations be useful?
Example:

scope (Network, !Debug)
{
}

To ease iteration on the files, a empty list, or maybe even skipping the list at all will be supported. In this case it will be as if there is no scope at all. Example: scope () { } or scope { }

The Contents is either one or more struct definitions, or one or more field definitions.
Ommiting the { } scope block delimiters for single items can be considered, example:

scope (Network, !Debug)
def struct Foo
{
}

But this feature is likely to increase parsing complexities.

@flaxed flaxed added feature Feature suggestion syntax Syntax work labels Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature suggestion syntax Syntax work
Projects
None yet
Development

No branches or pull requests

1 participant