Dynamic variables

David R. Hanson, Todd A Proebsting

Research output: Contribution to journalArticle

2 Citations (Scopus)

Abstract

Most programming languages use static scope rules for associating uses of identifiers with their declarations. Static scope helps catch errors at compile time, and it can be implemented efficiently. Some popular languages - Perl, Tcl, TeX, and Postscript - offer dynamic scope, because dynamic scope works well for variables that "customize" the execution environment, for example. Programmers must simulate dynamic scope to implement this kind of usage in statically scoped languages. This paper describes the design and implementation of imperative language constructs for introducing and referencing dynamically scoped variables - dynamic variables for short. The design is a minimalist one, because dynamic variables are best used sparingly, much like exceptions. The facility does, however, cater to the typical uses for dynamic scope, and it provides a cleaner mechanism for so-called thread-local variables. A particularly simple implementation suffices for languages without exception handling. For languages with exception handling, a more efficient implementation builds on existing compiler infrastructure. Exception handling can be viewed as a control construct with dynamic scope. Likewise, dynamic variables are a data construct with dynamic scope.

Original languageEnglish (US)
Pages (from-to)264-270
Number of pages7
JournalSIGPLAN Notices (ACM Special Interest Group on Programming Languages)
Volume36
Issue number5
StatePublished - May 2001
Externally publishedYes

Fingerprint

Computer programming languages

Keywords

  • Control structures
  • D.3.3 [Programming Languages]: Language Constructs and Features - Dynamic scope
  • Languages

ASJC Scopus subject areas

  • Computer Graphics and Computer-Aided Design
  • Software

Cite this

Dynamic variables. / Hanson, David R.; Proebsting, Todd A.

In: SIGPLAN Notices (ACM Special Interest Group on Programming Languages), Vol. 36, No. 5, 05.2001, p. 264-270.

Research output: Contribution to journalArticle

@article{c6a3fa3f193d4781b4a8596ba6be841a,
title = "Dynamic variables",
abstract = "Most programming languages use static scope rules for associating uses of identifiers with their declarations. Static scope helps catch errors at compile time, and it can be implemented efficiently. Some popular languages - Perl, Tcl, TeX, and Postscript - offer dynamic scope, because dynamic scope works well for variables that {"}customize{"} the execution environment, for example. Programmers must simulate dynamic scope to implement this kind of usage in statically scoped languages. This paper describes the design and implementation of imperative language constructs for introducing and referencing dynamically scoped variables - dynamic variables for short. The design is a minimalist one, because dynamic variables are best used sparingly, much like exceptions. The facility does, however, cater to the typical uses for dynamic scope, and it provides a cleaner mechanism for so-called thread-local variables. A particularly simple implementation suffices for languages without exception handling. For languages with exception handling, a more efficient implementation builds on existing compiler infrastructure. Exception handling can be viewed as a control construct with dynamic scope. Likewise, dynamic variables are a data construct with dynamic scope.",
keywords = "Control structures, D.3.3 [Programming Languages]: Language Constructs and Features - Dynamic scope, Languages",
author = "Hanson, {David R.} and Proebsting, {Todd A}",
year = "2001",
month = "5",
language = "English (US)",
volume = "36",
pages = "264--270",
journal = "ACM SIGPLAN Notices",
issn = "1523-2867",
publisher = "Association for Computing Machinery (ACM)",
number = "5",

}

TY - JOUR

T1 - Dynamic variables

AU - Hanson, David R.

AU - Proebsting, Todd A

PY - 2001/5

Y1 - 2001/5

N2 - Most programming languages use static scope rules for associating uses of identifiers with their declarations. Static scope helps catch errors at compile time, and it can be implemented efficiently. Some popular languages - Perl, Tcl, TeX, and Postscript - offer dynamic scope, because dynamic scope works well for variables that "customize" the execution environment, for example. Programmers must simulate dynamic scope to implement this kind of usage in statically scoped languages. This paper describes the design and implementation of imperative language constructs for introducing and referencing dynamically scoped variables - dynamic variables for short. The design is a minimalist one, because dynamic variables are best used sparingly, much like exceptions. The facility does, however, cater to the typical uses for dynamic scope, and it provides a cleaner mechanism for so-called thread-local variables. A particularly simple implementation suffices for languages without exception handling. For languages with exception handling, a more efficient implementation builds on existing compiler infrastructure. Exception handling can be viewed as a control construct with dynamic scope. Likewise, dynamic variables are a data construct with dynamic scope.

AB - Most programming languages use static scope rules for associating uses of identifiers with their declarations. Static scope helps catch errors at compile time, and it can be implemented efficiently. Some popular languages - Perl, Tcl, TeX, and Postscript - offer dynamic scope, because dynamic scope works well for variables that "customize" the execution environment, for example. Programmers must simulate dynamic scope to implement this kind of usage in statically scoped languages. This paper describes the design and implementation of imperative language constructs for introducing and referencing dynamically scoped variables - dynamic variables for short. The design is a minimalist one, because dynamic variables are best used sparingly, much like exceptions. The facility does, however, cater to the typical uses for dynamic scope, and it provides a cleaner mechanism for so-called thread-local variables. A particularly simple implementation suffices for languages without exception handling. For languages with exception handling, a more efficient implementation builds on existing compiler infrastructure. Exception handling can be viewed as a control construct with dynamic scope. Likewise, dynamic variables are a data construct with dynamic scope.

KW - Control structures

KW - D.3.3 [Programming Languages]: Language Constructs and Features - Dynamic scope

KW - Languages

UR - http://www.scopus.com/inward/record.url?scp=18844431882&partnerID=8YFLogxK

UR - http://www.scopus.com/inward/citedby.url?scp=18844431882&partnerID=8YFLogxK

M3 - Article

AN - SCOPUS:18844431882

VL - 36

SP - 264

EP - 270

JO - ACM SIGPLAN Notices

JF - ACM SIGPLAN Notices

SN - 1523-2867

IS - 5

ER -