[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Nov 3 00:31:22 1999 
Subject:Robin on lexical locals 
From:Aaron Sloman See text for reply address 
Volume-ID:991103.03 

[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]

Robin Popplestone <pop@roo.cs.umass.edu> writes:

> Another gripe I have is that POP-11 doesn't let me use a protected
> identifier as a lexical local
>
> define fred();
>     lvars exp = 23;
> enddefine;
>
> This seems unreasonable, and undesirable, 'cos it's handy to use
> familiar signs, e.g.:
>
> define average(x,y,Algebra)
>     let nonop + = Algebra("+"), nonop / = Algebra("/")
>     in
>         (x+y)/2
>     endlet
> enddefine;

I suppose one problem is that a user may accidentally include a
protected identifier because of leaving out a semi-colon, or

    define foo(p, q) -> z;
        lvars x = ..., y = ...,
        x + y -> z
    enddefine;

So in general the compile time error message guards people against
mistakes.

The sophisticated user who really wants to can temporarily unprotect
an identifier required as a lexical local;

sysunprotect("exp");

define foo();
    lvars exp = 5;
    exp*exp =>
enddefine;

sysprotect("exp");

foo();
** 25

Aaron
===
-- 
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (NB: Anti Spam address)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/