SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
ACCESS TO NONLOCAL
NAMES
Shashwat Shriparv
dwivedishashwat@gmail.com
InfinitySoft
Access Links
• A direct implementation of lexical scope for
nested procedures is obtained by adding a
pointer called an access link to each
activation record.
• If procedure p is nested immediately within
q in the source text,then the access link in
an activation record for p points to the
access link in the record for the most recent
activation of q.
Nesting
Depth=3
Nesting
Depth=2
Nesting
Depth=1
Nesting
Depth=2
Access Links (Static Links)
s
a x
q(1,9)
access
k v
s
a x
q(1,9)
access
k v
q(1,3)
access
k v
s
a x
q(1,9)
access
k v
q(1,3)
access
k v
p(1,3)
access
i j
s
a x
q(1,9)
access
k v
q(1,3)
access
k v
p(1,3)
access
i j
e(1,3)
access
The access link points to the
activation record of the static
parent procedure:
s is parent of r, e, and q
q is parent of p
Suppose procedure p at nesting depth np
refers to a non local a with nesting depth
na<=np.The storage for ‘a’ can be found as
follows.
1. When control is in p, an activation record
for p is at the top of the stack. Follow np –na
access links from the record at the top of the
stack. The value of np –na can be
precomputed at compile time
2. After following np –na links, we reach an
activation record for the procedure that a is
local to.
DISPLAYS
Faster access to nonlocals than with
access links can be obtained using an array
d of pointers to activation records,called a
display. We maintain the display so that
storage for a nonlocal ‘a’ at nesting depth i
is in the activation record pointed to by
display element d[i].
Access to non local names
Using a display is generally faster than
following access links because the
activation record holding a nonlocal is
found by accessing an element of d and then
following just one pointer.
The display changes when a new
activation occurs,and it must be reset when
control returns from the new activation.
When a new activation record for a
procedure at nesting depth i is set up,we
1.Save the value of d[i] in the new
activation record and
2.Set d[i] to point to the new activation
record.
Just before an activation ends,d[i] is reset
to the saved value.
Suppose a procedure at nesting depth j calls
a procedure at depth i.There are two
cases,depending on whether or not the
called procedure is nested within the caller
in the source text,as in the discussion of
access links.
1. Case j<i.Then i=j+1 and the called
procedure is nested within the caller.The
first j elements of the display therefore do not need
to be changed,and we set d[i] to the new activation
record.
2.Case j>=i. Again the enclosing procedures at
nesting depths 1,2,…,i-1 of the called and calling
procedure must be the same. Here,we save the old
value of d[i] in the new activation record, and
make d[i] point to the new activation record.
DYNAMIC SCOPE
Under dynamic scope,a new activation
inherits the existing bindings of nonlocal
names to storage.A nonlocal name ‘a’ in the
called activation refers to the same storage
that it did in the calling activation.New
bindings are set up for local names of the
called procedure;the names refer to storage
in the new activation record.
Access to non local names
The following two approaches to implementing
dynamic scope bear some resemblance to the use
of access links and displays, respectively in the
implementation of lexical scope.
1.Deep access. Conceptually, dynamic scope results
if access links point to the same activation records
that control links do. The term deep access comes
from the fact that the search goes deep into the
stack.
• Shallow access. Here, the idea is to hold the
current value of each name in statically
allocated storage. When a new activation of
a procedure p occurs, a local name n in p
takes over the storage statically allocated
for n.The previous value of n can be saved
in the activation record for p and must be
restored when the activation of p ends.
The trade-off between the two
approaches is that deep access takes longer
to access a nonlocal,but there is no
overhead associated with beginning and
ending an activation. Shallow access on the
other hand allows nonlocals to be looked up
directly, but time is taken to maintain these
values when activations begin and end.
THANK YOU…
Shashwat Shriparv
dwivedishashwat@gmail.com
InfinitySoft

Contenu connexe

Tendances

Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123Ankita Goyal
 
Target language in compiler design
Target language in compiler designTarget language in compiler design
Target language in compiler designMuhammad Haroon
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environmentIffat Anjum
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mountingrajshreemuthiah
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategiesDr. Loganathan R
 
