Giter Site home page Giter Site logo

Comments (5)

ordian avatar ordian commented on August 23, 2024

Thinking about this, what's the difference between dotted InlineTable and dotted Table?

from toml.

steveej avatar steveej commented on August 23, 2024

i don't feel confident that i can help clear up the definitions, but i'd like to make my expectations explicit:

[nixpkgs]
src.git = "https://git"

i'm also wondering which table is considered dotted here 🤔 it seems to be a property of the keys in the nixpkgs table rather than in the src table.

from toml.

ordian avatar ordian commented on August 23, 2024
[nixpkgs]
src.git = "https://git"

This is the expected output. And this code works:

use toml_edit::*;

fn main() {
    let mut d = Document::new();
    d["nixpkgs"] = table();
    
    d["nixpkgs"]["src"] = table();
    d["nixpkgs"]["src"].as_table_mut().unwrap().set_dotted(true);
    d["nixpkgs"]["src"]["git"] = value("https://github.com/nixos/nixpkgs");

    println!("{}", d);
}

from toml.

ordian avatar ordian commented on August 23, 2024

i'm also wondering which table is considered dotted here thinking it seems to be a property of the keys in the nixpkgs table rather than in the src table.

This is a TOML property, so src is a table (dotted), and git is the key of that table, see https://toml.io/en/v1.0.0 for details.

EDIT: actually TOML spec talks about dotted keys, not tables. But I in terms implementation, it might be harder to implement as a property of keys.

from toml.

epage avatar epage commented on August 23, 2024

Thinking about this, what's the difference between dotted InlineTable and dotted Table?

Ease of implementation :)

A dotted key in a standard table can have standard tables nested under it

[fruit]
apple.color = "red"
apple.taste.sweet = true

# [fruit.apple]  # INVALID
# [fruit.apple.taste]  # INVALID

[fruit.apple.texture]  # you can add sub-tables
smooth = true

But you can't do that with Inline Tables.

And the way the divide is currently implemented generally makes it easier to convert the data back to a string. I do have an idea that might allow us to fix this.

from toml.

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.