Deutsch   English   Français   Italiano  
<vnbk2j$20pk0$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: aotto1968 <aotto1968@t-online.de>
Newsgroups: comp.lang.tcl
Subject: Re: OK, what looks better. The OLD tcl-oo or the NEW tcl-oo?
Date: Tue, 28 Jan 2025 23:00:51 +0100
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <vnbk2j$20pk0$1@dont-email.me>
References: <vlqmit$3tm2o$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 28 Jan 2025 23:00:51 +0100 (CET)
Injection-Info: dont-email.me; posting-host="85159161014cc15daee782a5c640db29";
	logging-data="2123392"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/ZGXLD/fchJ0Ugz9rOdLalM9P+hei3rCs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NgIjkqL8S1Neq7yeza+C/gsiPcs=
Content-Language: en-US
In-Reply-To: <vlqmit$3tm2o$1@dont-email.me>
Bytes: 2498

I'm still struggling with myself as to whether "myoo" should be reference-based or namespace-based.
after doing some research with the tcl-only API, I've now switched to C. Unfortunately, the public namespace C API is rather 
weak and only "string" based, which has now prompted me to switch to the semi-public "Int" API, where at least there is usable 
"namespace" support. After the first analysis, I can now say that "namespace-based" is currently faster.

package require libmyoox
 > 1.0

::myooX::ClassN ::MyClassN {
   proc MyClassN {myNs num} {
     namespace upvar $myNs my my
     set my(num) $num
   }
   proc get {myNs} {
     namespace upvar $myNs my my
     set my(num)
   }
}
 > ::MyClassN::cls

::myooX::ClassN ::MyClassR {
   proc MyClassR {myRef num} {
     upvar $myRef my
     set my(num) $num
   }
   proc get {myRef} {
     upvar $myRef my
     set my(num)
   }
}
 > ::MyClassR::cls

set ns1   [::myooX::NewN ::MyClassN 1]
 > ::MyClassN::MyClassN-1
set ref2  [::myooX::NewR ::MyClassR::cls 2]
 > ::MyClassR::MyClassR-1::my

::MyClassN::get $ns1
 > 1
::MyClassR::get $ref2
 > 2

time {::myooX::NewN ::MyClassN       1 } 10000
 > 10.244 microseconds per iteration
time {::myooX::NewR ::MyClassR::cls  2 } 10000
 > 15.086 microseconds per iteration

time {::MyClassN::get $ns1  } 10000
 > 1.6015 microseconds per iteration
time {::MyClassR::get $ref2 } 10000
 > 2.4201 microseconds per iteration