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

Add operator support #14

Open
brettlangdon opened this issue Jul 3, 2015 · 4 comments
Open

Add operator support #14

brettlangdon opened this issue Jul 3, 2015 · 4 comments

Comments

@brettlangdon
Copy link
Owner

Idea revitalized from #9

Originally I wanted to support operators like +, -, / and *, but cut it out of the original scope and now am considering adding them back in.

The simple use case here is for numbers.

primary {
  num_workers = 2;
}
secondary {
  num_workers = 4;
}

total_workers: primary.num_workers + secondary.num_workers;
one_hour = 3600;

primary {
  interval = 5 * one_hour;
}

As well, concatenation for strings would be helpful:

prefix = "prefix";

primary {
    string_setting = prefix + "primary";
}

secondary {
  string_setting = prefix + "secondary";
}

Where is starts to get trickier is with sections, do we merge them together?

primary {
  some_setting: "value";
}

secondary {
  some_setting: "another value";
}

all_settings: primary + secondary;

What is the value of all_settings here?

Also, should consider this for lists when they are supported. Lists will probably be treated as sets and also support unions, intersections and etc

@lode
Copy link

lode commented Jul 14, 2015

I would say this belongs in the programming language using the configuration file, and not in the configuration file itself. A bit like the mustache mantra of "Logic-less templates". Keep it simple.
What's your stance in this?

@brettlangdon
Copy link
Owner Author

Yeah, I've gone back and forth on whether it is worth adding or not. Mostly wanted to put up these issues to see what people say.

@lode
Copy link

lode commented Jul 14, 2015

I do see the value in string concatenation (as in the referenced HOCON issue). Especially for i18n config that might be very handy. And number 'concatenation' seems not far away then, but calculating feels a bit off track for a config.

@brettlangdon
Copy link
Owner Author

Yeah, I am not 100% on the use case, just figured if I was going to do integer addition, wouldn't be too hard to add the others.

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

No branches or pull requests

2 participants