Proposal: use spaces instead of periods for hierarchical separation #90

Closed
eric opened this Issue Feb 24, 2013 · 11 comments

Comments

Projects
None yet

eric commented Feb 24, 2013

The .gitconfig uses spaces instead of periods to specify multiple levels of hierarchy, so instead of:

[parent.child]
key = 5

It would be

[parent child]
key = 5

One benefit of this is it would allow multi-word keys (if that was desirable).

[parent "child with spaces"]
key = 5

for instance.

Contributor

jamesmoss commented Feb 24, 2013

You can already use spaces

[parent.child with spaces]
key = 5

liuggio commented Feb 25, 2013

-1

jcoene commented Feb 25, 2013

+1

While working in a Chef repo (the type of configuration I'd love to use TOML for) it occurred to me that the current period notation for keys seems especially poorly suited to host configuration.

Imagine translating this JSON to TOML:

"munin": {
  "hosts": {
    "host1.sub.dom.com": { .... },
    "host1.sub.dom.com": { .... }
  }
}

or

"sysctl": {
  "net.ipv4.tcp_tw_recycle": 1,
  "net.ipv4.tcp_tw_reuse": 1
}

or

"statsd": {
  "site.controller.home.show.count": {
    "type": "counter"
  },
  "site.controller.home.show.duration": {
    "type": "measurement"
  }
}

As far as I can tell, TOML currently doesn't allow for periods in keys for hash objects. Under the current spec, the application would need to traverse the tree with it's own expectation of how the keys are supposed to be transformed. This seems like a bad idea.

rcarver commented Feb 28, 2013

👍 the hosts example is pretty interesting @jcoene.

+1 I like how readable it becomes with spaces.

[munin hosts host1.sub.dom.com]
    ....
[munin hosts host2.sub.dom.com]
    ....

Whichever separator is used... if you support arbitrary keys you need a way to escape it.

[a.b."key.with.dots.in"]

[a b "key with spaces in"]

see also mojombo#185

fisherl commented Apr 4, 2013

hello

2013-04-04

fisherl2011

发件人:Nigel Thorne notifications@github.com
发送时间:2013-04-03 09:10
主题:Re: [toml] Proposal: use spaces instead of periods for hierarchical separation (#90)
收件人:"mojombo/toml"toml@noreply.github.com
抄送:

+1 I like how readable it becomes with spaces.
[munin hosts host1.sub.dom.com]
....
[munin hosts host2.sub.dom.com]
....

Whichever separator is used... if you support arbitrary keys you need a way to escape it.
[a.b."key.with.dots.in"]

[a b "key with spaces in"]

see also #185

Reply to this email directly or view it on GitHub.

Contributor

rossipedia commented Apr 8, 2013

👍

sorbits commented Jul 4, 2013

it occurred to me that the current period notation for keys seems especially poorly suited to host configuration

I had a similar issue with email addresses, e.g.:

[foo@example.org]
name = "John Doe"

[bar@example.com]
name = "Jane Roe"

I propose that key groups support strings for literal keys, e.g. the above would become:

["foo@example.org"]
name = "John Doe"

["bar@example.org"]
name = "Jane Roe"

Somewhat related, should keys in key groups have leading/trailing whitespace stripped? E.g.:

[ servers.alpha ]
ip = 127.0.0.1

Should that result in the equivalent of config[" servers"]["alpha "]["ip"] = 127.0.0.1? Because this is how some TOML parsers interpret it.

88Alex commented Jul 4, 2013

Some suggestions:

#1: [parent|child|127.0.0.1]

#2: [parent>child>127.0.0.1]

#3: [parent][child][127.0.0.1]

@88Alex I think solution # 3 makes the most sense. As I explain in mojombo#185 (comment), spaces in keys are just as useful as periods :)

This was referenced Mar 10, 2014

Owner

BurntSushi commented Jun 25, 2014

The benefits of this, I think, would be subsumed by #220 with the added bonus that #220 is mostly backwards compatible. Closing.

@BurntSushi BurntSushi closed this Jun 25, 2014

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