Hi, all.
conf package is pure-tcl package for loading a textual configuration data from file, channels and strings. It supports conf syntax with hierarchical and ini-style sections and key-value pairs where value can be string or list.
Source code: https://github.com/lego12239/conf.tcl
## Features
* conf syntax supports of hierarchical sections
* conf syntax support of ini-style sections
* conf syntax support of comments
* conf syntax support of file inclusion
* callback can be used on every key-value assignment to change a default behaviour drastically(you can even use a package only as parser and process a parsed key-value as you want)
* conf is parsed into 2 dicts: one is a parsed conf and another is a conf specification with info about value types. This is very important for working with parsed conf correctly. See Rationale section in the README.
* there are utility routines to help with conf spec checking.
пятница, 11 ноября 2022 г. в 11:12:20 UTC+3, Oleg Nemanov:
One problem i didn't solve is reporting of conf spec(or conf spec pattern) syntax errors in more meaningful form than "missing value to go with key".
This is done in _spec_cmp. In the chain of "elseif" should be an "else" where we test that $vpat is not dict(or string with 1 word). The simple way is
call "dict size" inside a catch. But i don't like this, because of the catch even for successful case is 3 times slower, then without it.
We have "string is list", but there is no "string is dict".
One problem i didn't solve is reporting of conf spec(or conf spec pattern) syntax errors in more meaningful form than "missing value to go with key".
This is done in _spec_cmp. In the chain of "elseif" should be an "else" where we test that $vpat is not dict(or string with 1 word). The simple way is
call "dict size" inside a catch. But i don't like this, because of the catch even for successful case is 3 times slower, then without it.
We have "string is list", but there is no "string is dict".Yes, "string is dict" was only included in 8.7.
It would be great to port this back to 8.6.
There are two solutions:
[string is list $s] && ([llength $s] % 2) == 0
or
![catch {dict size $s}]
The first shimmers a present dict to a list, the second pollutes the
error stack
We have "string is list", but there is no "string is dict".
We have "string is list", but there is no "string is dict".
Neither do we have [string is array] or [info isarray], but we have
[array exists].
I see there is a [dict exists] command. Can't one make do with it?
proc isdict arg {
if {[dict exists $arg]} {return 1}
return 0
}
No?
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 23:55:23 |
| Calls: | 12,105 |
| Calls today: | 5 |
| Files: | 15,006 |
| Messages: | 6,518,155 |