octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Nested functions patch


From: John W. Eaton
Subject: Nested functions patch
Date: Fri, 9 Mar 2012 18:50:56 -0500

On  9-Mar-2012, I wrote:

| I don't understand the following:
| 
| | @@ -1961,6 +2004,12 @@
| |    // Map from symbol names to symbol info.
| |    std::map<std::string, symbol_record> table;
| |  
| | +  // If we are nested, this is our parent function
| | +  symbol_table *nest_parent;
| | +
| | +  // And these are all of our nested child functions
| | +  std::vector<symbol_table*> nest_children;
| | +
| 
| A symbol table is not a function.  Do you mean that nest_parent is the
| symbol table for the parent function?  If so, I'm not sure that makes
| sense.  There should be one symbol table with multiple scopes, one for
| each function.  So it seems to me that you would want to track scopes
| rather than symbol table objects.

Hmm, looking again, the symbol table does maintain a list of symbol
table objects for each scope, so perhaps the way you are managing this
information is OK.  However, I think the following question is still
valid:

| Thinking about this more, when we have nested functions, don't the
| children effectively have the same scope as the parent, except that
| variables passed in the argument list or as globals are handled
| separately?  So would it be possible to handle nested functions by
| merging the scopes of the parents and children?  I suppose we would
| have to be sure that the parents do not have access to the symbols
| that appear only in the child functions.  But if the child and parent
| shared the same scope, then it seems that it would simplify variable
| lookup in the child.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]