Groups | Search | Server Info | Login | Register
Groups > comp.compilers > #174
| From | George Neuner <gneuner2@comcast.net> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: How to handle qualified identifiers such as x.y in a Pascal-like language |
| Date | 2011-06-25 17:11 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <11-06-048@comp.compilers> (permalink) |
| References | <11-06-037@comp.compilers> <11-06-040@comp.compilers> <11-06-044@comp.compilers> |
On Fri, 24 Jun 2011 13:58:23 +0200, "[Linux Magazine]" <uu3kw29sb7@snkmail.com> wrote: >In practice people do not write procedures in procedures that much, and >procedures in procedures in procedures are rare. Nested procedures and 1st class closures are very common in functional languages. C and its current popular variants don't permit them (though C++0x has added anonymous lambda) and so, IMO, too many programmers have no experience of their power. 1st class closures are more general and more powerful than most object systems - closures permit the construction of ad hoc objects that can bind arbitrary functions to arbitrary data without the need for class definitions or template objects. >This also means that you need efficient access to global variables and >variables local to the procedure currently being executed. Further the >access to variables declared in the directly surrounding scope should be >fairly efficient. This goes without saying. However, it's fairly easy to arrange fast access to nonlocals even in scopes several nest levels distant. As has been mentioned, display is the canon method. Displays, though, have a problem dealing with deep nesting ... which, admittedly is rare, but not unheard of. Typically, the compiler will allow only so many nesting levels and if you exceed that number, the compilation fails. Closure conversion - aka lambda lifting - is IMO a better method because it can handle any nesting depth. It takes a bit more analysis during compilation, but it is more flexible than a display. >The rest just needs to work. You will do fine with an implementation >where all procedures have direct access to its own variables and global >variables, and variables declared in surrounding procedures may be more >difficult to access. Yes ... asymmetric access is acceptable for an academic exercise, but not for a compiler that you would want others to use. I know the OP is a novice compiler developer, but let's advocate learning general solutions that will continue to work for more advanced projects in the future. George
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
How to handle qualified identifiers such as x.y in a Pascal-like language noitalmost <noitalmost@cox.net> - 2011-06-20 15:43 -0400
Re: How to handle qualified identifiers such as x.y in a Pascal-like language torbenm@diku.dk (Torben Ægidius Mogensen) - 2011-06-22 10:57 +0200
Re: How to handle qualified identifiers such as x.y in a Pascal-like language Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2011-06-22 11:47 +0100
Re: How to handle qualified identifiers such as x.y in a Pascal-like language George Neuner <gneuner2@comcast.net> - 2011-06-24 18:13 -0400
Re: How to handle qualified identifiers such as x.y in a Pascal-like language BGB <cr88192@hotmail.com> - 2011-06-29 12:31 -0700
Re: How to handle qualified identifiers such as x.y in a Pascal-like language BGB <cr88192@hotmail.com> - 2011-07-01 12:46 -0700
Re: How to handle qualified identifiers such as x.y in a Pascal-like language anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-07-02 17:13 +0000
Re: How to handle qualified identifiers such as x.y in a Pascal-like language BGB <cr88192@hotmail.com> - 2011-07-03 13:14 -0700
Re: How to handle qualified identifiers such as x.y in a Pascal-like language torbenm@diku.dk (Torben Ægidius Mogensen) - 2011-07-07 10:27 +0200
Re: How to handle qualified identifiers such as x.y in a Pascal-like language BGB <cr88192@hotmail.com> - 2011-07-07 04:14 -0700
Re: How to handle qualified identifiers such as x.y in a Pascal-like language George Neuner <gneuner2@comcast.net> - 2011-07-02 16:58 -0400
Re: How to handle qualified identifiers such as x.y in a Pascal-like language Gene <gene.ressler@gmail.com> - 2011-06-22 19:21 -0700
Re: How to handle qualified identifiers such as x.y in a Pascal-like language Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2011-06-24 07:56 +0100
Re: How to handle qualified identifiers such as x.y in a Pascal-like language Gene <gene.ressler@gmail.com> - 2011-06-24 19:19 -0700
Re: How to handle qualified identifiers such as x.y in a Pascal-like language Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2011-06-25 11:55 +0100
Re: How to handle qualified identifiers such as x.y in a Pascal-like language noitalmost <noitalmost@cox.net> - 2011-06-29 13:13 -0400
Re: How to handle qualified identifiers such as x.y in a Pascal-like language "[Linux Magazine]" <uu3kw29sb7@snkmail.com> - 2011-06-24 13:58 +0200
Re: How to handle qualified identifiers such as x.y in a Pascal-like language George Neuner <gneuner2@comcast.net> - 2011-06-25 17:11 -0400
Re: How to handle qualified identifiers such as x.y in a Pascal-like language noitalmost <noitalmost@cox.net> - 2011-06-23 12:43 -0400
Re: How to handle qualified identifiers such as x.y in a Pascal-like language Tony Finch <dot@dotat.at> - 2011-06-29 18:55 +0100
Re: How to handle qualified identifiers such as x.y in a Pascal-like language BGB <cr88192@hotmail.com> - 2011-06-29 15:51 -0700
csiph-web