[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Feb 4 02:41:33 1995 
Subject:Re: SECTION_CANCEL 
From:A . Sloman 
Volume-ID:950207.03 

> o Is SECTION_CANCEL frowned upon these days?
I don't see why it should be? Its main use is optimisation as far as
I can tell, though there's a bit of protection also: other programs
cannot possibly access the section local identifiers after a
section has been cancelled.

> o If so, how should I get the effect of cancelling unwanted identifiers
>   in a section?

you can always use "cancel" before the end of the section?

    vars xfoo = 88;
    section foo;

    vars xfoo;

    cancel xfoo;
    endsection;

    xfoo =>
    ** 88

> o Why are vars statements inside a procedure a bad idea?
>   (c.f. compile_mode :pop11 +strict)

vars inside a procedure does two things.

(a) if the variable is not already a global variable it is declared as
global.
(b) it is also declared as dlocal to the procedure (i.e. the value is
saved on entry to the procedure and restored on exit.)
    See HELP DLOCAL

Doing (a) inside a procedure F generally shows that you don't recognize
when you are using a truly global variable:- global in the sense that
procedures defined elsewhere can access it if called while F is running.
If a variable is going to be used globally (e.g. cucharout, prmishap,
database, etc.) it should be declared as global.
Then use "dlocal" to indicate that it's dynamically localised in F.

However, lots of code using the Pop-11 pattern matcher would either
break or look clumsy if this rule were followed, so there are compile
modes that tolerate it. (That's why some people don't like the matcher.)

LIB FMATCHES is a partial solution: it works with lvars, and does not
use valof.

I hope that helps.

By the way I never use "compile_mode :pop11 +strict" as I think it is
far TOO strict for libraries, in particular, it makes it awkward
to trace procedures that are not explicitly declared as vars,
undermining the essential flexibility of an AI language (as opposed
things like C, Pascal, etc.)

So I tend to use, instead, something like this:

    compile_mode:pop11 +varsch +defpdr -lprops +constr +global
                :vm +prmfix :popc -wrdflt -wrclos;

That does a subset of what :pop11 +strict does. See HELP COMPILE_MODE

I think one reason +strict is used all over the place in libraries now
is because POPC needs it. But I don't think POPC will ever really become
a widely used tool. It will be too complicated to understand! Instead
the method of saved images can be used to produce "products", now that
memory is so cheap, and starting up large systems on demand paged
machines is so fast. Even accessing a file server across our network,
typing pop11 or, its equivalent:

    basepop11 +startup

starts up Pop11 in a fraction of a second, even though the files total
about 3 Mbytes. basepop11 +startup +prolog (= prolog) is not noticeably
slower. (It's all slightly slower on another machine that has Poplog on
its local disks, for some reason.).

Aaron