Coder Social home page Coder Social logo

Comments (3)

havocp avatar havocp commented on July 24, 2024

It is an interesting idea. Would have to play with the parser and see if it's workable. It creates some ambiguity; note that outside of [], "a=1, b=2" is a single object, but here "a=1,b=1" would be two objects in a list. Also it requires the parser to "look ahead" because in all existing cases, if you see "alpha" in "alpha=1" you know that "alpha" is an object key already. But in this case, you don't know whether "alpha" is an object key or just a string, until you get to the "=" or ":" - so that's a look-ahead to the next token that is never (if I remember right) currently done. Anyway those are just some possible issues I thought of offhand, it would need more digging in.

from config.

pditommaso avatar pditommaso commented on July 24, 2024

I don't think that it will create an ambiguity, on the contrary in my opinion it would be even more coherent with the JSON array semantic. In fact an array can hold a list of primitive types or objects, so the assignment notation can only represent an object since it is not a primitive types.

My real use case it the following: I have a list of components, for each of them I have to provide a configuration. I know that I could use the object notation instead of the array, for example:

components { alpha: { a:1, b:2 }, beta: { x:3, y:4} } 

But the main problem with this approach is that I cannot have different configuration for the same "component" because the last will override the previous ones. So here, the array is the best choice:

components [ {alpha: { a:1, b:2 }}, {beta: { x:3, y:4}}, {beta: { x:5, y:6}} ]  

But the syntax it is not so clean as it would be expected. Much better would be:

components [ alpha = { a:1, b:2 }, beta = { x:3, y:4 }, beta = { x:5, y:6 } ]   

from config.

ericacm avatar ericacm commented on July 24, 2024

+1

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.