Tk Library Source Code

View Ticket
Login
Ticket UUID: 1540192
Title: RFE: add comm::comm alias subcmd (similar to interp alias)
Type: RFE Version: None
Submitter: hemanglavana Created on: 2006-08-14 20:14:38
Subsystem: comm Assigned To: andreas_kupries
Priority: 7 High Severity:
Status: Closed Last Modified: 2006-08-30 22:34:10
Resolution: Closed By: andreas_kupries
    Closed on: 2006-08-30 15:34:10
Description:
Hi,

The comm package should support an alias sub-command
which behaves similar to [interp alias] command with
the main difference that the aliased commands get
invoked on the remote process. 

Here's an example of how to acheive the same using a
wrapper proc:

set rmt_id [getRemoteCommId]
set lcl_id [comm::comm selfid]

proc commAlias {lcl_id lcl_proc rmt_id rmt_proc args} {
    # Create a local proc which will invoke the remote
    # proc via comm::comm send and return its results
    proc $lcl_proc args "uplevel 1 [list \
        comm::comm send $rmt_id $rmt_proc \
                        $args \$args]"
}

# Create an alias for the proc foo.
# Also pass $lcl_id as an argument so that the 
# remote proc knows where the request is coming from
commAlias $lcl_id foo $rmt_id foo $lcl_id

A "comm::comm alias" sub-command would make the above
setup very easy.

Thanks,
Hemang.
User Comments: andreas_kupries added on 2006-08-30 22:34:10:
Logged In: YES 
user_id=75003

Implemented in the CVS head, new module 'interp', doing
interp creation, and additional packages for the creation of
delegation procedures and methods (snit).

hemanglavana added on 2006-08-15 04:00:11:
Logged In: YES 
user_id=81875

"delegate" sounds good to me. And -async would be a nice
addition too -- it can be very useful for logging messages
to a central server where we know that the client doesn't
have to wait for any responses. The -command stuff can wait.

andreas_kupries added on 2006-08-15 03:46:47:
Logged In: YES 
user_id=75003

Makes sense. Easy client side.
Note: lcl_id aka local_id can be had automatically from the
comm channel used to setup the "alias".

Not really aliases, but forwarder, delegators ... I like the
last name, matches with what snit does.

More complex delegation would allow -async and -command.
-async is actually easy, -command can have a variety of
semantics, depending on when we wish to declare the callback
(when delegator is created, or when it is used).

Well, let us stay with the simple stuff first.