Tcl Source Code

View Ticket
Login
Ticket UUID: 672050
Title: function interface design and namespaces
Type: RFE Created on: 2003-01-21 21:10:10
Submitter: elfring Assigned to: vasiljevic
Subsystem: 80. Thread Package Severity:
Priority: 5 Medium Last modified: 2003-10-16 15:22:01
Status: Open Closed by:
Resolution: None Closed on:
Version: None
Description:
The programming interface for the thread package consists of 
several functions that are grouped into a few namespaces. A lot of 
functions have got a parameter/argument that specifies a 
subcommand at the first position.

How do you think about the 
following suggestion?
I would like to try an interface design like 
that:
Examples...
1. thread::mutex lock 
    instead of
    
thread::mutex::lock 

2. thread::cond::create
    instead 
of
    thread::cond create

3. tsv::array::names
    instead 
of
    tsv::array names

Does the increased use of 
namespace functions make a valuable difference in speed and 
maintenance?
Is it a step nearer to an object oriented TCL class 
library for thread programming?
User Comments:
nobody added on 2003-01-22 15:32:30:
Logged In: NO 

I have nothing against that. It will however yield no speed  
imporvements. Ok, the maintenance might be simpler.   
The ideal OO-like approach would be:  
  
set mutex [thread::mutex new]  
$mutex lock  
  
But, this would defeat the byte-compiler and impose speed  
limits. Also, since the "$mutex" command will then be   
limited to single interpreter, you'd loose the transparency  
of the item (in this case the mutex) among threads, so it will  
even more complicate the matter. Therefore, this is the  
approach I've dropped from further considerations. 
 
Which leaves us with your proposed change. As I said, I see 
no real problems in that. 
 
Zoran

dkf added on 2003-10-15 22:05:15:
Logged In: YES 
user_id=79902

What about leveraging TIP#112 in Tcl 8.5?

elfring added on 2003-10-16 15:22:01:
Logged In: YES 
user_id=572001

TIP #112: Ensembles are Namespaces are Commands
http://www.tcl.tk/cgi-bin/tct/tip/112.html

This will be an useful interface for the threads library, too.