|
2016-10-09
| ||
| 15:51 | • Closed ticket [f9c3463120]: Proposal syntax for list plus 6 other changes artifact: 2af7fb43df user: dkf | |
|
2016-08-29
| ||
| 21:52 | • Ticket [f9c3463120]: 3 changes artifact: fb622b30b8 user: ferrieux | |
| 21:35 | • Pending ticket [f9c3463120]. artifact: 4dfd7458e2 user: dgp | |
| 19:39 | • New ticket [f9c3463120]. artifact: 024c68e856 user: anonymous | |
Proposal syntax for list
Closed / Rejectedf9c3463120117afc9c86cbfe2d57da81dbc942e4Created 10 years agoUpdated 10 years ago
Descriptionplain2016-08-29 19:39:03
This is a proposal of a change in Tcl syntax:
When I want to create a big datastructure (with lists or dicts), I like to write the code in serveral lines for clarity. The problem with this expression: [comand_name arg0 arg1 arg2...] is that backslash are necessary if I want to write that expression in several lines. It's a little bit cumbersome:
set big_data_strucutre [dict \
key1 value1 \
key2 value2 \
key3 [list item1 item2 item3] \
key4 value4 \
key5 [list item1 [list item21 item22]] \
key6 value6]
Maybe it's better to make backslash optional inside square brackets (similar to braces). It's more clear and it's not necessary to type so much:
set big_data_strucutre [dict
key1 value1
key2 value2
key3 [list item1 item2 item3]
key4 value4
key5 [list item1 [list item21 item22]]
key6 value6]
dgpplain2016-08-29 21:35:02
To be clear, you are not proposing a change to
list syntax. You are proposing that a newline
cease being a command terminator in Tcl
script syntax. The remaining option would be
a semi-colon, I suppose, but I can offer little
hope this bridge would ever be crossed.
The good news is you can already have almost
what you want without changing any of Tcl's
syntax rules at all:
set big_data_strucutre [dict {*}"
key1 value1
key2 value2
key3 [list item1 item2 item3]
key4 value4
key5 [list item1 [list item21 item22]]
key6 value6"]
ferrieuxplain2016-08-29 21:52:01
And one can even make it simpler, knowing that Tcl will internally shimmer the value to a dict as soon as a dict primitive is used:
set big_data_strucutre "
key1 value1
key2 value2
key3 {item1 item2 item3}
key4 value4
key5 {item1 {item21 item22}}
key6 value6"
dkfplain2016-10-09 15:51:08
I concur. The likelihood that we'll make newline change interpretation in any context is very slight at best, and pretty much zero in this one as it is far more likely to break existing code. A <i>lot</i> of existing code at that.
Log in (anonymous is fine) to add a comment.