Header
Home | Sitemap  
Sections
Archive
Su Mo Tu We Th Fr Sa
1
2345678
9101112131415
16171819202122
23242526272829
30
Syndication



Duration of Identifiers(WML)

by

image

 
Duration of Identifiers
Chapters 13–15 used identifiers for variable names. The attributes of variables include
name, value and data type (such as string, number or boolean). We also use identifiers as
names for user-defined functions. Each identifier in a program has other attributes, including
duration and scope (discussed in section 16.8).
An identifier’s duration (also called its lifetime) is the period during which that identifier
exists in memory. Some identifiers exist briefly, some are repeatedly created and
destroyed and others exist for the entire execution of a script.
Identifiers that represent local variables in a function (i.e., parameters and variables
declared in the function body) have automatic duration. Automatic duration variables are
automatically created when program control enters the function in which they are declared,
they exist while the function in which they are declared is active and they are automatically
destroyed when the function in which they are declared is exited. For the remainder of the
text, we will refer to variables of automatic duration as local variables.
Software Engineering Observation 16.9
Automatic duration is a means of conserving memory, because automatic duration variables
are created when program control enters the function in which they are declared and are destroyed
when the function in which they are declared is exited. 16.9
Chapter 16 WMLScript: Functions 299
© Copyright 2001 by Deitel & Associates, Inc. All Rights Reserved. review Packet 5/7/01.
Software Engineering Observation 16.10
Automatic duration is an example of the principle of least privilege. This principle states that
each component of a system should have sufficient rights and privileges to accomplish its
designated task, but no additional rights or privileges. This helps prevent accidental and/or
malicious errors from occurring in systems. Why have variables stored in memory and accessible
when they are not needed? 16.10
WMLScript also has identifiers of static duration. Such identifiers are typically
defined within the WML or WMLScript document and exist from the point at which the
WML or WMLScript document is interpreted until the browsing session terminates (the
browser is closed by the user). Duration and scope (where a name can be used) are separate
issues, as shown in Section 16.8. Static duration variables (often called browser variables)
are globally accessible to the deck—i.e., every card in the deck can potentially use these
variables. Scripts called from a deck can access browser variables indirectly using the
WMLBrowser object’s getVar and setVar methods. For the remainder of the text, we
refer to variables of static duration as browser variables.
170 times read

Related news

» Scope Rules (WML)
by admin posted on Aug 28,2007
» Programmer-Defined Functions
by admin posted on Aug 28,2007
» wml script functions
by admin posted on Aug 28,2007
» Program Modules in WMLScript
by admin posted on Aug 24,2007
» Questions
by admin posted on Jul 19,2007


More Top News
Cisco Wireless Networking
Most Popular
Featured Author