Olin Lathrop wrote: > Walter Banks wrote: > > I wish that pascal had braces and statement locals and C had > > pascal's local functions. > > Pascal has BEGIN/END, which is pretty much the same as C braces. A > BEGIN/END block is a compound statement that is viewed as a single statem= ent > outside the block. The major difference is pascal uses a ";" as a statement separator in a a compound statement. begin statement end; begin statement ; statement1 end In C ";" terminates a statement > temporary > variables only within the scope of a specific block of code, as apposed t= o a > whole routine, then I don't know of anything similar in Pascal. That is = a > reasonable idea that is embodied in C (Wow, who'd have thought!). This is a very good idea, I agree > In my source to source translator, there is a significant section of code= in > the C back end to deal with local functions. I emulate them by using glo= bal > functions and explicitly passing any accessed local state down to the > function. > > This can get messy with nesting. Let's say routine A calls local routine= B, > which calls its own local routine C. C may access a local variable of A,= so > that variable has to be passed to B just so B can pass it to C when these > local routines are emulated with global routines. My translator does > multiple passes of pushing call arguments up the chain until no changes a= re > made in a pass. The result is not pretty, but it works for the C output > language. This has always been the argument used in WG14 meetings that scope resolution is complex for nested functions. The problem has several solutio= ns including the one you describe. It is actually no more complex than resolvi= ng temporary variables in nested brace blocks. Pascal local functions have the same implementation issues. Nested functions are one feature that I wish C had. All the best of the season, Walter.. -- Walter Banks Byte Craft Limited http://www.bytecraft.com --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .