Re: tcl hidden "cruelties"

Liste des GroupesRevenir à cl tcl 
Sujet : Re: tcl hidden "cruelties"
De : aotto1968 (at) *nospam* t-online.de (aotto1968)
Groupes : comp.lang.tcl
Date : 12. Oct 2024, 13:46:49
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vedr3p$5rrn$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 11.10.24 14:27, Gerald Lester wrote:
On 10/10/24 05:20, aotto1968 wrote:
Hi,
>
...
>
Anyone who knows TCL knows that "refactoring" TCL code is cruel, because it always ends in a huge amount of "broken" code.
 Well I guess that is true if your code has lots of hidden dependencies and is otherwise not well designed in structured.
 
Regardless of "broken code", TCL itself has some cruelties in its syntax. Here, for example, the storage of an "array" with a namespace path, which in TCL always has !! TWO !! commands. ONE command to generate the namespace and ONE command to finally generate the array.
 Ah, I don't know of a single language, including Python, where the namespace does not have to be "defined" prior to things being "created" inside of it!
 
namespace eval ::funcDEF::MkErrN {}
array set ::funcDEF::MkErrN::my {
     RETURN_MAPPING                                     {}
     argv                                               {{ME_CXN_MK_MNGN mng}}
     class                                              MkErrorC
     classC                                             MkErrorC
     classM                                             ME_CCC_MkErrorC
     func                                               MkErrN
     prefix                                             Class
     prefixC                                            ClassC
     prefixM                                            ME_CCC_MkErrorC
     retC                                               MkErrorC
     retM                                               ME_CCN_MkErrorC
     retOM                                              ME_CCN_MkErrorC
     ty                                                 sm_
     type0M                                             ME_CXN_MK_MNGN
     var0                                               mng
}
 As Ralf Fassel noted, you could have done:
      namespace eval ::funcDEF::MkErrN {
       variable my
       array set my {
           RETURN_MAPPING {}
           ...
           var0 mng
       }
     }
 
this example has 3 commands
1. namespace eval
2. variable
3. array set
one more than my example
the core question is why the NS is *NOT* created by default.
-> If you can raise an error you can also create the namespace.
the core-issue here is that the "TCL" maintainer wants to protect the programmer for itself...
-> this is usually a "bad" habit because the maintainer try to know better what the programmer wants
    as the programmer itself.
just for the background, a "dynamic-namespace" in TCL is something like a "pointer" in C because a "POINTER" open an
"dynamic-namespace" in C. the TCL advantage is that you can choose a *good* name for the pointer, in my case something like
"::class::$instance" and the "::call::$instance::my" is just the instance memory.
the TCL maintainer has a view on the "namespace" feature like a traditional "namespace" in c++ or java etc but lost the
dynamic-pointer view of the "namespace".

Date Sujet#  Auteur
10 Oct 24 * tcl hidden "cruelties"12aotto1968
11 Oct 24 +- Re: tcl hidden "cruelties"1Ralf Fassel
11 Oct 24 +- Re: tcl hidden "cruelties"1Alan Grunwald
12 Oct 24 +* Re: tcl hidden "cruelties"3aotto1968
12 Oct 24 i`* Re: tcl hidden "cruelties"2Ralf Fassel
13 Oct 24 i `- Re: tcl hidden "cruelties"1aotto1968
13 Oct 24 +* Re: tcl hidden "cruelties"2aotto1968
20 Oct 24 i`- Re: tcl hidden "cruelties"1aotto1968
14 Oct 24 `* Re: tcl hidden "cruelties"4Rich
14 Oct 24  `* Re: tcl hidden "cruelties"3aotto1968
14 Oct 24   +- Re: tcl hidden "cruelties"1et99
14 Oct 24   `- Re: tcl hidden "cruelties"1Rich

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal