Related articles |
---|
[8 earlier articles] |
Re: Converting Pascal to C++, C# or VB neelk@cs.cmu.edu (Neelakantan Krishnaswami) (2006-04-08) |
Re: Converting Pascal to C++, C# or VB thompgc@gmail.com (thompgc@gmail.com) (2006-04-08) |
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09) |
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09) |
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09) |
Re: Converting Pascal to C++, C# or VB DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-04-10) |
Re: Converting Pascal to C++, C# or VB gneuner2@comcast.net (George Neuner) (2006-04-10) |
Re: Converting Pascal to C++, C# or VB englere.geo@yahoo.com (Eric) (2006-04-12) |
Re: Converting Pascal to C++, C# or VB hebisch@math.uni.wroc.pl (Waldek Hebisch) (2006-04-12) |
Re: Converting Pascal to C++, C# or VB oliver@first.in-berlin.de (Oliver Bandel) (2006-04-14) |
From: | George Neuner <gneuner2@comcast.net> |
Newsgroups: | comp.compilers |
Date: | 10 Apr 2006 00:18:04 -0400 |
Organization: | Compilers Central |
References: | 06-04-017 06-04-040 06-04-068 |
Keywords: | Pascal, translator |
Posted-Date: | 10 Apr 2006 00:18:04 EDT |
On 9 Apr 2006 17:25:00 -0400, Marco van de Voort <marcov@stack.nl>
wrote:
>On 2006-04-08, George Neuner <gneuner2@comcast.net> wrote:
>
>> Nested Routines:
>> Simulating nested routines is fairly simple - you turn the top level
>> function or procedure into a C++ "function" object - that is an object
>> that overloads the call operator "()". You convert the shared local
>> variables and top level parameters to member variables and any nested
>> routines into member functions [or recursively, into member function
>> objects]. See example below.
>
>I quickly looked over it, but I don't fully get it. Is this supposed
>to be a general solution (e.g. also for call pattern that might be
>more complicated than parent ->1st level child -> 2nd level child) ?
It is a general OO solution for simulating statically scoped nested
functions using top-level functions plus statically scoped data.
By turning parameters and locals of the enclosing function into object
data members, you provide the scope chain which enables the "nested"
functions - implemented directly as object member functions or as
additional "function object" members - to access the data scope of the
enclosing function.
>> Your equivalents of PUT will need to recognize an object and store the
>> object type and data in a way that allows the object to be
>> reconstructed on the fly when GET reads it back. This is called
>> "serialization" and in C++ it requires "run time type information"
>> [RTTI] and some fairly advanced coding techniques.
>
>(note that serialisation can also be done using simple inheritance and
>writing each field individually. RTTI is only necessary if you want to avoid
>spelling out the fields, and don't need the extra control to specify the
>fileformat)
RTTI is not required to implement serialization, but it makes certain
aspects of [in particular] unserialization easier when dealing with
heterogeneous containers or multiple inheritence.
George
Return to the
comp.compilers page.
Search the
comp.compilers archives again.