Process management os concept
Process management os conceptProcess management os concept
Process management os conceptpriyadeosarkar91
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler designSudip Singh
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))Papu Kumar
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dhrumil Panchal
 
Inter process communication
Inter process communicationInter process communication
Inter process communicationPradeep Kumar TS
 
Address in the target code in Compiler Construction
Address in the target code in Compiler ConstructionAddress in the target code in Compiler Construction
Address in the target code in Compiler ConstructionMuhammad Haroon
 

Tendances (20)

Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123
 
Target language in compiler design
Target language in compiler designTarget language in compiler design
Target language in compiler design
 
Heap Management
Heap ManagementHeap Management
Heap Management
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mounting
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
garbage collector
garbage collectorgarbage collector
garbage collector
 
Daa unit 5
Daa unit 5Daa unit 5
Daa unit 5
 
Distributed Systems Naming
Distributed Systems NamingDistributed Systems Naming
Distributed Systems Naming
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
 
Run time storage
Run time storageRun time storage
Run time storage
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Address in the target code in Compiler Construction
Address in the target code in Compiler ConstructionAddress in the target code in Compiler Construction
Address in the target code in Compiler Construction
 

En vedette (19)

Compiler design
Compiler designCompiler design
Compiler design
 
Compiler design
Compiler designCompiler design
Compiler design
 
Erp
ErpErp
Erp
 
Cdma
CdmaCdma
Cdma
 
Linux 4 you
Linux 4 youLinux 4 you
Linux 4 you
 
Fragmentation
FragmentationFragmentation
Fragmentation
 
Email
EmailEmail
Email
 
Apple i phone
Apple i phoneApple i phone
Apple i phone
 
How to Study for Tests
How to Study for TestsHow to Study for Tests
How to Study for Tests
 
Data base design
Data base designData base design
Data base design
 
Cluster computing
Cluster computingCluster computing
Cluster computing
 
History of simulation software
History of simulation softwareHistory of simulation software
History of simulation software
 
File records on disk
File records on diskFile records on disk
File records on disk
 
Grid computing
Grid computingGrid computing
Grid computing
 
Cumulative distribution
Cumulative distributionCumulative distribution
Cumulative distribution
 
Exception handling java
Exception handling javaException handling java
Exception handling java
 
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
 
Digital water marking
Digital water markingDigital water marking
Digital water marking
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 

Similaire à Access to non local names

Intermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfIntermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfHimanshu883663
 
Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...Aori Nevo, PhD
 
OmniBase Object Database
OmniBase Object DatabaseOmniBase Object Database
OmniBase Object DatabaseESUG
 
System Verilog Functional Coverage
System Verilog Functional CoverageSystem Verilog Functional Coverage
System Verilog Functional Coveragerraimi
 
09 implementing+subprograms
09 implementing+subprograms09 implementing+subprograms
09 implementing+subprogramsbaran19901990
 
Cloudproject
CloudprojectCloudproject
Cloudprojectanushv24
 
Runtimeenvironment
RuntimeenvironmentRuntimeenvironment
RuntimeenvironmentAnusuya123
 

Similaire à Access to non local names (11)

Ch7
Ch7Ch7
Ch7
 
Intermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfIntermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdf
 
Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...
 
OmniBase Object Database
OmniBase Object DatabaseOmniBase Object Database
OmniBase Object Database
 
Compiler Design Unit 4
Compiler Design Unit 4Compiler Design Unit 4
Compiler Design Unit 4
 
System Verilog Functional Coverage
System Verilog Functional CoverageSystem Verilog Functional Coverage
System Verilog Functional Coverage
 
Run time administration
Run time administrationRun time administration
Run time administration
 
09 implementing+subprograms
09 implementing+subprograms09 implementing+subprograms
09 implementing+subprograms
 
Cloudproject
CloudprojectCloudproject
Cloudproject
 
Runtimeenvironment
RuntimeenvironmentRuntimeenvironment
Runtimeenvironment
 
