Coder Social home page Coder Social logo

Comments (18)

mmuschalik avatar mmuschalik commented on July 24, 2024 1

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.

havocp avatar havocp commented on July 24, 2024

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.

 avatar commented on July 24, 2024

yes, I got that; what I meant - do you think there is an extension on hocon rules that would permit this?

from config.

havocp avatar havocp commented on July 24, 2024

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.

 avatar commented on July 24, 2024

re: "if we don't resolve globally, we try "lexical scope" search or "only in the same object" search" - I like this

from config.

 avatar commented on July 24, 2024

on a related note, do you have v 1.0.0 closer on your horizon?

from config.

havocp avatar havocp commented on July 24, 2024

1.0.0 is basically just supposed to be timed with the next Scala/Akka release - which is "soon" afaik.

from config.

jsuereth avatar jsuereth commented on July 24, 2024

1-2 weeks before RC1

from config.

fehmicansaglam avatar fehmicansaglam commented on July 24, 2024

What is the current situation for this issue? Do you have to plan to support "lexical scope"?

from config.

havocp avatar havocp commented on July 24, 2024

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.

fehmicansaglam avatar fehmicansaglam commented on July 24, 2024

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.

havocp avatar havocp commented on July 24, 2024

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.

fehmicansaglam avatar fehmicansaglam commented on July 24, 2024

Thanks for your help. I have implemented scopes using resolveWith. And with not that much code.

from config.

bmarwell avatar bmarwell commented on July 24, 2024

Hello. This issue is pretty old, but still needed. Are you going to put any effort into it?

from config.

havocp avatar havocp commented on July 24, 2024

I don’t have plans to work on this, but of course others are welcome to.

from config.

jvanzyl avatar jvanzyl commented on July 24, 2024

@fehmicansaglam Might you be able to share your code for lexically scoped substitutions?

from config.

fehmicansaglam avatar fehmicansaglam commented on July 24, 2024

@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.

jvanzyl avatar jvanzyl commented on July 24, 2024

Thanks so much!

from config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.