+ All Categories
Home > Documents > ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis --...

ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis --...

Date post: 25-Feb-2018
Category:
Upload: manuel-odendahl
View: 216 times
Download: 0 times
Share this document with a friend

of 7

Transcript
  • 7/25/2019 ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis -- Macaroni is

    1/7

    H a c a r o n l l s B e t t e r t h a n

    S p a g h e t t i

    b y

    G u y L e w i s S t e e l e J r .

    M a s s a c h u s e t t s I n s t i t u t e o f T e c h n o lo g y

    A r t i f i c i a l I n t e l l i g e n c e

    L a b o r a t o r y

    545 T ec hno l og y S qua r e

    C a m b r i d g e , R a s s a c h u s e t t s 0 Z1 39

    N ~ s t r a c t :

    We p r e s e n t a s t a c k I m p l e m e n t a t i o n o f

    m u l t l p l e e n v ir o n m e n ts s l m l l a r I n p r i n c i p l e t o t h a t

    o f B o b r o w a n d W e g b r e t t , b u t b a s e d o n a m o d e l w h i c h

    p r o v i d e s b o t h s t a t l c a n d d y n am l c s c o p l n g . We n o t e

    s om e o f t he p r a91na t t c c ons equenc es o f t h i s c h o i ce o f

    m o d e l s ; o n e i s t h a t no u n n e c e s s a ry c o n t r o l s t a c k i s

    r e t a i n e d f o r c e r t a i n i m p o r ta n t c o n s t r u c t i o n s s u c h a s

    " u p w a rd fu n a r g s ' a nd c o r o u t t n e s . We a l s o d i s c u s s

    t h e c o r r e c t t r e a t m e n t o f e x i t f u n c t i o n s , a n d t h e

    n e e d f o r " e n t r y f u n c t i o n s " I f d y na m ic s w i t c h i n g o f

    c o n t r o l c o n t e x t s I s t o b e

    c o n s i s t e n t .

    I n t r o d u c t i o n

    T he s t a c k I m p l e m e n t a t i o n o f

    e n v i r o n m e n t s

    d e s c r i b e d I n [B W ] w a s d e s l g n e d t o c o m b i n e t h e

    f l e x i b i l i t y o f g e n e r a l i z e d

    t r e e - s t r u c t u r e d

    e n v ir o n m e n ts w i th t h e e f f i c i e n c y o f e x i s t i n g s t a c k

    h a r d w a r e . I t w a s b a s ed o n t h e d y n a m i c - b i n d i n g m o d e l

    t h e n p r e v a l e n t a m on g L IS P s y s t e m s . S i nc e t h a t t l m e

    a n u m b e r o f p r o b l e m s w l t h d y n a m i c b l n d l n g h a v e c o m e

    t o l i g h t . We p r o p o s e h e r e a r e v t s l o n o f t h e

    s p a g h e t t i s t a c k I m p l e m e n t a t i o n w h l ch r e t a i n s m uc h

    t h e s a m e s t o r a g e m a n ag e m en t t e c h n i q u e s w h i l e

    s u b s t i t u t i n g a b e t t e r m o d e l o f

    e n v i r o n m e n t

    a n d

    c o n t r o l

    r e l a t i o n s h i p s .

    T h i s m o d e l a s s u m e s s t a t l c

    ( l e x l c a l ) b t n d l n g a s t h e p r l m a r y s c o p l n g d i s c i p l i n e ,

    b u t h a s p r o v i s i o n s f o r d y na m ic b l n d i n g a s w e l l . We

    w i l l n o t a r g u e t h e r e l a t l v e m e r i t s o f l e x l c a l a n d

    d y n a m ic s c o p l n g h e r e ; f o r t h a t t h e re a d e r i s

    r e f e r r e d t o [ I m p e r a t i v e ] a n d [ D e c l a r a t i v e ] .

    H o w e v e r , w h e r e r e l e v a n t w e w 11 1 n o t e s om e o f t h e

    p r a g m a t i c c o ns e qu e n ce s o f t h e d i f f e r e n c e s b e t w e e n

    t h e m o d e l s .

    I n t e r n a l S t o r a g e S t r u c t u r e s

    We i n t r o d u c e f i v e k l n d s o f s t o r a g e o b j e c t s .

    T h r e e

    o f

    t h e se a r e " s t a c k - a l l o c a t e d f ra m e s ' , t o b e

    m a n a ge d b y t h e s t o r a g e r e c l a m a t i o n t e c h n i q u e s

    d i s c u s s e d I n [ B W ] . E a ch s u c h f r a m e h a s t h r e e f l e l d s

    S I Z E , m A X , a n d U SE f o r

    us e

    b y t h e s t o r a g e m a n a g e r .

    T h e o t h e r tw o a r e h e a p - a l l o c a t e d o b j e c t s w h i c h a r e

    m a n a g e d b y t h e g a r b a g e c o U e c t o r i n t h e u s u a l w a y ,

    e x c e p t t h a t w h en s u c h a n o b j e c t i s r e c l a i m e d t h e U S E

    f i e l d o f a n y f r a m e p o i n t e d t o by t h e o b j e c t m u s t b e

    d e c r e m e n t e d , p o s s i b l y r e s u l t i n g I n t h e re c l a m a t i o n

    o f t h e f r a m e . T h es e n ew o b j e c t s a r e :

    ( l )

    A c c e ss f ra m e s . T h es e a r e a n a lo g o u s t o t h e b a s i c

    f r a m e s o f [ B W ]. A n a c c es s f ra m e c o n t a i n s v a l u e s

    o f s t a t i c a l l y s c o pe d v a r i a b l e s a n d a n A L I N K

    p o i n t e r t o a n o t h e r a cc e ss f r am e ( o r N IL i f t h l s

    i s t h e h i g h e s t a c c e s s f r a m e o f t h e s t a t i c

    e n v i r o n m e n t ) . N o t i c e t h a t , b y t h e v e r y n a t u r e

    o f s t a t i c a c c e s s , t h e s e f r a m e s n e ed n o t c o n t a i n

    n am e s f o r e a ch o f t h e v a r i a b l e s ( t h o u g h t h e y

    m a y , i f d e s l r e d , f o r d e b u g g i n g p u r p o s e s ; b u t

    s ee a l s o th e r a m a r k s i n [ D e c l a r a t i v e ] ) , b u t o n l y

    t h e v a l u e s .

    . . . . . . - l x l u s e s , z E ]

    . A ~ I N K t . . . . . . . .

    VALUES[I] /

    VALUES[Z] /

    ( Z ) C o n t r o l f r a m e s . T h es e a r e a n a l o g o u s t o t h e

    f r a m e e x t e n s i o n s o f [ B W ]. C o n t r o l f r a m e s

    c o n t a l n v a r l o u s t e m p o r a r y q u a n t i t i e s , a C L I N K

    p o l n t e r t o a p r e v l o u s c o n t r o l f r a m e , a n d a n

    A L IN K p o i n t e r t o t h e c u r r e n t a c c e ss fr a m e .

    , . x I u s e s z E

    CLINK -"

    AL]NK e,

    Tf.HPORARY1

    TEMPORARYZ

    ( 3 )

    D y n a m ic b l n d l n g f ra m e s . T h es e a r e s l m l l a r t o

    c o n t r o l f r a m e s , b u t a l s o c o n t a i n n a m e - v a l u e

    p a i r s f o r d y n a m ic v a r i a b l e l o o k u p . A d y n a m i c

    b i n d i n g f r am e ma y a l s o h a v e an a d d i t i o n a l D LIN K

    p o i n t e r t o t h e p r e v i o u s d yn a m ic b i n d i n g f r a m e .

    T he D L IN K p o i n t e r i s n o t l o g i c a l l y n e c e s s a r y ,

    s i n c e t h e s a m e f ra m e c a n b e f o u nd b y f o l l o w i n g

    t h e C L IN K c h a i n , b u t c a n s pe e d u p t h e s e a r c h i n

    t h e c a s e o f d e e p a c c e s s , o r t h e c o n t e x t s w i t c h

    i n t h e c a s e o f s h a l l o w a c c e ss .

    60

  • 7/25/2019 ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis -- Macaroni is

    2/7

    --- : 3.

    = I

    U S E

    I

    S l Z E

    CLINK @

    ALINK

    DLINK 4k

    DYNAHIC NAME 1

    OYNARIC VALUE 1

    . , .

    DYNAHIC NAME M

    OYNAMIC VALUE M

    TEMPORARY 1

    TEMPORARY 2

    ..o

    TERPORARY N

    3 ~

    ( 4 ) F u n a r g o b j e c t s . E ac h f u n a r g o b j e c t c o n t a i n s a

    p o i n t e r t o a p i e c e o f c o d e a n d a n A L IN K p o i n t e r

    t o t h e a c c e s s f r a m e w i t h r e s p e c t t o w h i c h t h e

    c o d e i s c l o s e d .

    ( 5 ) E s c a pe f u n c t i o n o b j e c t s . T h es e a r e o b j e c t s

    s i m i l a r t o t h o se c r e a te d b y L a n d l n ' s J - o p e r a t o r

    [ L a n d t n ] , R e y n o l d ' s e sc a pe c o n s t r u c t [ R e y n o l d s ] ,

    o r S C H E H E ' s C A TC H c o n s t r u c t [ SC H E H E] . A n e s c a p e

    f u n c t i o n o b j e c t c o n t a i n s a C LIN K p o i n t e r t o s o me

    c o n t r o f r a m e , a n d a l s o a c o r r e s p o n d i n g D L IN K

    p o i n t e r s I f s u ch p o i n t e r s a r e u s e d b y d y n a m i c

    b i n d i n g f r a m e s .

    [ 0 L , N I C L I . K

    O u r m o d e l d i c t a t e s t h a t t h e r e b e a

    d i s t i n g u i s h e d r e g l s t e r C U RC LIN K w h i ch p o i n t s t o t h e

    c o n t r o l f ra m e b e i n g r u n I n . ( I n th e m u l t i p r o c e s s t n g

    c a s e , t h e r e w o u l d b e a C U RC LIN K f o r e a c h p r o c e s s ,

    b u t w e s h a l l n o t g o i n t o t h e d e t a i l s o f

    m u l t t p r o c e s s t n g h e r e . ) I f D LIN K s a r e b e i n g u s e d ,

    t h e r e m u s t a l s o b e a C U R D LI NK . W e s h a l l a s s um e t h e

    u s e o f D L IN K s , a n d d e t e r m i n e w h e t h e r t h e c u r r e n t

    c o n t r o l f r a m e l s a d y n am i c b i n d i n g f r am e b y m e an s o f

    t h e t e s t C U R D LIN K = C U R C LIN K . I f D L I N K s a r e n o t

    u s e d , a l l c o d e r e l a t i n g t o th e m s h o u l d b e I g n o r e d

    h e r e , a nd a n o t h e r mean s p r o v i d e d f o r d i s t i n g u i s h i n g

    d y n am i c b i n d i n g f r a m es f ro m o r d i n a r y c o n t r o l f r a m e s .

    A l l c o n t r o l f ra m e s w h i ch a r e n o t c u r r e n t a r e

    " s e a l e d ' , a nd m u st c o n t a i n a c o n t i n u a t i o n p o i n t , a

    p o i n t e r t o t h e co d e t o e x e c u t e o n r e t u r n t o t h a t

    c o n t r o l f r a m e . I n [B W ] t h i s c o n t i n u a t i o n p o i n t i s

    s h ow n i n a f i x e d l o c a t i o n I n th e f ra m e e x t e n s i o n ,

    b u t I t i s o f t e n m o r e c o n v e n i e n t t o p u s h t h e

    c o n t i n u a t i o n p o i n t o n t o t h e e nd j u s t b e f o r e s e a l i n g

    I t , a nd p op I t o n u n s e a l i n g I t ( p o s s i b l y r e p l a c i n g

    i t

    w i t h

    a r e t u r n e d v a l u e ) .

    We n o w p r e s e n t s c e n a r i o s f o r t h e c o m m on

    o p e r a t i o n s .

    C a l l i n g a f u n c t i o n . We h a v e a f u n a r g o b j e c t f o r a

    f u n c t i o n w e w i s h t o c a l l , w e k n ow h ow m a ny a r g u m e n t s

    t o g i v e i t , a n d w e w i l l c a l c u l a t e t h e a r g u m e n t s o n

    t h e f l y .

    C a l l F u n c t to n ( F N A R G , N u m be r o f A r g s )

    l e t A = A l l o c a t e A c c e s s F r am e ( N u m b e r o f A r g s ) t_nn

    b e g i n

    A . A L I N K ~ G r a b A c c e s s F r a m e ( F N A R G . A L I N K ) ;

    f o r I f r o m 1 t o N u m b e r o f A r g s d _

    A . V A L U E 3 [I ] ~ - C a l c u l a t e A r g u m e n t ( i ) ;

    R e l e a s e A c c e s s F r a m e (C U R C L I N K .A L IN K ) ;

    C U R C L I N K . A L I N K ~ - A ;

    go t o (FNARG.CODE)

    e n d

    N o t e t h a t n o c o n t r o l f r am e i s p u s h e d ; o u r m o d e l

    p r e s e r v e s t h e i m p o r t a n t p r o p e r t y o f t a i l - r e c u r s i o n .

    3 e e " P u s h R e t u r n A d d r e s s " b e l o w .

    A p p l i c a t i o n . T h i s b r e a k s d ow n I n t o tw o c a s e s :

    o r d i n a r y f u n a r g s a n d e sc a pe f u n c t i o n s .

    A p p l y ( F U N , A R G L I S T )

    c a s e t y p e ( F U N ) I n

    F u n a r g :

    A p p l y F u n a r g ( F U N , A R G L I S T ) ;

    E s c a p e F u n c t i o n :

    A p p l y E s c a p e F u n c t i o n ( F U N , A R G L I S T ) ;

    e s a c

    A p p l y i n g a f u n a r g . We h a v e a f u n a r g o b j e c t f o r

    a

    f u n c t i o n a n d a c o m p ut ed l i s t o f a r g u m e n t s .

    A p p l y F u n a r g ( F N A R G , A R G L I S T )

    l e t A = A l l o c a t e A c c e s s F r a m e ( l e n g t h ( A R G L l S T ) ) l_p_n

    begi.

    A . A L I N K ~ - G r a b A c c e s s F r a m e ( F N A R G . A L I N K ) ;

    co mme n t Th is fo ._ .E lo o p s te p s [ a n d X in

    p a r a l l e l ;

    f o r

    I

    f r o m

    1, X i_nnARGLIST

    d o

    A . V A L U E 3 [ I ] * - X ;

    R e l e a s e A c c e s s F r a m e ( C U R C L I N K . A L I N K ) ;

    C U R C L I N K . A L I N K ~ - A ;

    go t_.o(FNARG.CODE)

    e n d

    C r e a t i n g a f u n a r g . We h a v e a p ie c e o f c o d e a n d w i s h

    t o c l o s e i t I n th e c u r r e n t e n v i r o n m e n t .

    C o n s F u n a r g ( C O D E )

    l e t F = A l l o c a t e F u n a r g O b j e c t ( ) i_nn

    b e g i n

    F.CODE ~- CODE;

    F . A L I N K * - G r a b A c c e s s F r a m e ( C U R C L I N K . A L I N K ) ;

    F

    e n d

    N o t e t h a t a f u n a r g p o i n t s o n l y t o c h a i n s o f a c c e ss

    f r a m e s , a n d r e t a i n s n o c o n t r o l f r a m e s . U n d e r t h e

    d y n a m i c b i n d i n g m o d e l o f [ B W ], f u n a r g s r e t a i n f r a m e

    e x t e n s i o n s e v e n t h o ug h t h e y w i l l n e v e r b e u s e d .

    61

  • 7/25/2019 ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis -- Macaroni is

    3/7

    E v a l u a t i n g a s u b - c o m b i n a t i o n . A s m e n t i o n e d a b o v e

    a n d d i s c u ss e d m or e t h o r o u g h l y in [ D e c l a r a t i v e ] , t h e

    l o g i c a l l y c o r r e c t t lm e t o p us h " c o n t r o l s t a c k " i s

    w h en co m m e nc in g e v a l u a t i o n o f a s u b - c o m b i n a t i o n , n o t

    w h e n c a l l i n g a f u n c t i o n . T h U S:

    P us h R e t u r n Address Con t i nua t ion P o i n t )

    b e g i n

    P u s h ( C o n t i n u a t i o n P o i n t , C U R C L I N K ) ;

    le__tt C = A l l o c a t e C o n t r o l F r am e(. ) Ln

    b e g i n

    C . C L I N K ~ - C U R C L I N K ;

    E . A L I N K * - G r a b

    A c c es s

    F r a m e ( C U R C L I N K . A L I N K ) ;

    C U R C L I N K ~ - C

    e n d

    en__.dd

    D y n a m i c B i n d i n g . We h a v e a s e t o f v a r i a b l e n a m es

    ( w h i c h m a y b e p o i n t e r s t o a t o m i c s y m b o l s , a d d r e s s e s

    o f v a l u e c e i l s , o r a n y t h in g e l s e t h a t c a n b e g i v e n

    t o t h e d y n a m ic l o o k u p r o u t i n e t o l o c a t e a v a l u e ) a n d

    a c o r r e s p o n d i n g s e t o f v a l u e s . H e r e w e s h a l l a s su m e

    t h e d e e p a c c e s s m e t h o d , i n w h i c h t h e v a l u e s a r e

    p l a c e d o n t h e s t a c k . A s f o r t h e c r e a t i o n o f a n

    e s ca p e f u n c t i o n , a t t h i s p o i n t w e s h o u ld b e r u n n i n g

    i n a f r e s h c o n t r o l f r a m e , w h i c h w i l l b e c o n v e r t e d

    i n t o a d y n a m ic b i n d i n g f r a m e .

    B l nd D y nam i c V a r t ab l es ( N A N E L I S T , V A LUE LI ST )

    b e g i n

    PUSH(CURDLINK, CURCLINK);

    c om m en t T h i s c o d e l s f o r d e e p a c c e s s ;

    f o r N I n N A ME L IS T , V LnV A LUE L I S T do

    b e g l n

    PUSH(N, CURCLINK);

    PUSH(V, CURCLINK);

    e n d ;

    CURDLINK~- CURCLINK

    e n d

    R e t u r n f r o m f u n c t i o n . We have computed one o r m o r e

    v a l u e s , a n d w i s h t o r e t u r n f r o m t h e c u r r e n t c o n t r o l

    f r a m e . ( S e e [ D e c l a r a t i v e ] f o r a d i s c u s s i o n o f w h y

    i t i s o n l y p r i m i t i v e o p e r a t o r s w h ic h e v e r d o t h i s ,

    a n d h o w s u c h o p e r a t o r s c a n b e a c co m o d a t e d I n a L I S P -

    l i k e l a n g u a g e . )

    R e t u r n f r o m C o n t r o l F ra m e( VA LU E S ) =

    le t A = CURCLINK.ALINK,

    C = CUR CLINK.CLINK I n

    b e g l n

    c om m en t I f w e u s e s h a l l o w a c c e ss f o r d y n a m i c

    v a r i a b l e s , t h i s i s t h e p l a c e

    t o r e s t o r e

    t h e o l d b i n d i n g s i f t h i s i s a d y n a m ic

    b i n d i n g s f r a m e ;

    l _ ff CURDLINK = CURCLINK th e n

    b e g i n

    U n d o D y n a m i c B i n d i n g s ( ) ;

    C UR D L I N K ( -

    C U R C L I N K . D L I N K

    end;

    c o m m e n t B e c a u se w e a r e r un n i n g i n t h e c u r r e n t

    c o n t r o l f r a m e , C U R CL IN K i s t h e o n l y

    r e f e r e n c e t o i t ;

    De le te SegNent (CURCLINK) ;

    R e l e a s e A c c e s s F r a m e ( A ) ;

    CURCLINK~- C;

    E n s u r e R u n n a b t l i t y ( ) ;

    c om m en t T he c o n t i n u a t i o n p o i n t I s o n t h e t o p

    o f t h e n ew c o n t r o l f r a m e , a n d w e s h a l l

    r e p l a c e i t w i t h t h e r e t u r n e d v a lu e s ;

    le t X = Pop(CU RCLIN K) 1._nn

    b e g i n

    fo r Y In VALUES do PUSH(Y, CURCLINK);

    go t _9 ( x )

    en_dd

    e n d

    C r e a t i n g a n e s c a p e f u n c t i o n . We w a n t t o c r e a t e a

    n e w a c c e s s f ra m e w i t h a v a l u e i n I t w h i c h

    i s

    a n

    e s c a p e f u n c t i o n . We s h o u l d h a v e j u s t e n t e r e d a

    f r e s h c o n t r o l f r am e ( w h i c h w i l l b e t h e ca s e i f t h e

    e s c a p e e x p r e s s i o n I s a s u b - f o r m o f a c o m b i n a t i o n ,

    f o r e x a m p l e ) ; I f n o t , w e m u s t f i r s t h a v e s e a l e d t h e

    c u r r e n t c o n t r o l f ra m e w i t h a r e t u r n a d d r e s s an d

    c r e a t e d a n ew o n e . T he a c t u a l c r e a t i o n a n d b i n d i n g

    o f t h e e s c a pe f u n c t i o n I s s i m i l a r t o t h e p r o c e s s o f

    e n t e r i n g a f u n c t i o n ; i t r e q u i r e s t h e c r e a t i o n o f an

    a c c e s s fr a m e , b u t n o t o f a c o n t r o l f r a m e .

    B l n d E s c a pe F u n c t i o n ( )

    le__tt E = A l l o c a t e E s ca p e F u n c t i o n O b j e c t ( ) ,

    A =

    A l l o c a t e A c c e s s F r a m e ( l ) l _ n n

    b e g i n

    E . C L I N K * - G r ab C o n t r o l F r am e( C UR C L I N K . C L IN K ) ;

    c om m en t T h e c u r r e n t f r a m e c a n n o t b e a d y n a m i c

    b l n d t n g f r a m e ;

    E . D L I N K ~ - CURDLINK;

    A . V A L U E S [ I ] * - E ;

    A . A L I N K ~ - C UR C L I N K . A L I N K ;

    C UR C L I N K . A L I N K 4- A

    e n d

    A p p l y l n g a n e s c a pe f u n c t i o n . We h a v e a n e s c a p e

    f u n c t l o n o b j e c t a nd a l i s t o f th e v a l u e ( s )

    t o

    b e

    r e t u r n e d .

    A pp l y E s c ape F unc t l on ( E S C F UN , A R G L I S T )

    b e g l n

    c om m en t I f s h a l l o w d y n a m i c b i n d i n g l s u s e d , I t

    t a k e s s o m e e f f o r t t o c h a n g e C L I NK s , a n d

    t h e r e i s a l s o t h e m a t t e r o f e x i t f u n c t i o n s

    ( s e e b e l o w ) ;

    Sw i tch D ynamic Contex t (CUR CLINK, ESCFUN.CLINK);

    R e l eas e C on t r o l F r am e( C UR C L I N K ) ;

    CURCLINK ( - Grab C on t ro l F rame(ESCFUN.CLINK) ;

    CURDLINK( - ESCFUN.DLINK;

    E n s u r e R u n n a b l l l t y ( ) ;

    le_~tX = P OP(CU RCLINK ) l_nn

    b e g i n

    f o r Y In ARGLIST d_9o PUSH(Y, CUR CLINK);

    g o L o ( X )

    e n d

    en__dd

    H e r e a r e s om e o f t h e u t l l l t y r o u t l n e s a ss um ed b y t h e

    f u n c t i o n s J u s t p r e s e n t e d . T h e l r p r i m a r y p u r p os e I s

    t o e n f o r c e a r e f e r e n c e - c o u n t s t o ra g e d i s c i p l i n e o n

    t h e f r a m e s .

    G r a b A c c e s s F r a m e (A )

    i f A ~ N I L t h e n A . U S E + - A . U S E + 1

    62

  • 7/25/2019 ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis -- Macaroni is

    4/7

    6 r a b C o n t r o l F r a m e (C )

    i f

    C

    N I L t h e n C . U S E 4 - C . U S E + 1

    R e l e a s e A cc e s s F r m e ( A ) ,

    l _ f f A ~ N IL t h e n

    b e g i n

    A.USE ~- A.USE - 1 ;

    i_ f f A .USE = 0 then

    le.._.t.t = A . A LIN K l_nn

    b e g i n

    D e l e t e S e g m e n t (A ) ;

    Rel ease

    A c c e s s F r u e ( B )

    e n d

    e n d

    R e l e a s e C o n t r o l F r a m e ( C )

    i f C * NIL t h e n

    b e g i n

    C.USE ~- C.USE

    - 1 ;

    I f C .U S E = 0 t h e n

    1 e ta = C .A L INK , B = C .CL INK t_nn

    b e g i n

    D e l e t e S e g m e n t ( C ) ;

    R e l e a s e A c ce s s F r m e ( A ) ;

    R e l e a s e C o n t r o l F r a m e( B )

    e n d

    e n _ _ d _ d

    E n s ur e R u n n a b l l l t y ( )

    i t " CURCLINK.USE > 1 the .~n

    b e g i n

    CURC LINK.USE ~- CU RCLINK.USE - 1 ;

    CURC LINK 4- Cop y $egmenZ(CUR CLINK);

    CURCLINK.ALINK.USE (- CURCLINK.ALINK.USE + 1

    e n d

    e l s e i f N o t E n o ug h R o o m t o R u n ( ) t h e n

    le_~t C = Copy 3egment(CURCLINK) in

    b e g i n

    D e l e t e S e g m e n t ( C U R C L I N K ) ;

    C U R C L I N K ~ - C

    e n d

    T h e p r i m i t i v e s " A l l o c a t e A c ce s s F r am e " a n d " A l l o c a t e

    C o n t r o l F r a m e " a r e a s su m e d t o i n i t i a l i z e t h e U~ E

    f i e l d o f t h e n e w l y a l l o c a t e d f ra m e to 1 . S ee [ BW ]

    f o r a d e s c r i p t i o n o f t h e o p e r a t i o n o f t h e p r i m i t i v e

    " D e l e t e S e g m e n t ' .

    E x i t f u n c t i o n s

    E x l t f u n c t i o n s , a s d e s c r i b e d i n [ B W ], w e r e n o t

    i m p l e m e n t e d i n I n t e r L I S P [T e t t e l m a n ] , w h i c h

    c o n t a i n s , t o o u r k n o w l e d g e , t h e o n l y w o r k i n g

    I m p l e m e n t a t i o n o f s p a g h e t t i s t a c k s . ( I n f a c t , t h e

    o n l y l a n g u a g e we k n ow o f w h i c h i m p l e m e n t s g e n e r a l

    e x i t f u n c t i o n s I s IT S T E C O [ T EC O ] ) T h i s m ay b e

    b e c au s e t h e y a r e o f m a r g i n a l u t i l i t y , o r b ec a u se f o r

    s om e p u r p o s e s t h e y a r e e a s i l y s i m u l a t e d b y t h e u s e r .

    L e t u s d e n o t e a d y n a m i c v a r i a b l e b y p r e f i x i n g i t

    w i t h a c o l o n ; t h e n w e m i g h t w r i t e :

    ( ( L / ~ B D A

    ( : V )

    ( ( L ~ B D A ( G O 0 0 1 )

    (C O N D ( ( N U L L : V ) 6 0 0 0 1 )

    ( T ( F U N C A L L : V G 0 0 0 1 ) ) ) )

    < f o r m > ) )

    N I L )

    ( T h e H a c L I S P f u n c t i o n F U NC AL L I s t h e s a m e a s t h e

    I n t e r L I S P f u n c t i o n A PP LY *; i t I s e s s e n t i a l l y a w a y

    o f d e f e a t i n g t h e c o n v e n t i o n t h a t t h e f u n c t i o n

    p o s i t i o n o f a c o m b i n a t i o n i s " e v a l u a t e d N i n a

    d i f f e r e n t w a y f r o m t h e a r g um e n t p o s i t i o n s . T h us t h e

    f i r s t a r g u m e n t t o F U NC AL L i s c a l l e d a s a f u n c t i o n o n

    t h e r e s t

    of

    t h e a r g u m e n t s . )

    N ow t h i s c o d e w i l l b i n d : V d y n a m i c a l l y t o

    N I L a nd t h e n e x e c u t e < f o rm > . I f : V i s e v e r s e t n o n -

    n i l , t h e n I t w i l l b e r u n a s a n " e x i t f u n c t i o n " o n

    t h e v a l u e o f t h e f o rm .

    T h i s d o e s n o t b e h a ve p r e c i s e l y a s a n e x i t

    f u n c t i o n a s d e s c r i b e d i n [B W ] w o u l d , b e c a u s e e x i t

    f u n c t i o n s a r e s u p p o s e d t o b e r u n e v e n w h e n t h e

    s y s t e m i s s k i p p i n g o u t o f t h e f r a m e , a s f o r a n o n -

    l o c a l g o t o o r a n e r r o r . T h e r e a r e , h o w e v e r , a

    c o u p l e o f d i f f i c u l t i e s h e r e . O ne i s t h a t t h e

    s p a g h e t t i s t a c k m o d e l d oe s n o t p r e s c r i b e w h a t v a l u e

    t o f e e d t o t h e e x i t f u n c t i o n I n t h e c a s e o f a n o n -

    l o c a l e x i t ( t h e d e s c r i p t i o n s o f " S e t e x f n " a nd " E x i t

    A c c e s s F r a m e" d o n o t c o v e r t h i s c a s e ) . I t p r o b a b l y

    o u g h t to r e c e i v e a b i t o f i n f o r m a t i o n d e s c r i b i n g

    w h , ~ th e r t h e e x i t I s n o r m a l o r n o n - l o c a l . A n o t h e r

    p r ( , b le m i s t h a t c o n t r o l f r am e s m ay b e n o n - l o c a l l y

    e n l e r e d E x i t f u n c t i o n s a re d e s c r i b e d a s b e i n g

    u s e f u l f o r c l o s i n g f i l e s , f o r e x a m p l e ; i t w o u l d

    s ee m t h a t i f s u ch a f ra m e w e r e r e - e n t e r e d , t h a n k s t o

    t h e u s e o f a n "e s c a p e " f u n c t i o n , w e m i g h t w a n t t o

    r e - o p e n t h e f i l e

    T h i s l a t t e r p r o b l e m I s s i m i l a r t o t h a t o f

    h a n d l i n g s h a l l o w - a c c e s s d y n a m i c a l l y b o un d v a r i a b l e s

    d u r i n g a c o n t r o l c o n t e x t s w i t c h . I t i s n e c e s s a r y t o

    f i n d s om e p o i n t I n th e c o n t r o l t r e e w h i c h I s a n

    a n c e s t o r ( a c t u a l l y a d e s c e nd a n t , c o n s i d e r i n g t h e

    d i r e c t i o n o f t h e p o i n t e r s ) o f b o t h t h e o l d a nd t h e

    n ew c o n t e x t , a nd t h e n t r a v e l a p a t h fr o m o l d c o n t e x t

    t o " J o i n p o i n t " t o ne w c o n t e x t , u p d a t i n g v a r i a b l e s

    [ G r e e n b l a t t l ] [ B a k e r l ] . O ne n ee ds t o d o a s i m i l a r

    t h i n g f o r " e x i t f u n c t i o n s ' ; o ne s h o u l d t r a v e l f r o m

    o l d c o n t e x t t o j o i n p o i n t , r u n n i n g a l l e x i t

    f u n c t i o n s , a nd t h e n f r om j o i n p o i n t t o n e w c o n t e x t ,

    r u n n i n g a l l e n t r y fu n c t i o n s . ( P r es u m a b ly t h e e x i t

    f u n c t i o n a nd e n t r y f u n c t i o n f o r a g i v e n fr a m e s h o u ld

    b e i n v e r s e s . ) I n a s i m p l e c a s e , su ch a s a n o n - l o c a l

    e x i t , t h e ne w c o n t e x t I s t h e J o i n p o i n t , a nd e n t r y

    f u n c t i o n s a r e n o t n e ed e d; b u t t h e y a r e n e c e s s a r y in

    t h e g e n e r a l c a s e , s u c h a s f o r

    generators see

    b e l o w ) .

    T he s i m u l a t i o n d e s c r i b e d a bo v e d o e s n ' t w o r k

    f o r n o n - l o c a l e x i t s , a nd s o t h e e n t r y / e x i t - f u n c t i o n

    f a c i l i t y m u s t b e b u i l t - I n . H o w ev e r, i t i s p r o b a b l y

    b e t t e r t o r e q u i r e t h e u s e r t o e x p l i c i t l y s p e c i f y

    w h en on e l s n e c e s s a r y , r a t h e r t h an a l l o w i n g h i m t o

    p i c k a n y f r a m e an d p a t c h o n e i n . T h u s o n e m i g h t

    ~ i t e :

    ( E X I T B I N D

    (L NIB DA (VA L U E NORMA LP )

    (PROGN

    (3ETQ

    SAVED-FP03

    ( F I L E P O S T H E - F I L E ) )

    (CL OS E THE -F IL E )

    V A L U E ) )

    ( L N I B D A ( )

    (PROGN (OPEN THE-FILE)

    (F IL E P O3 THE -F IL E

    SAVED-FPOS)))

    )

    6 3

  • 7/25/2019 ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis -- Macaroni is

    5/7

    T h i s w o u l d e x e c u t e ( b o d y ) I n a f r a me m a r k e d a s

    h a v i n g e x l t a n d e n t r y f u n c t i o n s . W e h a v e

    r e p r e s e n t e d t h e e x l t f u n c t i o n a s t a k i n g t h e v a l u e

    e n d a s w i t c h . W e a re n o t s u r e w h a t a r g u m e n t s t h e

    e n t r y f u n c t i o n s h o u l d r e c e i v e ; t h e r e is a l s o t h e

    m a t t e r o f w h e t h e r t h e e n t r y f u n c t i o n s h o u l d b e

    i n v o k e d o n t h e f i r s t ( n o r m a l ) e n t r y t o t h e

    c o n s t r u c t . A l t h o u g h e xi t f u n c t i o n s , a s a

    g e n e r a l l z a t i o n o f t h e c o n t e x t -s w l t c h i n g m e c h a ni s m ,

    w l l l p r o b a b l y p r o v e I n v a l u a b l e I n f u t u r e l a n g u a g e s ,

    w e d l d n o t I n c l u d e h a n d l i n g o f e x l t f u n c t i o n s I n t h e

    r o u t i n e s p r e s e n t e d a b o v e b e ca u s e o f t h e s e p r e s e n t

    u n c e r t a i n t i e s . { N o te B i n d i n g P r i n c i p l e }

    O m i t t e d F e a t u r e s

    W e h a v e p u r p o s e l y o m i t t e d c e r t a i n f e a t u r e s

    f r o m o u r m o d e l w h i c h w e r e p r o v i d e d i n [ B N ] . W e o m i t

    r e l a t l v e e v a l u a t i o n b e c a u s e w e do n o t w a n t t o b e

    c o n s t r a i n e d t o s t o r e n a m e s I n a c c e s s f r a m e s . H o r e

    a c c u r a t e l y , w e d o n o t w i s h t o c o m m i t o u r s e l v e s t o a

    p a r t l c u l a r f o r m a t f or n a m e s ; n a m e s m a y b e

    r e p r e s e n t e d a s a to m i c s y m b ol s , a d d r e s s e s o f v a l u e

    c e l l s , e f f e c t i v e a d d r e s s e s o f m a c h i n e i n s t r u c t i o n s ,

    e t c. A n am e l s a n y e n t i t y w h l c h ' a l l o w s o n e t o

    i d e n t i f y t h e v a l u e r ep r e s e n t e d b y t he n a m e . I t

    w o u l d b e p o s s i b l e t o p r o v i d e r el a t i v e e v a l u a t i o n f o r

    d y n a m l c a l l y - b o u n d v ar i ab l e s , b e c a u s e f o r t h o s e w e d o

    e f f e c t i v e l y h a v e t o u s e a s i n g l e, s y s t e m - w i d e

    r e p r e s e n t a t i o n o f n a me s .

    H o r e g e n er a l l y, w e s u g g e s t t h a t t h e u s e r n o t

    b e g i v e n a c c e s s t o f r a m e po i n t e r s , b u t o n l y t o

    p r i m i t i v e s s u c h a s f u n ar g s a n d e s c ap e f u n c t i o n s

    w h l c h m a y b e i m p l e m e n t e d In t e r m s o f f r a m e s . T h i s

    I s t o r e d u c e t h e d e p e n d e n c e o f u s e r p r o g r a m s o n a

    p a r t i c u l a r i m p l e m e n t a t i o n .

    A s a c o r ol l a ry , t h e c o n c e p t o f a f r a m e n a m e

    i s u n n e c e s s a r y , b e c a us e t h e r e i s n o n e e d t o r e f e r

    d l r e c t l y t o f r a m e s . T he p r i m i t i v e o p e r a t i o n s w e

    p r e s e n t h e r e h a ve no ne e d t o s e a r c h d y n a m i c a l l y f o r

    f r a m e s o f a p a r t i c u l a r name. {Note D e b u g g i n g }

    G e n e r a t o r s a n d C o r o u t t n e s

    O f I n t e r L I S P u s e r s w ho m ak e n o n - t r i v i a l u s e

    o f th e s p a g h e t t i - s t a c k f e a t u r e , a l m o s t a l l u s e i t

    a l m o s t e x c l u s i v e l y t h r o u g h t h e g e n e r a t o r s a n d

    c o r o u t t n e s f e a t u r e . [ K a p l a n ] F o r s om e r e a s o n , t h e

    c o r o u t t n e I m p l e m e n t a t i o n d e s c r i b e d in [ BW ] r e q u i r e d

    t h e u s e r t o s u p p l y t o t h e " R e su m e " p r i m i t i v e a

    f u n c t i o n w i t h w h i c h t o c o n t i n u e t h e c u r r e n t

    c o r o u t i n e o n r e s u m p t i o n . T h i s w as p r o b a b l y s o t h a t

    r e s u m p t i o n c o u l d p a ss m o re t h a n o ne v a l u e b e t w e e n

    c o r o u t l n e s . T h i s h a s v e r y m uc h t h e f l a v o r o f t h e

    " c o n t i n u a t i o n - p a s s i n g s t y l e " o f c o d i n g . We p r e s e n t

    h e r e o u r v e r s i o n o f t h a t a p p ro a c h :

    S t a r t ( F N A R G ,

    ARGLIST)

    b e g i n

    CURPROC e- FNARG ;

    A p p l y ( F N A R G , A R G L I S T ) ;

    e n d

    Resume(FNARG, AR GLIST, BACKFN)

    b e g i n

    CURPROC.CODE ~- BACKFN.CODE;

    Re le a se A cce ss F ra me (CURP ROC.A L INK ) ;

    C U R P RO C .A L IN K 4 - G r a b A c c e s s F r a m e ( B A C K F N . A L I N K ) ;

    CURPROC 4- FNARG ;

    A p p l y ( F N A R G , A R G L I S T ) ;

    en___dd

    T h i s i m p l e m e n t a t i o n o f c o r o u t t n e s h a s g r e a t

    a p p e a l , b e c a u se i t m ak es i t c l e a r t h a t t h e r e i s o n l y

    o n e " r e a l " t h r e a d o f c o n t r o l r u n n i n g a mo ng a l l t h e

    c o r o u t t n e s . A c o r o u t l n e f u n a r g d oe s n o t r e t a i n a n y

    c o n t r o l s t a c k ; t h e u s e r m u s t s u m m a ri z e t h e s t a t e o f

    t h e c o r o u t l n e I n t h e f u n a r g B AC RF N, w h i c h r e t a i n s

    o n l y s t a t i c a c c e s s f r a m e s . ( R e c a l l t h e

    c o n t i n u a t i o n - p a s s i n g v e r s i o n o f a n o r d i n a r y

    f u n c t i o n , i n w h i c h t h e r e Is n o " r e a l " c o n t r o l s t a c k ,

    b u t t h e c o n t r o l s t a t e i s s i m u l a t e d b y m e a ns o f

    f u n a r g e n v i r o n m e n ts . [ I m p e r a t i v e ] [ D e c l a r a t i v e ] )

    T he u s u a l a p p r o a c h , h o w e v e r , I s t o a l l o w

    e a c h " R e su m e " t o s p e c i f y a v a l u e w h i c h b e c o m es t h e

    v a l u e o f t h e " Re su me m c a l l o f t h e r e su m e d p r o c e s s .

    We s e e n o d i f f i c u l t y w i t h f u n c t i o n s r e t u r n i n g m o r e

    t h a n o n e v a l u e , a n d s o t h e r e i s n o d i s a d v a n t a g e t o

    u s i n g t h i s t e c h n i q u e ( o t h e r th a n t h a t i t r e q u i r e s

    t h e r e t o b e m o r e t h a n on e " r e a l m c o n t r o l s t a c k ) . W e

    t h e r e f o r e r e w r i t e t h e c o r o u t l n e p r i m i t i v e s I n te r m s

    o f e s c a p e f u n c t i o n s :

    3 t a r t ( F N A R G , A R G L I S T )

    b e g i n

    c o m m e n t I n i t i a l l y C UR PR OC m u s t b e s e t t o a n

    e s c a p e f u n c t i o n ;

    S wa p O u t C o r o u t i n e ( ) ;

    C U RC LIN K ~ - A l l o c a t e C o n t r o l F r a m e ( ) ;

    C U R C L I N K . C L I N K ( -

    NIL;

    C U R C L I N K . A L I N K 4 - N I L ;

    CU RPRO C ~ - A l l o c a t e E s c ap e F u n c t i o n O b j e c t ( ) ;

    A p p l y F u n a r g ( F N A R G , A R G L I S T ) ;

    e n d

    Resume(ESCFUN, ARGLIST)

    b e g i n

    Swap

    O u t C o r o u t t n e ( ) ;

    CURPROC ~- ESCFUN ;

    c om m e nt A c t u a l l y , r a t h e r th a n c a l l i n g A p p l y

    E s c a p e F u n c t i o n , w e o u g h t t o d o w h a t i t d o e s

    b u t a l s o s e t C U R PR O C.C LIN K ( a n d a l s o

    C U R PR O C .D LIN K , f o r n e a t n e s s , t h o u g h i t l s n '

    n e c e s s a r y ) t o N I L s o t h a t C URPR OC w i l l n o t

    u n n e c e s s a r i l y r e t a i n c o n t r o l f ra m e s ;

    A p p l y E s c a p e F u n c t l o n ( E S C F U N , A R G L I S T ) ;

    e n d

    S wa p O u t C o r o u t i n e ( )

    b e g i n

    R e l e a s e C o n t r o l F r a m e ( C U R P R O C . C L I N K ) ;

    C U R P R O C . C L I N K ~

    G r a b C o n t r o l F r a m e ( C U R C L I N K . C L I N K ) ;

    c om m e nt T he c u r r e n t c o n t r o l f r a m e m u s t n o t b e a

    d y n a m i c b i n d i n g f r a m e ;

    CURPROC.DLINK~- CURDLINK;

    e n d

    6 4

  • 7/25/2019 ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis -- Macaroni is

    6/7

    I f

    escape functions are used onl y for this purpose,

    i t is e a s y t o s e e t h a t t he c o n t r o l f r a m e s d o n o t

    f o r m t r e e s , b u t

    o n l y

    a f o r e s t o f s t a c k s .

    {Note Stack Groups}

    E a c h o f t h e s e i m p l e m e nt a t i o n s o f c o r o u t i n e s

    h a s t h e p r o p e r t y t h a t n o m o r e c o n t r o l s t a c k i s

    r e t a i n e d f o r t h e c o r o u t l n e s t ha n n e c e s s a r y ; t h e

    first retains none, and the second onl y the relevant

    c o n t r o l s t a c k f o r e a c h c o r o u t i n e . T h e

    i m p l e m e n t a t i o n i n [ B W ] h ad t he p r o b l e m t h a t e v e r y

    c o r o u t i n e r e t a i n e d t h e c o n t r ol s t a c k o f i ts c r e a t o r

    in o r d e r t o r e t a i n t h e e n v i r o n m e n t a l s o .

    { N o t e E N V E V A L T r i c k }

    S t o r a g e A l l o c a t i o n

    I n t h e s i m p l e c a s e s , c o n t r o l a n d a c c e s s

    f r a m e s a r e a l l o c a t e d a l t e r n a t e l y a s t h e c o n t r o l

    s t a c k g r ow s , a n d d e - a l l o c a t e d a l t e r n a t e l y a s t h e

    c o n t r o l s t a c k s h r i n k s . T h i s i s t r u e e v e n i f t h e

    struc tures are not paral lel; the control stack may

    g r o w l i n e a r l y w h i l e t h e a c c e s s s t a c k b e c o m e s a

    l e a f y t r e e . A s l o n g a s n o f u n a r g s a r e c r e a t e d ,

    t h e a c c e s s f r a m e s c an b e d e - a l l o c a t e d a l t e r n a t e l y

    with the control frames.

    If downward funargs are used, then when the

    c o n t r o l s t a c k s h r i n k s b a ck , i t m a y b e p o s s i b l e t o

    de-al locat e an access frame except for the fact that

    a funarg o bject points to it, and it would r equir e a

    g a r b a g e c o l l e c t i o n t o d e t e r m i n e t h a t t h e f u n a r g

    o b j e c t i s a c t u a l l y g a r b a g e . { N ot e S t a c k A l l o c a t i o n }

    In the case of an upward funarg, it woul d act ual l y

    b e i m p o s s i b l e t o d e - a l l o c a t e a n a c c e s s f r a m e .

    F i n a l l y ,

    i n t h e c a s e

    o f a n I t e r a t i v e ( t a i l -

    r e c u r s l v e ) l o o p n o c on t r o l f r a m e s a re a l l o c a t e d o r

    d e - a l l o c a t e d , b u t a c c es s f r a me s m a y b e a l t e r n a t e l y

    al located and released at a great rate.

    T h e s e c a s e s w i l l l e a d t o f r a g m e n t a t i o n o f

    t h e s t a c k a r e a o f c o n t ro l a n d a c c e s s f r a m e s a r e

    a c t u a l l y a l l o c a t e d a l t e r n a t e l y . N e s u g g e s t

    a 1 1 o c a t l n g c o n t r o l f r a m e s f r o m t he b o t t o m u p a n d

    a c c e s s f r a m e s f r o m t h e t o p d o w n t o a v o i d t h i s

    fragmen tation. In the simple case, each end of the

    stack area wil l grow and shrink as a stack. In the

    funa rg cases, the control stack wil l remai n stack-

    l l k e w i t h o u t f r a g m e n t a t io n a s t he a c c e s s f r a m e a r e a

    beco mes possib l y fragmented. In the iteration case,

    t h e c o n t r o l s t a c k w i l l b e s t a c k l i ke w h i l e t h e a c c e s s

    f r a m e s c ha s e a r o u n d a r i n g b u f f e r , i n e f f e c t , a t t h e

    o t h e r e n d . { N o t e R e u s i n g A c c e s s F r a m e s }

    [ B a k e r Z ] i n d i c a t e s t h a t a h y b r i d s t o r a g e

    a l l o c a t i o n s ch em e u s i n g b o t h g a r b ag e c o l l e c t i o n a n d

    r e f e r e n c e c o u n t s m a y b e i n f e r io r t o a s y s t e m u s i n g

    p u r e g a r b ag e c o l l e c t i o n . I f s o , i t w o u ld b e b e t t e r

    t o u s e h i s g a r b a g e c o l l e c t o r a nd s i m p l y a l l o c a t e a l l

    f r a m e s i n t h e h e a p . I n p r a c t i c e t h i s m a y d e p e n d

    c r i t i c a l l y o n t h e p a r t i c u l a r h a r dw a r e u s e d .

    A c k n o w l e d g e m e n t s

    D a n i e l B o b r o w , A l i c e Ha r t l e y , R o n K a p l a n ,

    a n d N a r r e n T e l t e l m a n w e r e m o s t p a t i en t i n d e s c r i b i n g

    t h e I m p l e m e n t a t i o n a n d u s e o f s pa g h e t t i s t a c k s i n

    I n t e r L I S P . C o m m e n t s b y G e r a l d J a y S u s s m a n , J o n

    D o y l e , J o h a n d e K l e e r , a n d R i c h a r d S t a l l m a n w e r e

    a l s o h e l p f u l .

    otes

    { N o t e B i n d i n g P r i n c i p l e )

    O u r d e c i s i o n t o us e a s p e c i a l " b i n d i n g - t y p e "

    c o n s t r u c t f o r e x i t f u n c t i o n s w a s g u i de d b y a g e n e r a l

    p r i n c l p l e : a n y t h i n g y o u c a n d o b y a s s i g n m e n t ,

    e x c e p t c o m m u n i c a t i n g w i t h o th e r p r o c e s s e s , c a n

    p r o b a b l y b e a c c o m p l l s h e d m o r e c l e a r l y b y b i n d i n g ,

    bec ause the extent of the ef fect is contained in an

    o b v i o u s w a y . T h e u s e o f 8 e t e xf n i n [ B N ] m a y b e

    c o m p a r e d t o t h e u s e o f t h e A L T E R s t a t e m e n t i n C O B O L .

    T h e u s e o f a b i n d i n g p r i m i t i v e a l s o a v o i d s t h e

    n e c e s s i t y t o c om p o se u s e r a nd s y s te m e x i t f u n c t i o n .

    { N o t e D e b u g g i n g }

    F r a m e n am e s , l i k e v a r i a b l e n am e s i n a c c e s s

    f r a m e s , m a y b e u s e f u l f o r d e b u g g i n g , b u t s h o u l d n o t

    b e r e q u i r e d f o r t h e c o r r e c t e x e c u t i o n o f t h e u s e r

    p r o g r a m . O ne s h o u l d d r a w a d i s t i n c t i o n b e t w e e n

    p r o g r a m s s u c h a s d e b u g g e rs a nd c o m p i l e r s , w h i c h

    d e pe n d o n t h e p a r t i c u l a r r e p r e s e n t a t i o n o f o t h e r

    p r o g r a m s , a n d p r o g r a m s w h i c h d e p e n d o n t h e i r o w n

    p a r t i c u l a r r e p r e s e n t a t i o n . P r o g r a m s o f t h e l a t t e r

    k i n d c a n n o t e a s i l y t a k e a d v a n t a g e o f n e w

    I m p l e m e n t a t l o n t e c h n i q u e s w h i c h I n v o l v e d i f f e r e n t

    r e p r e s e n t a t i o n s .

    { N o t e S t a c k G r o u p s }

    The fact that generators are the primary us e

    o f s p a g h e t t i s t a c k s I n I n t e r L I S P l e a d s u s t o

    s p e c u l a t e t h a t t h e l e s s g e n e r a l " s ta c k g r o u p " m o d e l

    p r o p o s e d b y G r e e n b l a t t f o r t h e L I S P m a c h i n e

    [ G r e e n b l a t t Z ] m a y b e a d e q u a t e f o r m a ny p u r p o s e s .

    T h i s m o d e l p r o v i d e s m u l t i p l e s e t s o f c o n t r o l s t a c k s ,

    w i t h o u t a l l o w i n g f o r a g e n e r a l t r e e s t r u c t u r e . T h is

    m o d e l h a s n o w b e e n i m p l e m e n t e d on t h e L I S P M a c h i n e

    a t N I T .

    { N o t e E N V E V A L T r i c k }

    Ron Kaplan [Kaplan] tel ls us that a certain

    sys tem in InterLIS P creates several generat ors as it

    i s b e i n g l o a d e d f o r u s e a t r u n t im e , a n d t h a t

    s p e c l a l p a i n s m u s t b e t a k en , u s i n g t h e E N V E V A L

    primitive, so that the control stack of the loader

    w i l l n o t be r e t a i n e d b y t h e c o n t r o l s t a c k s o f t h e

    g e n e r a t o r s .

    { N o t e S t a ck A l l o c a t i o n }

    S om e l a n g u a g e s , s u c h a s E CL [ C o n r a d ]

    [ N e g b r e l t ] , p r o v i d e f o r s t a c k a l l o c a t i o n o f

    a r b i t r a r y , d a t a o b j e c t s , w h i c h m i g h t a l l e v i a t e t h i s

    p r o b l e m .

    {Note Reuslng Access Frames}

    In many It eratlve sltuatlons it is easy for

    a c o m p i l e r t o de t e c t t h a t a p r o v i d e d a c c e s s f r a m e

    w i l l b e t h r o w n a w a y o n t a l l - r e c u r s l o n t o a n o t h e r

    funct ion; if the frame for the cal led funct ion is

    t h e s am e s i z e ( o r s m a l l e r ) t h a n t h e on e f o r t h e

    c a l l i n g f u n c t i o n , t h e c o m p i l e r m ay a r r a n g e t o r e - u s e

    t h e f r a m e r a t h e r t h a n a l l o c a t i n g a n ew o n e . T h i s I s

    s i m i l a r t o so m e o f t h e i d e a s i n [ D a r l t n g t o n a n d

    B u r s t a 1 1 ] , b u t m or e l i k e l y t o be a p p l i c a b l e b e ca u s e

    t h e c o m p i l e r ca n o f t e n d e t e r m i ne a b s o l u t e l y t h a t t h e

    f r am e i s t o b e d is c a r d e d .

    6 5

  • 7/25/2019 ACM SIGPLAN Notices Volume 12 Issue 8 1977 [Doi 10.1145%2F872734.806933] Steele, Guy Lewis -- Macaroni is

    7/7

    References

    [Baker l ]

    Baker, Henry B., Jr . Shallow Binding in LISP

    1.5. AI Working Paper 138. HIT AI Lab (January

    i 9 7 7 .

    [Baker2]

    Baker, Henry B., Jr. Li st Processing in Real

    Time on a Se ri al Computer. AI Working Paper

    139. HIT AI Lab (February 1977). To appear in

    Comm. ACH.

    [ ~ ]

    Bobrow, Danlel O. and Wegbrelt , Ben.

    A

    Model

    a nd S t a c k I m p l e m e n t a t i o n o f M u l t i p l e

    Environmen ts. = CACM 4, I0 (Octob er 1973) pp.

    591-603.

    [Conrad]

    Conrad, William R. Int ern al Representations of

    ECL Data Ty pes . Technical Report 5-75 . Center

    for Research In Computing Technology, Harvard U.

    (Cambridge, March 1975).

    [Darllngton

    and

    Burstall]

    Darllngton, J., and Burstall, R.M. A S y s t e m

    w h l c h A u t o m a t i c a l l y I mpr ove s P r o g r a m s . A c t a

    Informatlca 6 (1976), 41-60.

    [ Declarative

    Steel e, Guy Lewls Jr . LAMBDA: The Ul ti ma te

    D e c l a r a t i v e . AI N e m o 3 7 9 .

    MIT

    AI L a b

    (Cambridge, November 1976).

    [Oreenbla t t l ]

    Ore enb lat t, R lchard . The LISP machine.

    A r t l f l c l a l

    In te l l i gence

    Working Paper 79, HIT

    (Cambridge, November 1974).

    [Oreenblatt2]

    Personal communications

    with

    Rlchard Oreenblatt

    (March 1978).

    [ Imperat ive]

    Steel e, Guy Lewis Jr ., and Sussman, Gerald Jay.

    LMIBDA:

    The Ultimate Imperative. AI Memo 353.

    MIT AI Lab (Cambridge, March 1976).

    [Landln]

    Landtn, Peter J. A Correspondence between

    ALGOL 60 and Church's Lambda-Nota tion. CACM8,

    2-3 (February and March 1965).

    [Kaplan]

    Personal communications

    (February 1977).

    w i th

    Ron Kaplan

    [ R e y n o l d s ]

    R e y n o l d s, J o h n C . = D e f i n i t i o n a l I n t e rpr e t e r s

    f o r Hi g h e r O r d e r P r o g r a m m i n g L a n g u a g e s . A C M

    Conference Proceedings 1072.

    [SCHEME]

    Sussman, Gerald Jay , and Steel e, Guy Lewis Jr.

    S C HE ME : A n I n t e rpr e t e r f o r Ext e n d e d L a m b d a

    Cal cul us. AI Memo 349. NIT AI Lab (Cambridge,

    December 1975).

    [TECO]

    There Is no publishe d reference f or ITS TECO,

    but

    those wi th ARPANET access can re tr ie ve the

    f l l e .INFO.;TECO ORDER ~ MIT-AI. See the FN

    command therein.

    [ T e l t e l m a n ]

    Teltelman, Warren, et al. InterLISP Refe rence

    M a n u a l . R e v i s e d e d i t i o n. X e r o x P a l o A l t o

    Research Center (Palo Alto, 1975).

    [We g b r e l t ]

    Wegbrelt, B en , et al. ECL Programmer's Manual.

    Technical Report Z3 -7 4. Center for Research In

    Compu ting Technology, Harvar d U. (Cambridge ,

    December 1974).

    66


Recommended