Helix talk at RelateIQ
Helix talk at RelateIQHelix talk at RelateIQ
Helix talk at RelateIQ
 

Plus de Shashwat Shriparv (20)

Learning Linux Series Administrator Commands.pptx
Learning Linux Series Administrator Commands.pptxLearning Linux Series Administrator Commands.pptx
Learning Linux Series Administrator Commands.pptx
 
LibreOffice 7.3.pptx
LibreOffice 7.3.pptxLibreOffice 7.3.pptx
LibreOffice 7.3.pptx
 
Kerberos Architecture.pptx
Kerberos Architecture.pptxKerberos Architecture.pptx
Kerberos Architecture.pptx
 
Suspending a Process in Linux.pptx
Suspending a Process in Linux.pptxSuspending a Process in Linux.pptx
Suspending a Process in Linux.pptx
 
Kerberos Architecture.pptx
Kerberos Architecture.pptxKerberos Architecture.pptx
Kerberos Architecture.pptx
 
Command Seperators.pptx
Command Seperators.pptxCommand Seperators.pptx
Command Seperators.pptx
 
Upgrading hadoop
Upgrading hadoopUpgrading hadoop
Upgrading hadoop
 
Hadoop migration and upgradation
Hadoop migration and upgradationHadoop migration and upgradation
Hadoop migration and upgradation
 
R language introduction
R language introductionR language introduction
R language introduction
 
Hive query optimization infinity
Hive query optimization infinityHive query optimization infinity
Hive query optimization infinity
 
H base introduction & development
H base introduction & developmentH base introduction & development
H base introduction & development
 
Hbase interact with shell
Hbase interact with shellHbase interact with shell
Hbase interact with shell
 
H base development
H base developmentH base development
H base development
 
Hbase
HbaseHbase
Hbase
 
H base
H baseH base
H base
 
My sql
My sqlMy sql
My sql
 
Apache tomcat
Apache tomcatApache tomcat
Apache tomcat
 
Introduction to apache hadoop
Introduction to apache hadoopIntroduction to apache hadoop
Introduction to apache hadoop
 
Next generation technology
Next generation technologyNext generation technology
Next generation technology
 
Configure h base hadoop and hbase client
Configure h base hadoop and hbase clientConfigure h base hadoop and hbase client
Configure h base hadoop and hbase client
 

Dernier

Entrepreneurship & organisations: influences and organizations
Entrepreneurship & organisations: influences and organizationsEntrepreneurship & organisations: influences and organizations
Entrepreneurship & organisations: influences and organizationsP&CO
 
Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)
Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)
Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)tazeenaila12
 
Chicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdf
Chicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdfChicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdf
Chicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdfSourav Sikder
 
Introduction to The overview of GAAP LO 1-5.pptx
Introduction to The overview of GAAP LO 1-5.pptxIntroduction to The overview of GAAP LO 1-5.pptx
Introduction to The overview of GAAP LO 1-5.pptxJemalSeid25
 
Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024Winbusinessin
 
Anyhr.io | Presentation HR&Recruiting agency
Anyhr.io | Presentation HR&Recruiting agencyAnyhr.io | Presentation HR&Recruiting agency
Anyhr.io | Presentation HR&Recruiting agencyHanna Klim
 
Lecture_6.pptx English speaking easyb to
Lecture_6.pptx English speaking easyb toLecture_6.pptx English speaking easyb to
Lecture_6.pptx English speaking easyb toumarfarooquejamali32
 
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...IMARC Group
 
Plano de marketing- inglês em formato ppt
Plano de marketing- inglês  em formato pptPlano de marketing- inglês  em formato ppt
Plano de marketing- inglês em formato pptElizangelaSoaresdaCo
 
NewBase 25 March 2024 Energy News issue - 1710 by Khaled Al Awadi_compress...
NewBase  25 March  2024  Energy News issue - 1710 by Khaled Al Awadi_compress...NewBase  25 March  2024  Energy News issue - 1710 by Khaled Al Awadi_compress...
NewBase 25 March 2024 Energy News issue - 1710 by Khaled Al Awadi_compress...Khaled Al Awadi
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access
 
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptxHELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptxHelene Heckrotte
 
