[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon May 25 18:08:48 2003 
Subject:Scoped procedures 
From:D . J . Gurnell 
Volume-ID:1030525.04 

Hello,

I have a problem... take a look at this:

  define a();
    lvars i;

    define b();
      if i < 5 then
        i + 1 -> i;
        c();
      endif;
    enddefine;

    define c();
      b();
    enddefine;

    c();
  enddefine;

I have three functions: a(), b() and c(). b() and c() are scoped inside
a(), and are mutually recursive. If I run this code, I get the following:

  ;;; MISHAP - enp: EXECUTING NON-PROCEDURE
  ;;; INVOLVING:  <undef c>
  ;;; FILE     :  /home/pg/djg/temp.p   LINE NUMBER:  18
  ;;; DOING    :  b c a runproc

  ;;; MISHAP interrupted
  ;;; (At or before line 18 column 5)

Not difficult to see why, I guess... b() doesn't think c() has been
declared. However, when I try to forward declare c() by changing the lvars
line to:

  lvars i, c;

or:

  lvars i;
  lvars procedure c;

as I _believe_ I should do (though I'm not sure), I get this:

  ;;; MISHAP REDECLARING LEXICAL IDENTIFIER STATUS: c 0
  ;;; (At or before line 11 column 15)

Creepy. Does anybody know how I can get around this, or should I just
declare everything as globally scoped functions nad have done with it?

Cheers,
Dave

-- 
Dave Gurnell
d.j.gurnell@cs.bham.ac.uk