home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!eco.twg.com!twg.com!news
- From: "David Herron" <david@twg.com>
- Subject: Re: How do I imbed tcl in an application
- Message-ID: <1992Jul28.172451.16671@twg.com>
- Sensitivity: Personal
- Encoding: 52 TEXT
- Sender: news@twg.com (USENET News System)
- Conversion: Prohibited
- Organization: The Wollongong Group, Inc., Palo Alto, CA
- Conversion-With-Loss: Prohibited
- Date: Tue, 28 Jul 1992 17:26:36 GMT
- Lines: 52
-
- > How do I provide access to structures more complex than just strings?
- ..
- > typedef struct {
- > char *name;
- > int rank;
- > int ssn;
- > } Soldier;
- >
- > Soldier grunt;
- >
- > Now, is there any way I can pass ``grunt'' to a tcl proc and have it be
- > able to access grunt.name or grunt.rank ?
-
- Traditionally TCL has had you use `handles'. A handle is a character-string
- which is passed back to the TCL program, and which the TCL program supplies
- when it wants to manipulate that object. In the command-handler for each
- interested command, there must be a smidgeon of code which takes the handle and
- finds the object it refers to. Once the C code has that object, it can do
- whatever it likes with it.
-
- Then, if you want the TCL programmer to be able to manipulate things within
- the object, you provide a `soldier name <handle>' command. It looks up the handle
- and returns the name. Or it could look for a fourth argument, and use that to
- set the value.
-
- This all works. The supposedly most convenient way of coding the `handle'
- stuff is in the NeoSoft extensions. I have been able to make them work,
- but the explanation isn't the most clear and it isn't clear I'm making the
- best use of this facility.
-
- Another possible way is to use the key'd lists of the NeoSoft extensions.
- When returning a structure, instead of returning its handle you'd convert
- it into a key'd list. Then the TCL programmer would have to hand that key'd
- list back when it want's to do something. This seems, however, to cause a
- lot more overhead as the key'd list would have to be parsed over and over
- again. Also for lots of cases, the structure you're manipulating is the property
- of another module, which makes this strategy difficult.
-
- BTW,
-
- : jay jay@vnet.ibm.com My opinions and ideas, not my employer's.
- : shmdgljd@rchland.vnet.ibm.com (c) Copyright 1992. All rights reserved.
-
- This copyright notice is not compatible with Usenet. Usenet's inner soul
- and being involves copying and widely propogating everything it gets
- its hands on. But, a strict reading of this notice, prevents that sort
- of thing. Are you going to sue every Usenet site because of this? What is
- the point of such a broad claim?
-
- No need to respond in public..
-
- David
-