7movierulz.uk
7movierulz.uk7movierulz.uk
7movierulz.ukaroemirsr
 
Live-Streaming in the Music Industry Webinar
Live-Streaming in the Music Industry WebinarLive-Streaming in the Music Industry Webinar
Live-Streaming in the Music Industry WebinarNathanielSchmuck
 
UNLEASHING THE POWER OF PROGRAMMATIC ADVERTISING
UNLEASHING THE POWER OF PROGRAMMATIC ADVERTISINGUNLEASHING THE POWER OF PROGRAMMATIC ADVERTISING
UNLEASHING THE POWER OF PROGRAMMATIC ADVERTISINGlokeshwarmaha
 
Upgrade Your Banking Experience with Advanced Core Banking Applications
Upgrade Your Banking Experience with Advanced Core Banking ApplicationsUpgrade Your Banking Experience with Advanced Core Banking Applications
Upgrade Your Banking Experience with Advanced Core Banking ApplicationsIntellect Design Arena Ltd
 
Project Brief & Information Architecture Report
Project Brief & Information Architecture ReportProject Brief & Information Architecture Report
Project Brief & Information Architecture Reportamberjiles31
 

Dernier (20)

Entrepreneurship & organisations: influences and organizations
Entrepreneurship & organisations: influences and organizationsEntrepreneurship & organisations: influences and organizations
Entrepreneurship & organisations: influences and organizations
 
Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)
Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)
Harvard Business Review.pptx | Navigating Labor Unrest (March-April 2024)
 
Chicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdf
Chicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdfChicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdf
Chicago Medical Malpractice Lawyer Chicago Medical Malpractice Lawyer.pdf
 
Introduction to The overview of GAAP LO 1-5.pptx
Introduction to The overview of GAAP LO 1-5.pptxIntroduction to The overview of GAAP LO 1-5.pptx
Introduction to The overview of GAAP LO 1-5.pptx
 
Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024
 
Anyhr.io | Presentation HR&Recruiting agency
Anyhr.io | Presentation HR&Recruiting agencyAnyhr.io | Presentation HR&Recruiting agency
Anyhr.io | Presentation HR&Recruiting agency
 
Lecture_6.pptx English speaking easyb to
Lecture_6.pptx English speaking easyb toLecture_6.pptx English speaking easyb to
Lecture_6.pptx English speaking easyb to
 
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
 
Plano de marketing- inglês em formato ppt
Plano de marketing- inglês  em formato pptPlano de marketing- inglês  em formato ppt
Plano de marketing- inglês em formato ppt
 
NewBase 25 March 2024 Energy News issue - 1710 by Khaled Al Awadi_compress...
NewBase  25 March  2024  Energy News issue - 1710 by Khaled Al Awadi_compress...NewBase  25 March  2024  Energy News issue - 1710 by Khaled Al Awadi_compress...
NewBase 25 March 2024 Energy News issue - 1710 by Khaled Al Awadi_compress...
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024
 
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptxHELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
 
Investment Opportunity for Thailand's Automotive & EV Industries
Investment Opportunity for Thailand's Automotive & EV IndustriesInvestment Opportunity for Thailand's Automotive & EV Industries
Investment Opportunity for Thailand's Automotive & EV Industries
 
7movierulz.uk
7movierulz.uk7movierulz.uk
7movierulz.uk
 
Live-Streaming in the Music Industry Webinar
Live-Streaming in the Music Industry WebinarLive-Streaming in the Music Industry Webinar
Live-Streaming in the Music Industry Webinar
 
UNLEASHING THE POWER OF PROGRAMMATIC ADVERTISING
UNLEASHING THE POWER OF PROGRAMMATIC ADVERTISINGUNLEASHING THE POWER OF PROGRAMMATIC ADVERTISING
UNLEASHING THE POWER OF PROGRAMMATIC ADVERTISING
 
