Comments (18)
Another suggestion is the following:
Local scope:
^{this.name}
Parent scope:
^{super.name}
Global scope:
${name}
So, adopt the Java way of class inheritance, but obviously keep backwards compatibility.
from config.
substitutions are "global", so ${some-id} refers to some-id at the root. There's no way to do substitutions that refer to list elements.
from config.
yes, I got that; what I meant - do you think there is an extension on hocon rules that would permit this?
from config.
Two quick ideas would be:
- if we don't resolve globally, we try "lexical scope" search or "only in the same object" search
- an alternative syntax like ^{some-id} or something
I guess the first would be a little more in the "figure out what you meant" spirit of HOCON.
It might be some effort to implement; right now objects don't have a parent reference (and adding parent references could add a lot of object copying). So some kind of parent chain might have to be built when traversing the tree to resolve substitutions and then that chain would have to be passed in to the substitution-resolver code. (Just speculating here really, I may not remember the code properly. The point is it might be kind of tricky to implement.)
It's likely surprising that global search would be before lexical/local search, but it would have to be that way to be backward compatible.
from config.
re: "if we don't resolve globally, we try "lexical scope" search or "only in the same object" search" - I like this
from config.
on a related note, do you have v 1.0.0 closer on your horizon?
from config.
1.0.0 is basically just supposed to be timed with the next Scala/Akka release - which is "soon" afaik.
from config.
1-2 weeks before RC1
from config.
What is the current situation for this issue? Do you have to plan to support "lexical scope"?
from config.
I don't have any immediate plan. It's just a discussion that has come up / can be discussed further, if people have thoughts.
from config.
I see. I want to ask a question. I am trying to add Fixtures support to ReactiveMongo Extensions. Defining fixtures by HOCON seems to be a good idea. But as there is no locality in substitutions it is somewhat cumbersome to specify references. Currently it is not possible to do this:
_collection.persons {
person1 {
_id: _id_person1
name: Ali
surname: Veli
fullname: ${name} ${surname}
age: 32
}
person2 {
_id: _id_person2
name: Haydar
surname: Cabbar
fullname: ${name} ${surname}
age: ${person1.age}
}
}
Ability to inject a custom resolver would be great.
from config.
If you are up to implementing a custom resolve I think you could do that now with Config.resolveWith()
and ConfigResolveOptions.setAllowUnresolved()
- traverse the tree building the lexical stack and then resolveWith each node in the stack until resolution is complete. I guess the API is there but it would be a lot of code to write.
For a built-in lexical scope feature there's some work just to figure out how to spec it and how it should work, with a focus on usability, and then of course the work to implement it. I don't have an immediate plan to do either part of the work but if someone's passionate and wants to dig in I can try to help.
Syntax ideas:
^{look.up.lexically}
${^look.up.lexically}
${.look.up.lexically}
? not sure really. I haven't even checked that ^
is one of the reserved chars that we could use (spec has a list).
from config.
Thanks for your help. I have implemented scopes using resolveWith. And with not that much code.
from config.
Hello. This issue is pretty old, but still needed. Are you going to put any effort into it?
from config.
I don’t have plans to work on this, but of course others are welcome to.
from config.
@fehmicansaglam Might you be able to share your code for lexically scoped substitutions?
from config.
@jvanzyl it's been too long time but here's the code: https://github.com/fehmicansaglam/reactivemongo-extensions/blob/0.10.x/core/src/main/scala/fixtures/Fixtures.scala
from config.
Thanks so much!
from config.
Related Issues (20)
- Get the line/pos information from a ConfigObject HOT 1
- `ConfigFactory.parseResources()` overrides `ConfigParseOptions.setSyntax()`
- Is this project active? HOT 4
- Find a StackOverflowError in config
- Find a StackOverflowError in config
- Find a StackOverflowError in config HOT 1
- underscore characters HOT 2
- Problems with com.typesafe/config and maven-dependency-plugin
- introduce method accepting a list of Objects to add a value
- Should this project be explicitly considered as deprecated/not supported? HOT 29
- Community fork? HOT 7
- Resolving Variable Substitutions Between Multiple Config HOT 1
- Something error when use com.typesafe.config API convert conf file to scala bean class
- withFallBack is not adding value if not present
- how to load the config with substitution details HOT 3
- Add info about which signing keys will be used for published artifacts.
- Cannot provide environment variables programmatically
- Rendering partially resolved appended array results in invalid configuration HOT 1
- Inconsistent behavior with Overflow/Underflow and Exceptions
- Regression in environment variable reading behavior HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from config.