• require for "switch" a more free useable "falltrough" feature

    From aotto1968@21:1/5 to All on Sun Jul 17 12:09:53 2022
    Hi,

    *switch* has a *fallthrough* but only for the top-level:

    switch -glob aaab {
    a*b -
    b {expr {1}}
    a* {expr {2}}
    default {expr {3}}
    }

    I would like top have a *fallthrough* which act like a *continue* in while :

    switch -glob aaab {
    a*b {
    do-something
    fallthrough b ; # restart *switch* with "b" instead of "aaab"
    }
    b {expr {1}}
    a* {expr {2}}
    default {expr {3}}
    }

    Flow: "a*b" is doing some stuff and after *fallthrough* the *switch*
    restart with "b" stuff.
    *switch* get with *fallthrough* a "loop-like" feature.

    The reason for this requirement is the complicate simulation for
    *fallthrough* :

    set key aaab
    while true {
    switch -glob $key {
    a*b {
    do-something
    set key b
    continue
    }
    b {expr {1}}
    a* {expr {2}}
    default {expr {3}}
    }
    break
    }

    thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerald Lester@21:1/5 to All on Sat Jul 23 11:26:13 2022
    On 7/17/22 05:09, aotto1968 wrote:
    Hi,

    *switch* has a *fallthrough* but only for the top-level:

      switch -glob aaab {
          a*b     -
          b       {expr {1}}
          a*      {expr {2}}
          default {expr {3}}
      }

    I would like top have a *fallthrough* which act like a *continue* in
    while :

      switch -glob aaab {
          a*b     {
            do-something
            fallthrough b   ; # restart *switch* with "b" instead of "aaab"
          }
          b       {expr {1}}
          a*      {expr {2}}
          default {expr {3}}
      }

    Flow: "a*b" is doing some stuff and after *fallthrough* the *switch*
    restart with "b" stuff.
    *switch* get with *fallthrough* a "loop-like" feature.

    The reason for this requirement is the complicate simulation for *fallthrough* :

      set key aaab
      while true {
        switch -glob $key {
            a*b     {
              do-something
              set key b
              continue
            }
            b       {expr {1}}
            a*      {expr {2}}
            default {expr {3}}
        }
        break
      }

    thanks.


    Make a tip with the sample implementation.

    --
    +----------------------------------------------------------------------+
    | Gerald W. Lester, President, KNG Consulting LLC |
    | Email: Gerald.Lester@kng-consulting.net | +----------------------------------------------------------------------+

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