Toml: Clarify inline tables are immutable (and dotted keys can't "inject" into them)

Created on 16 Jun 2019  路  4Comments  路  Source: toml-lang/toml

You can't "inject" into inline tables with dotted keys. This isn't clear in the specification and we should clarify.

clarification

Most helpful comment

That would make a good counterexample for the spec, though.

How about this?


Inline tables are immutable. Once they are defined, new elements and subtables cannot be added to them.

a = {}
#a.b = 1  # INVALID
#[a.b]  # INVALID

I would avoid saying the word "inject." "Immutable" carries plenty of weight, so making that meaning clear ought to be sufficient.

All 4 comments

Also include below (if I am right):

a = {}
[a.b]
a = {}
[a.b]

This isn't valid. This is injecting a "b" key into an inline table defined "a".

That would make a good counterexample for the spec, though.

How about this?


Inline tables are immutable. Once they are defined, new elements and subtables cannot be added to them.

a = {}
#a.b = 1  # INVALID
#[a.b]  # INVALID

I would avoid saying the word "inject." "Immutable" carries plenty of weight, so making that meaning clear ought to be sufficient.

I'm going to have to change the wording. We don't want anyone to think that, when TOML is loaded into a data structure in a program, that the data structure must be immutable. Granted, it's not recommended to modify a configuration in a program. But what the program does with it is outside the scope of the specification.


Once inline tables are defined, their values are fully set, and new elements and subtables cannot be added to them.

a = {}
#a.b = 1  # INVALID
#[a.b]  # INVALID
Was this page helpful?
0 / 5 - 0 ratings