Groups | Search | Server Info | Login | Register


Groups > comp.compilers > #171

Re: How to handle qualified identifiers such as x.y in a Pascal-like language

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-24 18:13 -0400
Organization A noiseless patient Spider
Message-ID <11-06-045@comp.compilers> (permalink)
References <11-06-037@comp.compilers> <11-06-039@comp.compilers>

Show all headers | View raw


On Wed, 22 Jun 2011 11:47:19 +0100, Hans-Peter Diettrich
<DrDiettrich1@aol.com> wrote:

>noitalmost schrieb:
>> What I don't quite understand is how to parse access to a variable in
>> an outer stack frame. And I think this is similar to the problem of
>> nested procedures (which I also don't quite know how to handle).
>
>First of all: local procedures using local variables in an *outer*
>stackframe are problematic. Such a language feature deserves much
>work, in detail when you also want to allow to use local procedures as
>callbacks (procedure pointers). I'd drop that from my language.

But doing so sacrifices quite a bit of power.

In a Pascal-like language having strict stack semantics, the best way
to handle non-local variables is to identify and move them all into a
defined structure in the stack frame of the outermost enclosing
function, then add a hidden pointer argument to all the inner
functions and pass the address of the structure down the call chain.

The same analysis allows for creating persistent closures by
allocating the non-local variable structure on the heap instead of on
the stack.
[Of course, then you need other mechanisms to invoke the closures and
clean up after them when they are no longer needed ... mechanisms
which are beyond the scope of this discussion.]

George

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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