WAM Corporate Presentation Mar 25 2024.pdf
WAM Corporate Presentation Mar 25 2024.pdfWAM Corporate Presentation Mar 25 2024.pdf
WAM Corporate Presentation Mar 25 2024.pdf
 
Upgrade Your Banking Experience with Advanced Core Banking Applications
Upgrade Your Banking Experience with Advanced Core Banking ApplicationsUpgrade Your Banking Experience with Advanced Core Banking Applications
Upgrade Your Banking Experience with Advanced Core Banking Applications
 
Project Brief & Information Architecture Report
Project Brief & Information Architecture ReportProject Brief & Information Architecture Report
Project Brief & Information Architecture Report
 

Access to non local names

  • 1. ACCESS TO NONLOCAL NAMES Shashwat Shriparv dwivedishashwat@gmail.com InfinitySoft
  • 2. Access Links • A direct implementation of lexical scope for nested procedures is obtained by adding a pointer called an access link to each activation record. • If procedure p is nested immediately within q in the source text,then the access link in an activation record for p points to the access link in the record for the most recent activation of q.
  • 4. Access Links (Static Links) s a x q(1,9) access k v s a x q(1,9) access k v q(1,3) access k v s a x q(1,9) access k v q(1,3) access k v p(1,3) access i j s a x q(1,9) access k v q(1,3) access k v p(1,3) access i j e(1,3) access The access link points to the activation record of the static parent procedure: s is parent of r, e, and q q is parent of p
  • 5. Suppose procedure p at nesting depth np refers to a non local a with nesting depth na<=np.The storage for ‘a’ can be found as follows. 1. When control is in p, an activation record for p is at the top of the stack. Follow np –na access links from the record at the top of the stack. The value of np –na can be precomputed at compile time
  • 6. 2. After following np –na links, we reach an activation record for the procedure that a is local to.
  • 7. DISPLAYS Faster access to nonlocals than with access links can be obtained using an array d of pointers to activation records,called a display. We maintain the display so that storage for a nonlocal ‘a’ at nesting depth i is in the activation record pointed to by display element d[i].
  • 9. Using a display is generally faster than following access links because the activation record holding a nonlocal is found by accessing an element of d and then following just one pointer. The display changes when a new activation occurs,and it must be reset when control returns from the new activation.
  • 10. When a new activation record for a procedure at nesting depth i is set up,we 1.Save the value of d[i] in the new activation record and 2.Set d[i] to point to the new activation record. Just before an activation ends,d[i] is reset to the saved value.
  • 11. Suppose a procedure at nesting depth j calls a procedure at depth i.There are two cases,depending on whether or not the called procedure is nested within the caller in the source text,as in the discussion of access links. 1. Case j<i.Then i=j+1 and the called procedure is nested within the caller.The
  • 12. first j elements of the display therefore do not need to be changed,and we set d[i] to the new activation record. 2.Case j>=i. Again the enclosing procedures at nesting depths 1,2,…,i-1 of the called and calling procedure must be the same. Here,we save the old value of d[i] in the new activation record, and make d[i] point to the new activation record.
  • 13. DYNAMIC SCOPE Under dynamic scope,a new activation inherits the existing bindings of nonlocal names to storage.A nonlocal name ‘a’ in the called activation refers to the same storage that it did in the calling activation.New bindings are set up for local names of the called procedure;the names refer to storage in the new activation record.
  • 15. The following two approaches to implementing dynamic scope bear some resemblance to the use of access links and displays, respectively in the implementation of lexical scope. 1.Deep access. Conceptually, dynamic scope results if access links point to the same activation records that control links do. The term deep access comes from the fact that the search goes deep into the stack.
  • 16. • Shallow access. Here, the idea is to hold the current value of each name in statically allocated storage. When a new activation of a procedure p occurs, a local name n in p takes over the storage statically allocated for n.The previous value of n can be saved in the activation record for p and must be restored when the activation of p ends.
  • 17. The trade-off between the two approaches is that deep access takes longer to access a nonlocal,but there is no overhead associated with beginning and ending an activation. Shallow access on the other hand allows nonlocals to be looked up directly, but time is taken to maintain these values when activations begin and end.