• Re: ANNOUNCE: conf 1.0

    From Harald Oehlmann@21:1/5 to All on Thu Nov 10 14:10:24 2022
    Am 10.11.2022 um 13:59 schrieb Oleg Nemanov:
    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.

    Thanks, Oleg, sounds great !
    I also like your name in Cyrillic font!

    Thanks,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oleg Nemanov@21:1/5 to All on Thu Nov 10 04:59:44 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?0J7Qu9C10LMg0J0u?=@21:1/5 to All on Thu Nov 10 04:56:53 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oleg Nemanov@21:1/5 to All on Thu Nov 10 05:47:24 2022
    0YfQtdGC0LLQtdGA0LMsIDEwINC90L7Rj9Cx0YDRjyAyMDIyINCzLiDQsiAxNjoxMDozNyBVVEMr MywgSGFyYWxkIE9laGxtYW5uOg0KPiBJIGFsc28gbGlrZSB5b3VyIG5hbWUgaW4gQ3lyaWxsaWMg Zm9udCEgDQoNCjotRA0KDQo=

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oleg Nemanov@21:1/5 to All on Fri Nov 11 00:12:17 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Fri Nov 11 09:31:02 2022
    Am 11.11.2022 um 09:22 schrieb Oleg Nemanov:
    пятница, 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".

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oleg Nemanov@21:1/5 to All on Fri Nov 11 00:22:56 2022
    пятница, 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".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oleg Nemanov@21:1/5 to All on Fri Nov 11 00:46:41 2022
    пятница, 11 ноября 2022 г. в 11:31:07 UTC+3, Harald Oehlmann:
    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.

    I agree. It would be great.

    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

    Shimmering to a list is not good, i think. By the way, i think i made some error in my benchmarks with catch. Now i've repeated it and difference in performance is not big.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Fri Nov 11 08:52:24 2022
    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?

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Fri Nov 11 13:29:43 2022
    Luc <[email protected]> wrote:
    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?

    No, because dict exists tells you if a given key exists inside the
    dict, i.e., it looks 'inside' the dict.

    proc isdict arg {
    if {[dict exists $arg]} {return 1}
    return 0
    }

    No?

    Did you give that a try before posting?

    $ rlwrap tclsh
    % proc isdict arg {
    if {[dict exists $arg]} {return 1}
    return 0
    }
    % set v [dict create a b c d]
    a b c d
    % isdict $v
    wrong # args: should be "dict exists dictionary key ?key ...?"
    %

    'dict exists' provides the same functionality as 'array exists' (except
    for dicts).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)