DOC PREVIEW
GT AE 6382 - LECTURE NOTES

This preview shows page 1-2-3-4-5-33-34-35-36-66-67-68-69-70 out of 70 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 70 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1DRAFT (4/16/93): Distribution RestrictedChapter 27 Philosophy 25727.1 C vs. Tcl: primitives 25727.2 Object names 25927.3 Commands: action-oriented vs. object-oriented 26027.4 Application prefixes 26127.5 Representing information 262Chapter 28 Interpreters and Script Evaluation 26328.1 Interpreters 26328.2 A simple Tcl application 26328.3 Other evaluation procedures 26628.4 Deleting interpreters 266Chapter 29 Creating New Tcl Commands 26929.1 Command procedures 26929.2 Registering commands 27129.3 The result protocol 27229.4 Procedures for managing the result 27329.5 ClientData and deletion callbacks 27529.6 Deleting commands 278Chapter 30 Parsing 27930.1 Numbers and booleans 27930.2 Expression evaluation 28230.3 Manipulating lists 283Chapter 31 Exceptions 28531.1 Completion codes. 28531.2 Augmenting the stack trace in errorInfo 28831.3 Setting errorCode 2902DRAFT (4/16/93): Distribution RestrictedChapter 32 Accessing Tcl Variables 29132.1 Naming variables 29132.2 Setting variable values 29332.3 Reading variables 29532.4 Unsetting variables 29632.5 Setting and unsetting variable traces 29632.6 Trace callbacks 29732.7 Whole-array traces 29932.8 Multiple traces 29932.9 Unset callbacks 29932.10 Non-existent variables 30032.11 Querying trace information 300Chapter 33 Hash Tables 30133.1 Keys and values 30333.2 Creating and deleting hash tables 30333.3 Creating entries 30433.4 Finding existing entries 30533.5 Searching 30633.6 Deleting entries 30733.7 Statistics 307Chapter 34 String Utilities 30934.1 Dynamic strings 30934.2 Command completeness 31234.3 String matching 313Chapter 35 POSIX Utilities 31535.1 Tilde expansion 31535.2 Generating messages 3173DRAFT (4/16/93): Distribution Restricted35.3 Creating subprocesses 31835.4 Background processes 3194DRAFT (4/16/93): Distribution RestrictedPart III:Writing Tcl Applications in C256DRAFT (4/16/93): Distribution Restricted257Copyright © 1993 Addison-Wesley Publishing Company, Inc.All rights reserved. Duplication of this draft is permitted by individuals for personal use only. Anyother form of duplication or reproduction requires prior written permission of the author or pub-lisher. This statement must be easily visible on the first page of any reproduced copies. The publisherdoes not offer warranties in regard to this draft.Chapter 27PhilosophyThis part of the book describes how to write C applications based on Tcl. Since the Tclinterpreter is implemented as a C library package, it can be linked into any C or C++ pro-gram. The enclosing application invokes procedures in the Tcl library to create interpret-ers, evaluate Tcl scripts, and extend the built-in command set with new application-specific commands. Tcl also provides a number of utility procedures for use in implement-ing new commands; these procedures can be used to access Tcl variables, parse argu-ments, manipulate Tcl lists, evaluate Tcl expressions, and so on. This chapter discussesseveral high-level issues to consider when designing a Tcl application, such as what newTcl commands to implement, how to name objects, and what form to use for commandresults. The following chapters present the specific C interfaces provided by the Tcllibrary.Note: The interfaces described in Part III are those that will be available in Tcl 7.0, which hadnot been released at the timex this draft was prepared. Thus there may some differencesbetween what you read here and what you can do with your current version of Tcl. Thereare almost no differences in functionality; the differences mostly have to do with theinterfaces. Be sure to consult your manual entries when you actually write C code.27.1 C vs. Tcl: primitivesIn order to make a Tcl application as flexible and powerful as possible, you should orga-nize its C code as a set of new Tcl commands that provide a clean set of primitive opera-tions. You need not implement every imaginable feature in C, since new features canalways be implemented later as Tcl scripts. The purpose of the C code is to provide basicFIGURE 27TABLE 27258 PhilosophyDRAFT (4/16/93): Distribution Restrictedoperations that make it easy to implement a wide variety of useful scripts. If your C codelumps several functions together into a single command then it won’t be possible to writescripts that use the functions separately and your application won’t be very flexible orextensible. Instead, each command should provide a single function, and you should com-bine them together with Tcl scripts. You’ll probably find that many of your application’sessential features are implemented as scripts.Given a choice between implementing a particular piece of functionality as a Tclscript or as C code, it’s generally better to implement it as a script. Scripts are usually eas-ier to write, they can be modified dynamically, and you can debug them more quicklybecause you don’t have to recompile after each bug fix. However, there are three reasonswhy it is sometimes better to implement a new function in C. First, you may need toaccess low-level machine facilities that aren’t accessible in Tcl scripts. For example, theTcl built-in commands don’t provide access to network sockets, so if you want to use thenetwork you’ll have to write C code to do it. Second, you may be concerned about effi-ciency. For example, if you need to carry out intensive numerical calculations, or if youneed to operate on large arrays of data, you’ll be able to do it more efficiently in C than inTcl. The third reason for implementing in C is complexity. If you are manipulating com-plex data structures, or if you’re writing a large amount of code, the task will probably bemore manageable in C than in Tcl. Tcl provides very little structure; this makes it easy toconnect different things together but hard to manage large complex scripts. C providesmore structure, which is cumbersome when you’re implementing small things but indis-pensable when you’re implementing big complicated things.As an example, consider a program to manipulate weather reports. Suppose that infor-mation about current weather is available for a large number of measurement stations fromone or more network sites using a well-defined network protocol, and you want to write aTcl application to manipulate this data. Users of your application might wish to answerquestions like:• What is the complete weather situation at station X?• What is the current temperature at station X?• Which station in the country has the highest


View Full Document

GT AE 6382 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?