Top Banner

of 168

Manual CafeObj Ingles Completo

Apr 06, 2018

Download

Documents

uc20090071
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/2/2019 Manual CafeObj Ingles Completo

    1/168

    C a f e O B J U s e r ' s M a n u a l

    | v e r . 1 . 4 |

    A t a r u T . N a k a g a w a T o s h i m i S a w a d a K o k i c h i F u t a t s u g i

  • 8/2/2019 Manual CafeObj Ingles Completo

    2/168

    1

    C h a n g e s f r o m V e r s i o n 1 . 3

    T h e m a i n c h a n g e s f r o m v e r s i o n 1 . 3 a r e a s f o l l o w s .

    I n a d d i t i o n t o G n u C o m m o n L i s p , C M U C o m m o n L i s p a n d A l l e g r o C o m m o n L i s p c a n b e u s e d

    a s a p l a t f o r m .

    F a s t e r r e w r i t e e n g i n e s a r e n o w a v a i l a b l e , a n d c a n b e i n v o k e d f r o m C a f e O B J .

    T h e p r e d i c a t e = = > ( f o r t r a n s i t i o n r e l a t i o n s ) g e t s a m o r e p o w e r f u l s u p p o r t . A c o u p l e o f n e w

    s w i t c h e s a r e a d d e d f o r t h i s r e a s o n .

    B e h a v i o u r a l a x i o m s c a n b e u s e d i n e q u a t i o n a l r e d u c t i o n , a n d a n o p e r a t o r a t t r i b u t e c o h e r e n t i s

    a d d e d f o r t h i s p u r p o s e .

    A b e h a v i o u r a l r e d u c t i o n c o m m a n d i s i n t r o d u c e d .

    S o r t p r e d i c a t e s a r e i n t r o d u c e d .

  • 8/2/2019 Manual CafeObj Ingles Completo

    3/168

    2

  • 8/2/2019 Manual CafeObj Ingles Completo

    4/168

    C o n t e n t s

    1 D i a l o g u e w i t h t h e S y s t e m 1 1

    1 . 1 H e l l o , G o o d b y e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1

    1 . 1 . 1 S t a r t i n g U p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1

    1 . 1 . 2 Q u i t t i n g t h e S y s t e m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2

    1 . 1 . 3 E m e r g e n c y | R e s u m p t i o n a n d B u g R e p o r t s . . . . . . . . . . . . . . . . . . . . 1 2

    1 . 2 F i l e s a n d L i b r a r i e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3

    1 . 2 . 1 R e a d i n g F i l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3

    1 . 2 . 2 S a v i n g a n d R e s t o r i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 4

    1 . 2 . 3 I n i t i a l i s a t i o n s a n d O p t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    1 . 2 . 4 B a t c h C a f e O B J . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1 . 2 . 5 M o d u l e L i b r a r i e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1 . 2 . R e q u i r i n g a n d P r o v i d i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7

    1 . 3 S o m e H e l p f u l C o m m a n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7

    1 . 3 . 1 H e l p C o m m a n d a n d T o p - l e v e l C o m m a n d s . . . . . . . . . . . . . . . . . . . . . . 1 7

    1 . 3 . 2 S w i t c h - T o g g l i n g C o m m a n d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 8

    1 . 3 . 3 I n s p e c t i o n C o m m a n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9

    2 M o d u l e D e c l a r a t i o n 2 1

    2 . 1 O v e r a l l S t r u c t u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1

    2 . 2 B l o c k s i n a M o d u l e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2

    2 . 3 T i g h t M o d u l e s , L o o s e M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3

    2 . 4 C o m m e n t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4

    2 . 5 I m p o r t D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 5

    3 S i g n a t u r e 2 7

    3 . 1 S o r t D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 7

    3 . 1 . 1 S o r t D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 7

    3 . 1 . 2 S u b s o r t D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 8

    3 . 2 O p e r a t o r D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 9

    3 . 2 . 1 O p e r a t o r D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 9

    3

  • 8/2/2019 Manual CafeObj Ingles Completo

    5/168

    4 C O N T E N T S

    3 . 2 . 2 B e h a v i o u r a l O p e r a t o r D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1

    3 . 2 . 3 P r e d i c a t e D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2

    3 . 3 T e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2

    3 . 3 . 1 W e l l - f o r m e d T e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2

    3 . 3 . 2 P a r s i n g T e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4

    3 . 3 . 3 Q u a l i f y i n g T e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5

    3 . 4 R e c o r d D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 7

    3 . 4 . 1 P l a i n R e c o r d D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 7

    3 . 4 . 2 I n h e r i t i n g R e c o r d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 8

    4 A x i o m s 4 1

    4 . 1 V a r i a b l e D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1

    4 . 2 E q u a t i o n D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2

    4 . 2 . 1 U n c o n d i t i o n a l E q u a t i o n D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . 4 2

    4 . 2 . 2 C o n d i t i o n a l E q u a t i o n D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4

    4 . 2 . 3 B e h a v i o u r a l E q u a t i o n D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4

    4 . 3 T r a n s i t i o n D e c l a r a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5

    4 . 4 I n t e r n a l i s i n g A x i o m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    4 . 4 . 1 E q u a l i t y P r e d i c a t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    4 . 4 . 2 T r a n s i t i o n P r e d i c a t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 7

    4 . 4 . 3 B e h a v i o u r a l E q u i v a l e n c e P r e d i c a t e . . . . . . . . . . . . . . . . . . . . . . . . . . 4 8

    4 . 4 . 4 S o r t P r e d i c a t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 9

    5 I n s p e c t i n g M o d u l e s 5 1

    5 . 1 U s i n g I n s p e c t i o n C o m m a n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1

    5 . 1 . 1 P r i n t i n g W h o l e M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1

    5 . 1 . 2 P r i n t P a r t o f M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2

    5 . 1 . 3 D e e p I n s p e c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4

    5 . 1 . 4 I n s p e c t i n g R e c o r d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5

    5 . 2 S o m e T y p i c a l M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 7

    5 . 2 . 1 U n i q u e M o d e l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 7

    5 . 2 . 2 I n s p e c t i n g T r a n s i t i o n A x i o m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 8

    5 . 2 . 3 N o n - i s o m o r p h i c M o d e l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 9

    5 . 2 . 4 I n s p e c t i n g H i d d e n S o r t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 9

    6 E v a l u a t i n g T e r m s 6 1

    . 1 T e r m R e w r i t i n g S y s t e m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    . 1 . 1 W h a t i s a T R S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    . 1 . 2 H o w a M o d u l e D e n e s a T R S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

  • 8/2/2019 Manual CafeObj Ingles Completo

    6/168

    C O N T E N T S 5

    . 2 D o t h e E v a l u a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    . 2 . 1 E v a l u a t i o n C o m m a n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    . 2 . 2 R e p l a c i n g E q u a l s b y E q u a l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    . 2 . 3 E q u a t i o n s a n d T r a n s i t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    . 2 . 4 U s i n g B e h a v i o u r a l E q u a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    . 2 . 5 E v a l u a t i o n T r a c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    . 2 . E x a m p l e s o f C o n d i t i o n a l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    . 3 S t e p p e r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1

    . 3 . 1 S t e p M o d e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1

    . 3 . 2 E v a l u a t i o n U n d e r t h e S t e p M o d e . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2

    . 3 . 3 C o n t r o l l e d R e d u c t i o n , b y P a t t e r n s . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4

    . 3 . 4 C o n t r o l l e d R e d u c t i o n , b y N u m b e r o f S t e p s . . . . . . . . . . . . . . . . . . . . . 7

    . 4 F a s t e r E v a l u a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7

    . 5 C o n t e x t V a r i a b l e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 9

    . F l e x i b l e T y p i n g a n d E r r o r H a n d l i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1

    . . 1 F a c t o r i a l o f R a t i o n a l s ( ! ? ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1

    . . 2 S t a c k s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3

    . . 3 H a n d l i n g E r r o r s a s E r r o r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4

    7 O p e r a t o r A t t r i b u t e s 8 7

    7 . 1 E q u a t i o n a l T h e o r y A t t r i b u t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 7

    7 . 1 . 1 A s s o c i a t i v i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 8

    7 . 1 . 2 C o m m u t a t i v i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 8

    7 . 1 . 3 I d e n t i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 9

    7 . 1 . 4 I d e m p o t e n c y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 9

    7 . 1 . 5 I n h e r i t i n g E q u a t i o n a l T h e o r y A t t r i b u t e s . . . . . . . . . . . . . . . . . . . . . . . 9 0

    7 . 2 P a r s i n g A t t r i b u t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 0

    7 . 2 . 1 P r e c e d e n c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 0

    7 . 2 . 2 L e f t / R i g h t A s s o c i a t i v i t y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1

    7 . 3 C o n s t r u c t o r A t t r i b u t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2

    7 . 4 E v a l u a t i o n S t r a t e g y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2

    7 . 4 . 1 E - S t r a t e g y A t t r i b u t e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2

    7 . 4 . 2 D e f a u l t S t r a t e g y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3

    7 . 4 . 3 L a z y E v a l u a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3

    7 . 4 . 4 I n t e r p r e t i n g E - S t r a t e g i e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4

    7 . 5 M e m o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5

    7 . 5 . 1 C o h e r e n c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5

    7 . O p e r a t o r A t t r i b u t e s a n d E v a l u a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

  • 8/2/2019 Manual CafeObj Ingles Completo

    7/168

    C O N T E N T S

    7 . 7 F u r t h e r E x a m p l e : P r o p o s i t i o n a l C a l c u l u s . . . . . . . . . . . . . . . . . . . . . . . . . . 9 8

    7 . 8 L i m i t a t i o n o f t h e I m p l e m e n t a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 0

    8 M o d u l e S t r u c t u r e 1 0 3

    8 . 1 N a m e s a n d C o n t e x t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 3

    8 . 1 . 1 C o n t e x t a n d C u r r e n t M o d u l e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 3

    8 . 1 . 2 M o d u l e S h a r i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 5

    8 . 1 . 3 Q u a l i f y i n g N a m e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 5

    8 . 1 . 4 R e f e r r i n g t o O p e r a t o r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0

    8 . 2 P a r a m e t e r s a n d V i e w s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 7

    8 . 2 . 1 P a r a m e t e r i s e d M o d u l e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 7

    8 . 2 . 2 P r e - v i e w ( N o t P r e v i e w ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0 8

    8 . 2 . 3 V i e w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 0

    8 . 2 . 4 V i e w s G a l o r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 1

    8 . 2 . 5 N o t Q u i t e a V i e w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 2

    8 . 2 . S u c c i n c t V i e w s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 4

    8 . 3 B i n d i n g P a r a m e t e r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 5

    8 . 3 . 1 I n s t a n t i a t i o n o f P a r a m e t e r i s e d M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . 1 1 5

    8 . 3 . 2 P a r a m e t e r s a s I m p o r t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1

    8 . 3 . 3 P a r a m e t e r P a s s i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 7

    8 . 3 . 4 P a r a m e t e r s w i t h P a r a m e t e r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 9

    8 . 3 . 5 Q u a l i f y i n g P a r a m e t e r N a m e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 0

    8 . 4 M o d u l e E x p r e s s i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 1

    8 . 4 . 1 M o d u l e N a m e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 1

    8 . 4 . 2 R e n a m i n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 1

    8 . 4 . 3 M o d u l e S u m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 2

    8 . 4 . 4 M a k i n g M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 2

    9 T h e o r e m - P r o v i n g T o o l s 1 2 5

    9 . 1 O p e n / C l o s i n g M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 5

    9 . 1 . 1 W h y O p e n i n g M o d u l e s ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 5

    9 . 1 . 2 C o n s t a n t O n t h e F l y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 7

    9 . 2 A p p l y i n g R e w r i t e R u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 8

    9 . 2 . 1 S t a r t , T h e n A p p l y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 9

    9 . 2 . 2 A p p l y i n g A p p l y C o m m a n d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 0

    9 . 2 . 3 C h o o s i n g S u b t e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 1

    9 . 2 . 4 I d e n t i f y i n g R e w r i t e R u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 3

    9 . 2 . 5 A p p y l i n g C o n d i t i o n a l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 4

    9 . 3 M a t c h i n g T e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3

  • 8/2/2019 Manual CafeObj Ingles Completo

    8/168

    C O N T E N T S 7

    9 . 3 . 1 M a t c h C o m m a n d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 7

    9 . 3 . 2 M a t c h i n g T e r m s t o T e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 7

    9 . 3 . 3 M a t c h i n g T e r m s t o P a t t e r n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 8

    1 0 P r o v i n g M o d u l e P r o p e r t i e s 1 4 1

    1 0 . 1 C h e c k C o m m a n d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 4 1

    1 0 . 2 T h e o r e m P r o v i n g T e c h n i q u e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 4 3

    1 0 . 2 . 1 S t r u c t u r a l I n d u c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 4 4

    1 0 . 2 . 2 N o n d e t e r m i n i s t i c T r a n s i t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 4 5

    1 0 . 2 . 3 S y s t e m a t i c S e a r c h f o r T r a n s i t i o n R e l a t i o n s . . . . . . . . . . . . . . . . . . . . . 1 4 7

    1 0 . 2 . 4 B e h a v i o u r a l E q u i v a l e n c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 4 9

    1 0 . 2 . 5 B e h a v i o u r a l T r a n s i t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 0

    1 1 B u i l t - i n M o d u l e s 1 5 3

    1 2 R e f e r e n c e M a n u a l 1 5 5

    1 2 . 1 L e x i c a l A n a l y s i s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 5

    1 2 . 1 . 1 R e s e r v e d W o r d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 5

    1 2 . 1 . 2 S e l f - T e r m i n a t i n g C h a r a c t e r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 5

    1 2 . 1 . 3 I d e n t i e r s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 5

    1 2 . 1 . 4 O p e r a t o r S y m b o l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    1 2 . 1 . 5 C o m m e n t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    1 2 . 2 C a f e O B J C o d e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    1 2 . 2 . 1 M o d u l e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    1 2 . 2 . 2 V i e w s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 7

    1 2 . 2 . 3 E v a l u a t i o n C o m m a n d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 8

    1 2 . 2 . 4 M o d u l e E x p r e s s i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 8

    1 2 . 2 . 5 T e r m s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 8

    1 2 . 2 . A b b r e v i a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 8

    1 2 . 2 . 7 S u g a r C o a t i n g s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 9

    1 2 . 3 C o m m a n d S u m m a r y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 9

    A A B r i e f G u i d e t o B a s i c N o t i o n s a n d T e r m i n o l o g y 1 6 1

  • 8/2/2019 Manual CafeObj Ingles Completo

    9/168

    8 C O N T E N T S

  • 8/2/2019 Manual CafeObj Ingles Completo

    10/168

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

    C a f e O B J i s a s p e c i c a t i o n l a n g u a g e b a s e d o n t h r e e - w a y e x t e n s i o n s t o m a n y - s o r t e d e q u a t i o n a l l o g i c :

    t h e u n d e r l y i n g l o g i c i s o r d e r - s o r t e d , n o t j u s t m a n y - s o r t e d ; i t a d m i t s u n i d i r e t i o n a l t r a n s i t i o n s , a s w e l l

    a s e q u a t i o n s ; i t a l s o a c c o m m o d a t e s h i d d e n s o r t s , o n t o p o f o r d i n a r y , v i s i b l e s o r t s . A s u b s e t o f C a f e O B J

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

    s y s t e m . T h e s e t h e o r e t i c a l b a s e s a r e i n d i s p e n s a b l e t o e m p l o y C a f e O B J p r o p e r l y . F o r t u n a t e l y , t h e r e i s

    a n a m p l e l i t e r a t u r e o n t h e s e s u b j e c t s , a n d w e a r e a b l e t o r e f e r t h e r e a d e r t o , e . g . , [ 4 ] , [ 1 3 ] ( f o r b a s i c s

    o f a l g e b r a i c s p e c i c a t i o n s ) , [ 8 ] , [ ] ( f o r o r d e r - s o r t e d l o g i c ) , [ 7 ] ( f o r h i d d e n s o r t s ) , [ 1 0 ] ( f o r c o i n d u c t i o n ) ,

    [ 1 2 ] ( f o r r e w r i t i n g l o g i c ) , [ 5 ] ( f o r i n s t i t u t i o n s ) , a n d [ 1 1 ] , [ 1 ] ( f o r t e r m r e w r i t i n g s y s t e m s ) , a s p r i m e r s .

    T h e l o g i c a l a s p e c t s o f C a f e O B J a r e e x p l a i n e d i n d e t a i l i n [ 2 ] a n d [ 3 ] . T h i s m a n u a l i s f o r t h e i n i t i a t e d ,

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

    F o r a v e r y b r i e f i n t r o d u c t i o n , w e j u s t h i g h l i g h t a c o u p l e o f f e a t u r e s o f C a f e O B J . C a f e O B J i s a n o s p r i n g

    o f t h e f a m i l y o f a l g e b r a i c s p e c i c a t i o n t e c h n i q u e s . A s p e c i c a t i o n i s a t e x t , u s u a l l y o f f o r m a l s y n t a x . I t

    d e n o t e s a n a l g e b r a i c s y s t e m c o n s t r u c t e d o u t o f s o r t s ( o r d a t a t y p e s ) a n d s o r t e d ( o r t y p e d ) o p e r a t o r s .

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

    e q u a t i o n ( \ e s s e n t i a l l y a l g e b r a i c " ) , b u t i s n o w c o n s t r u e d m u c h m o r e b r o a d l y . F o r e x a m p l e , C a f e O B J

    a c c o m m o d a t e s c o n d i t i o n a l e q u a t i o n s , d i r e c t e d t r a n s i t i o n s , a n d ( l i m i t e d ) u s e o f d i s e q u a l i t y .

    T h e u n d e r l y i n g l o g i c o f C a f e O B J i s a s f o l l o w s

    1

    O r d e r - s o r t e d l o g i c [ 8 ] . A s o r t m a y b e a s u b s e t o f a n o t h e r s o r t . F o r e x a m p l e , n a t u r a l n u m b e r s

    m a y b e e m b e d d e d i n t o r a t i o n a l s . T h i s e m b e d d i n g m a k e s v a l i d t h e a s s e r t i o n t h a t 3 e q u a l s / 2 .

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

    a u t o m a t i c a l l y d e c l a r e d o n n a t u r a l n u m b e r s . M o r e o v e r , t h e s u b s o r t r e l a t i o n o e r s y o u a s i m p l e

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

    R e w r i t i n g l o g i c [ 1 2 ] . I n a d d i t i o n t o e q u a l i t y , w h i c h i s s u b j e c t t o t h e l a w o f s y m m e t r y , y o u m a y

    u s e t r a n s i t i o n r e l a t i o n s , w h i c h a r e d i r e c t e d i n o n e w a y o n l y . S t a t e t r a n s i t i o n s a r e n a t u r a l l y f o r -

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

    a n d / o r i n d e t e r m i n a c y .

    H i d d e n s o r t s [ 7 ] . Y o u h a v e t w o k i n d s o f e q u i v a l e n c e . O n e i s a m i n i m a l e q u i v a l e n c e , t h a t

    i d e n t i e s t e r m s ( e l e m e n t s ) i t h e y a r e t h e s a m e u n d e r t h e g i v e n e q u a t i o n a l t h e o r y . A n o t h e r

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

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

    W e w o u l d a l s o l i k e t o e m p h a s i s e a v e r y u s e f u l f e a t u r e o f C a f e O B J .

    P a r a m e t e r s . T h e r e a r e m a n y s o r t s t h a t a r e i n h e r e n t l y g e n e r i c . S t a c k s , l i s t s , s e t s a n d s o o n h a v e

    o p e r a t i o n s t h a t a c t i n d e p e n d e n t l y o f t h e p r o p e r t i e s o f b a s e ( \ d a t a " ) e l e m e n t s . A m o r e t r i c k y

    c a s e i s p r i o r i t y q u e u e s , w h i c h r e q u i r e b a s e e l e m e n t s t o h a v e a n o r d e r r e l a t i o n . Y o u m a y d e n e

    t h e s e s o r t s b y p a r a m e t e r i s e d m o d u l e s , w h e r e b a s e e l e m e n t s a r e p a r a m e t e r i s e d o u t . A p a r a m e t e r

    m a y b e s u b j e c t t o c o n s t r a i n t s . F o r e x a m p l e , t h e p a r a m e t e r o f a p r i o r i t y q u e u e m o d u l e m a y b e

    d e c l a r e d a n o r d e r e d s e t , n o t a n a r b i t r a r y s e t .

    1

    S o m e o f t h e a u t h o r s f e e l t h a t s o m e o f t h e s e t e c h n i c a l t e r m s a r e q u e e r . B u t t o a v o i d c o n f u s i o n , w e b a s i c a l l y k e e p t o

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

    9

  • 8/2/2019 Manual CafeObj Ingles Completo

    11/168

    1 0 C O N T E N T S

    L e g e n d s

    R e s t r i c t i o n s , p a r t i c u l a r s , a n d p r e j u d i c e s o f t h e c u r r e n t i m p l e m e n t a t i o n s h a l l b e h i g h l i g h t e d i n b o x e s ,

    a s

    W a r n i n g W o e b e t i d e t h o s e w h o d o n o t h e e d t h i s w a r n i n g !

    w h i l e s y n t a c t i c a l d e n i t i o n s a r e s h o w n a s

    S y n t a x 1 : t i t l e

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

    T h e d e n i t i o n s i n s i d e t h e b o x a r e b y w a y o f n o t a t i o n s a s f o l l o w s .

    ( 1 ) f g a r e m e t a - s y n t a c t i c a l b r a c k e t s .

    ( 2 ) j s e p a r a t e s a l t e r n a t i v e s .

    ( 3 ) 3 m e a n s z e r o o r m o r e r e p e t i t i o n s o f t h e p r e c e d i n g c o n s t r u c t .

    ( 4 ) + m e a n s o n e o r m o r e r e p e t i t i o n s .

    ( 5 ) 3 m e a n s z e r o o r m o r e r e p e t i t i o n s s e p a r a t e d b y c o m m a s .

    ( ) + m e a n s o n e o r m o r e r e p e t i t i o n s s e p a r a t e d b y c o m m a s .

    ( 7 ) [ , ] e n c l o s e o p t i o n a l c o n s t r u c t s .

    ( 8 ) T h e a b o v e s y m b o l s , t o a p p e a r a s t h e y a r e , a r e e n c l o s e d b y q u o t e s , a s \ { "

    ( 9 ) S y m b o l s i n t h e t y p e w r i t e r f o n t a p p e a r a s t h e y a r e : x i s l i t e r a l l y x . I n c a s e t h i s c o n v e n t i o n i s

    a m b i g u o u s , e . g . w h e n a p a r e n t h e s i s a p p e a r s i n i s o l a t i o n , s y m b o l s a r e q u o t e d a s i n ( 8 ) .

    F o r e x a m p l e ,

    A +

    r e p r e s e n t s s e q u e n c e s o f o n e o r m o r e A ' s , s e p a r a t e d b y c o m m a s .

  • 8/2/2019 Manual CafeObj Ingles Completo

    12/168

    C h a p t e r 1

    D i a l o g u e w i t h t h e S y s t e m

    A v a i l a b i l i t y

    Y o u m a y o b t a i n a c o m p l e t e d i s t r i b u t i o n p a c k a g e f r o m t h e f o l l o w i n g s i t e s . I n J a p a n , t h e r e l e v a n t l e s

    a r e

    f t p : / / f t p . s r a . c o . j p / p u b / l a n g / C a f e O B J / c a f e o b j - ? ? ? . t a r . g z

    f t p : / / f t p . s r a . c o . j p / p u b / l a n g / C a f e O B J / t r a m - ? ? ? . t a r . g z

    f t p : / / f t p . s r a . c o . j p / p u b / l a n g / C a f e O B J / b r u t e - ? ? ? . t a r . g z

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

    h t t p : / / w w w . l d l . j a i s t . a c . j p / c a f e o b j /

    M i r r o r s i t e s i n E u r o p e a n d U S A a r e u n d e r c o n s i d e r a t i o n .

    T h e c u r r e n t v e r s i o n w o r k s u n d e r U n i x o p e r a t i n g s y s t e m s ( u s u a l v e r n a c u l a r s , i n c l u d i n g v a r i o u s v e r s i o n s

    o f S u n O S , F r e e B S D , a n d L i n u x , a r e a l l o k a y ) o r M a c i n t o s h , a n d i s i m p l e m e n t e d o n v a r i o u s C o m m o n

    L i s p p r o c e s s o r s ( i n c l u d i n g G n u , C M U , A l l e g r o , a n d M a c L i s p ) . B u t y o u c a n n o t r u n , f o r e x a m p l e ,

    M a c L i s p o n S o l a r i s , f o r a n o b v i o u s r e a s o n . O n t h e q u e s t i o n o f w h i c h L i s p s y s t e m s t o u s e o n w h i c h

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

    ( R E A D M E ) i n t h e d i s t r i b u t i o n p a c k a g e .

    I n p r i n c i p l e t h e s y s t e m s h o u l d a l s o w o r k o n W i n d o w s w i t h A l l e g r o , b u t t h e r e i s n o g u a r a n t e e o f i t s

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

    1 . 1 H e l l o , G o o d b y e

    1 . 1 . 1 S t a r t i n g U p

    A f t e r i n s t a l l a t i o n , t y p e \ c a f e o b j " t o y o u r s h e l l t o i n v o k e t h e s y s t e m . T h e n t h e C a f e O B J i n t e r p r e t e r

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

    % c a f e o b j

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

    ; L o a d i n g / m n t 1 / l a n g / c a f e o b j - 1 . 4 / p r e l u d e / s t d . b i n .

    - - C a f e O B J s y s t e m V e r s i o n 1 . 4 . 1 0 0 2 0 3 p 1 1 6 - -

    b u i l t : 1 9 8 4 D e c 2 4 M o n 3 : 4 4 : 1 7 G M T

    1 1

  • 8/2/2019 Manual CafeObj Ingles Completo

    13/168

    1 2 C H A P T E R 1 . D I A L O G U E W I T H T H E S Y S T E M

    p r e l u d e f i l e : s t d . b i n

    * * *

    1 9 9 9 D e c 3 1 F r i 2 3 : 5 9 : 4 5 G M T

    T y p e ? f o r h e l p

    C a f e O B J >

    F o r a m o m e n t , i g n o r e t h e m e s s a g e . \ C a f e O B J > " i s a p r o m p t f o r y o u r r e q u e s t s . Y o u m a y t y p e m o d u l e s ,

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

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

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

    f o r n o w ) .

    C a f e O B J > m o d u l e T E S T { [ E l t ] }

    - - d e f i n i n g m o d u l e T E S T _ * d o n e .

    C a f e O B J >

    Y o u r i n p u t i s u p t o t h e r s t n e w l i n e c h a r a c t e r . T h e r e s t i s f r o m t h e s y s t e m . I t s h o w s t h a t t h e s y s t e m

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

    m a y c o n t i n u e t o f e e d o t h e r m o d u l e s , o r c h e c k i f i n d e e d t h e m o d u l e i s c o r r e c t l y s t o r e d . A s a f u r t h e r

    t r i a l , t y p e

    C a f e O B J > s e l e c t T E S T

    T E S T >

    T h e c o m m a n d s e l e c t t a k e s a s a r g u m e n t a m o d u l e n a m e . \ T E S T > " i s a n e w p r o m p t . A s y o u s e e , T E S T

    i s t h e n a m e o f t h e m o d u l e j u s t s e l e c t e d . T h e s y s t e m m a i n t a i n s a m o d u l e , c a l l e d t h e c u r r e n t m o d u l e

    t h a t i s t h e f o c u s o f m a n i p u l a t i o n a t t h e t i m e . T h e i n i t i a l p r o m p t \ C a f e O B J > " i n d i c a t e s t h e c u r r e n t

    m o d u l e i s n o t y e t s u p p l i e d . O r a m o d u l e C a f e O B J i s n o w c u r r e n t ( i t i s p o s s i b l e , i f c o n f u s i n g , t o d e n e

    s u c h a m o d u l e ) . V a r i o u s c o m m a n d s , s u c h a s p a r s i n g a n d r e d u c t i o n , a r e e x e c u t e d u n d e r t h e c u r r e n t

    m o d u l e . F o r m o r e d e t a i l s o n c u r r e n t m o d u l e s , s e e S e c t i o n 8 . 1 . 1 .

    1 . 1 . 2 Q u i t t i n g t h e S y s t e m

    T o q u i t C a f e O B J , t y p e q u i t ( o r q f o r s h o r t ) o r t h e e n d o f i n p u t c h a r a c t e r ( u s u a l l y c o n t r o l - D ) a t a

    p r o m p t . T h e n t h e i n t e r p r e t e r t e r m i n a t e s a n d t h e c o n t r o l i s g i v e n b a c k t o t h e o r i g i n a l s h e l l .

    C a f e O B J > q u i t

    [ L e a v i n g C a f e O B J ]

    %

    1 . 1 . 3 E m e r g e n c y | R e s u m p t i o n a n d B u g R e p o r t s

    I n d e t e c t i n g e r r o r s , C a f e O B J g r o w l s .

    C a f e O B J > m o d u l e E R R O R }

    [ E r r o r ] : w a s e x p e c t i n g t h e s y m b o l ` { ' n o t ` } ' .

    C a f e O B J >

  • 8/2/2019 Manual CafeObj Ingles Completo

    14/168

    1 . 2 . F I L E S A N D L I B R A R I E S 1 3

    T h e a b o v e m e s s a g e s t a r t i n g w i t h \ [ E r r o r ] " i n d i c a t e s t h a t t h e s y s t e m d e t e c t e d a s y n t a x e r r o r i n

    p r o c e s s i n g y o u r i n p u t .

    D u e t o i r r e c o v e r a b l e i n p u t e r r o r s , o r j u s t t o m u l f u n c t i o n s , C a f e O B J m a y s t o p a b n o r m a l l y , a n d t h r o w

    t h e c o n t r o l a w a y t o a n e r r o r e n v i r o n m e n t .

    C a f e O B J > ^ C

    C o r r e c t a b l e e r r o r : C o n s o l e i n t e r r u p t .

    S i g n a l l e d b y C A F E O B J - T O P - L E V E L .

    I f c o n t i n u e d : T y p e : r t o r e s u m e e x e c u t i o n , o r : q t o q u i t t o t o p l e v e l .

    B r o k e n a t S Y S T E M : T E R M I N A L - I N T E R R U P T . T y p e : H f o r H e l p .

    C H A O S > >

    T h e a b o v e s e s s i o n w a s o b t a i n e d b y t y p i n g t h e i n t e r r u p t c o d e ( u s u a l l y C o n t r o l - C ) a t t h e i n i t i a l p r o m p t ,

    f o r c i n g C a f e O B J t o s t o p w i l l y - n i l l y . T h e p r o m p t \ C H A O S > > " i n d i c a t e s y o u p l u n g e d i n t o a n e r r o r

    e n v i r o n m e n t . T h e a b o v e m e s s a g e m a y l o o k f a m i l i a r t o y o u , i f y o u a r e a u s e r o f G C L . T h e m e s s a g e w a s

    f r o m G C L , a n d t h e e r r o r e n v i r o n m e n t i s a G C L e r r o r l o o p

    1

    F o l l o w i n g t h e i n s t r u c t i o n s f r o m G C L , y o u m a y r e s u m e t h e C a f e O B J s e s s i o n w i t h : q a s

    C H A O S > > : q

    C a f e O B J >

    T h e r e m a y b e i r r e c o v e r a b l e c a s e s , w h e n : q ( o r s i m i l a r c o m m a n d s o f o t h e r C o m m o n L i s p s y s t e m s )

    f a i l s t o w o r k . T h e n t r y \ ( c a f e o b j t ) " . T h i s i s a m o r e r o b u s t m e a n s t o r e t u r n t o C a f e O B J . I f , f o r

    g o o d n e s s , y o u a r e u n a b l e t o r e t u r n t o C a f e O B J e v e n t h e n , e x i t G C L ( c o n t r o l - D n o r m a l l y w o r k s ) a n d

    s t a r t f r o m s c r a t c h .

    I f t h e s y s t e m s t i l l w o r k s n e , b u t i f y o u h a p p e n t o h a v e d e s t r o y e d s o m e v i t a l m o d u l e d e n i t i o n s , t r y

    C a f e O B J > r e s e t

    w h i c h r e s t o r e s t h e d e n i t i o n s o f b u i l t - i n m o d u l e s ( C h a p t e r 1 1 ) a n d p r e l u d e s ( S e c t i o n 1 . 2 . 3 ) . T h i s

    c o m m a n d d o e s n o t a e c t o t h e r m o d u l e s . F o r c o m p l e t e c l e a n u p , u s e

    C a f e O B J > f u l l - r e s e t

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

    y o u w i l l l o s e a l l t h e m o d u l e d e n i t i o n s y o u h a v e s u p p l i e d s o f a r . Y o u a r e w a r n e d .

    B u g R e p o r t s T h e s y s t e m i s u n d e r c o n t i n u a l i m p r o v e m e n t . I f y o u d e t e c t a n y b u g s , m a l f u n c t i o n s ,

    o r j u s t i n c o n v e n i e n c e s , d o l e t u s k n o w . T h e s u p p o r t t e a m i s r e a c h a b l e v i a

    c a f e - b u g s @ l d l . j a i s t . a c . j p

    1 . 2 F i l e s a n d L i b r a r i e s

    1 . 2 . 1 R e a d i n g F i l e s

    N o t e v e r y m o d u l e i s a s t r i v i a l a s T E S T , a n d y o u w i l l s o o o o o n n e e d l i b r a r y s y s t e m s f o r s t o r e / r e c o v e r i n g

    m o d u l e d e n i t i o n s , t e s t c a s e s , a n d s o o n . C a f e O B J r e q u i r e s e v e r y i m p o r t e d m o d u l e ( c f . S e c t i o n 2 . 5 )

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

    t h e f o l l o w i n g c o m m a n d .

    1

    E r r o r l o o p s o f C M U , A l l e g r o , a n d M a c L i s p w o r k m o r e o r l e s s s i m i l a r l y .

  • 8/2/2019 Manual CafeObj Ingles Completo

    15/168

    1 4 C H A P T E R 1 . D I A L O G U E W I T H T H E S Y S T E M

    S y n t a x 1 : i n p u t c o m m a n d

    i n p u t p a t h n a m e

    i n p u t ( o r i n f o r s h o r t ) r e q u e s t s t h e s y s t e m t o r e a d t h e l e s p e c i e d b y t h e p a t h n a m e . T h e l e i t s e l f

    m a y c o n t a i n i n p u t c o m m a n d , a n d s o o n , a d n a u s e u m . C a f e O B J r e a d s t h e l e u p t o e o f , o r u n t i l i t

    e n c o u n t e r s a l i n e t h a t o n l y c o n t a i n s ( t h e l i t e r a l ) e o f

    S y n t a x 2 : e o f c o m m a n d

    e o f

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

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

    P a t h n a m e s f o l l o w t h e c o n v e n t i o n s o f t h e U n i x l e s y s t e m . B o t h r e l a t i v e a n d a b s o l u t e p a t h s a r e p o s s i b l e ,

    a n d \ ~ " d e n o t e s y o u r h o m e d i r e c t o r y . I f t h e r e i s n o l e w i t h t h e p a t h n a m e , t h e s y s t e m e x p a n d s t h e

    n a m e w i t h s u x e s \ . m o d " o r \ . b i n " a n d r e - s e a r c h t h e d i r e c t o r y . B y c o n v e n t i o n , a l e s u x e d w i t h

    \ . m o d " i s a s s u m e d t o c o n t a i n d e n i t i o n s a n d c o m m a n d s w r i t t e n i n C a f e O B J , w h i l e \ . b i n " i n d i c a t e s a

    l e c o n t a i n i n g i n t e r n a l c o d e s . N o r m a l l y , y o u s h o u l d p r e p a r e \ . m o d " l e s y o u r s e l f , a n d l e a v e t h e s y s t e m

    t o c r e a t e \ . b i n " l e s ( s e e S e c t i o n 1 . 2 . 2 ) .

    S o m e d i r e c t o r y t r a v e r s a l c o m m a n d s o f U n i x a r e a l s o a v a i l a b l e .

    S y n t a x 3 : c d c o m m a n d

    c d p a t h n a m e

    S y n t a x 4 : p w d c o m m a n d

    p w d

    S y n t a x 5 : l s c o m m a n d

    l s p a t h n a m e

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

    W a r n i n g T h e a b o v e c o m m a n d s a c t l i k e t h e i r n a m e s a k e s i n U n i x s h e l l s , b u t a r e n o t e x a c t l y t h e s a m e .

    T h e a r g u m e n t s t o c d l s a r e n o t o p t i o n a l , b u t n e c e s s a r y . A l s o , t h e s y s t e m d o e s n o t r e c o g n i s e ~ b i m b o

    a s t h e h o m e d i r e c t o r y o f b i m b o

    1 . 2 . 2 S a v i n g a n d R e s t o r i n g

    M o d u l e d e n i t i o n s m a y b e s a v e d i n a n i n t e r n a l f o r m a t , f o r e c i e n t l a t e r r e t r i e v a l . T h e c o m m a n d s

    S y n t a x : s a v e c o m m a n d

    s a v e p a t h n a m e

    S y n t a x 7 : r e s t o r e c o m m a n d

    r e s t o r e p a t h n a m e

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

    a d h e r e t o t h e s y s t e m ' s c o n v e n t i o n , l e n a m e s s h o u l d b e s u x e d w i t h \ . b i n " . I n p l a c e o f r e s t o r e

    c o m m a n d , y o u m a y a l s o u s e i n p u t c o m m a n d ( S e c t i o n 1 . 2 . 1 ) .

    W a r n i n g s a v e s a v e s t h e c o n t e n t s o f p r e l u d e l e s ( s e e S e c t i o n 1 . 2 . 3 ) a s w e l l a s m o d u l e d e n i t i o n s

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

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

    s a v e d l e s .

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

    d u m p l e , b y t h e f o l l o w i n g c o m m a n d .

  • 8/2/2019 Manual CafeObj Ingles Completo

    16/168

    1 . 2 . F I L E S A N D L I B R A R I E S 1 5

    S y n t a x 8 : s a v e - s y s t e m c o m m a n d

    s a v e - s y s t e m p a t h n a m e

    W a r n i n g s a v e - s y s t e m d u m p s t h e i m a g e o f C o m m o n L i s p , s o d o n o t a b u s e t h i s c o m m a n d . A n d d u e

    t o t h e r e s t i c t i o n s o f C o m m o n L i s p s y s t e m s , t h i s c o m m a n d m a y n o t w o r k .

    1 . 2 . 3 I n i t i a l i s a t i o n s a n d O p t i o n s

    R e c a l l ( S e c t i o n 1 . 1 ) t h a t t h e i n i t i a l s y s t e m m e s s a g e c o n t a i n e d

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

    ; L o a d i n g / m n t 1 / l a n g / c a f e o b j - 1 . 4 / p r e l u d e / s t d . b i n .

    I n s t a r t i n g u p , C a f e O B J a u t o l o a d s a s e t o f m o d u l e s , c a l l e d s t a n d a r d p r e l u d e s . T h e y d e n e f r e q u e n t l y

    u s e d d a t a t y p e s a n d h o u s e - k e e p i n g d a t a ( c f . C h a p t e r 1 1 ) .

    Y o u m a y i n i t i a l i s e t h e s y s t e m t o y o u r t a s t e , w i t h o p t i o n s a n d i n i t i a l i s a t i o n l e s . I f a l e n a m e d

    \ . c a f e o b j " i s u n d e r y o u r h o m e d i r e c t o r y , t h e s y s t e m r e a d s t h e l e a s i f y o u t y p e

    C a f e O B J > i n ~ / . c a f e o b j

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

    c o m m a n d , S e c t i o n 1 . 3 . 2 ) .

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

    - q . T h i s o p t i o n p r o h i b i t s r e a d i n g . c a f e o b j

    - p p a t h n a m e . I n s t e a d o f t h e s t a n d a r d p r e l u d e l e , w h i c h i s s e t u p d u r i n g i n s t a l l a t i o n , t h e s y s t e m

    r e a d s t h e g i v e n p a t h n a m e ( w h i c h m u s t b e a l e ) . T h e s u x c o n v e n t i o n i s a p p l i c a b l e h e r e .

    + p p a t h n a m e . T h e s y t s t e m r e a d s t h e g i v e n p a t h n a m e i n a d d i t i o n t o t h e s t a n d a r d p r e l u d e l e .

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

    l o c a t e t h e s p e c i e d l e . ( F o r d e f a u l t s e a r c h p a t h s , s e e S e c t i o n 1 . 2 . 5 . ) A l l t h e p a t h n a m e s m u s t

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

    + l p a t h n a m e - l i s t . P a t h n a m e s a r e a d d e d t o t h e s e a r c h d i r e c t o r y l i s t .

    F o r e x a m p l e ,

    % c a f e o b j + p / u s r / c e r n / p a r t i c l e / m u o n . b i n

    - l / u s r / c e r n / l i b / s t d : / u s r / c e r n / l i b / m u o n : / u s r / h o m e / e v a / c a f e

    m a k e s t h e s y s t e m ( 1 ) r e a d t h e s t a n d a r d p r e l u d e l e , ( 2 ) r e a d m u o n . b i n i n a d d i t i o n , ( 3 ) s e t t h e s e a r c h

    d i r e c t o r i e s a s g i v e n , a n d ( 4 ) r e a d t h e i n i t i a l i s a t i o n l e . c a f e o b j , i f i t e x i s t s .

    Y o u m a y a l s o m a k e t h e s y s t e m r e a d l e s b y g i v i n g t h e m a s a r g u m e n t s . F o r e x a m p l e ,

    % c a f e o b j l e m m a 1 l e m m a 2

    h a s t h e s a m e e e c t s a s t y p i n g

    C a f e O B J > i n p u t l e m m a 1

    . . . m e s s a g e s f r o m t h e s y s t e m . . .

    C a f e O B J > i n p u t l e m m a 2

    . . . m e s s a g e s f r o m t h e s y s t e m . . .

  • 8/2/2019 Manual CafeObj Ingles Completo

    17/168

    1 C H A P T E R 1 . D I A L O G U E W I T H T H E S Y S T E M

    a t t h e b e g i n n i n g o f t h e s e s s i o n .

    N o t e t h a t , e v e n t h o u g h \ - p " o p t i o n s , l e n a m e a r g u m e n t s a n d \ . c a f e o b j " a l l c a u s e t h e s y s t e m t o

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

    w h e t h e r s t a n d a r d o r u s e r - s u p p l i e d , a r e t r e a t e d a s p r e l u d e s . T h i s d i e r e n c e r e v e a l s i t s e l f w h e n , e . g . ,

    r e s e t c o m m a n d ( S e c t i o n 1 . 1 ) i s i n v o k e d .

    F i n a l l y , i f y o u a r e d i s i n c l i n e d t o r e m e m b e r a l l o f t h e a b o v e , j u s t m e m o r i s e t h e h e l p o p t i o n .

    % c a f e o b j - h e l p

    l i s t s t h e a v a i l a b l e o p t i o n s .

    1 . 2 . 4 B a t c h C a f e O B J

    I f y o u d o n o t w a n t t o p a y m u c h a t t e n t i o n t o t h e s y s t e m , y o u m a y r u n t h e s y s t e m n o n - i n t e r a c t i v e l y . A n

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

    T h i s i s u s e f u l i n p r o c e s s i n g a l a r g e l e . F o r e x a m p l e ,

    % c a f e o b j - b a t c h g o l i a t h > c a f e . o u t

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

    a f t e r n o o n t e a .

    1 . 2 . 5 M o d u l e L i b r a r i e s

    A s s u g g e s t e d i n t h e p r e v i o u s s e c t i o n , C a f e O B J m a i n t a i n s a l i s t o f s e a r c h d i r e c t o r i e s . S o m e o f t h e m a r e

    s t a n d a r d . Y o u m a y c h a n g e t h e l i s t b y \ - l " o r \ + l " o p t i o n s , a s e x p l a i n e d i n S e c t i o n 1 . 2 . 3 . Y o u m a y

    a l s o c h a n g e i t d u r i n g t h e s e s s i o n w i t h s e t c o m m a n d ( S e c t i o n 1 . 3 . 2 ) . F o r e x a m p l e ,

    C a f e O B J > s e t l i b p a t h + / u s r / h o m e / m a r i a / c a f e : / u s r / h o m e / t a n i a / c a f e

    a d d s t h e t w o d i r e c t o r i e s t o t h e s e a r c h l i s t , w h i l e

    C a f e O B J > s e t l i b p a t h / u s r / h o m e / m a r i a / c a f e : / u s r / h o m e / t a n i a / c a f e

    r e p l a c e s t h e s e a r c h l i s t b y t h e t w o s o m e . E a c h p a t h n a m e s h o u l d b e s e p a r a t e d b y \ : " , l i k e i n \ - l " a n d

    \ + l " o p t i o n s .

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

    t h e c u r r e n t d i r e c t o r y , t h e n s t a n d a r d l i b r a r y d i r e c t o r i e s . T h e s t a n d a r d l i b r a r y d i r e c t o r i e s a r e x e d a t

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

    / u s r / l o c a l / c a f e o b j - 1 . 4 / l i b

    / u s r / l o c a l / c a f e o b j - 1 . 4 / e x s

    w h i c h a r e s e a r c h e d i n t h i s o r d e r . I f t h e s e a r c h p a t h s a r e m o d i e d , t h e s y t e m s e a r c h e s ( a ) t h e c u r r e n t

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

    o f + o r + l o p t i o n s ) .

    W a r n i n g T h e c u r r e n t d i r e c t o r y h a s a p r i v i l e g e d s t a t u s . I t i s a l w a y s s e a r c h e d r s t , a n d c a n n o t b e

    s u p p r e s s e d b y \ - l " o p t i o n s o r s e t c o m m a n d .

    T o i n s p e c t t h e c u r r e n t s e a r c h p a t h s , t y p e

    C a f e O B J > s h o w s w i t c h l i b p a t h

    ( s e e S e c t i o n 1 . 3 . 3 f o r s h o w c o m m a n d i n g e n e r a l ) .

  • 8/2/2019 Manual CafeObj Ingles Completo

    18/168

    1 . 3 . S O M E H E L P F U L C O M M A N D S 1 7

    1 . 2 . 6 R e q u i r i n g a n d P r o v i d i n g

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

    a g e m e n t .

    S y n t a x 9 : r e q u i r e c o m m a n d

    r e q u i r e f e a t u r e [ p a t h n a m e

    S y n t a x 1 0 : p r o v i d e c o m m a n d

    p r o v i d e f e a t u r e

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

    t h e s y s t e m s e a r c h e s f o r a l e n a m e d t h e f e a t u r e , a n d r e a d t h e l e i f f o u n d . I f a p a t h n a m e i s g i v e n , t h e

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

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

    f e a t u r e a r e a s s u m e d t o h a v e b e e n f u l l l e d a l r e a d y . F o r e x a m p l e , y o u m a y b e a t t h e p o i n t o f r e a d i n g

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

    | l i s t s , b a g s , s e t s , a n d s o o n | i n a s i n g l e l e . S u p p o s e f u r t h e r t h a t , f o r v a r i o u s r e a s o n s , y o u h a v e a

    c o u p l e o f a l t e r n a t i v e d e n i t i o n s o f t h o s e m o d u l e s , s t o r e d i n l e s c o n t a i n e r - 1 . m o d c o n t a i n e r - 2 . m o d

    e t c . T h e n i t i s c o n v e n i e n t t o i n s e r t t h e c o m m a n d

    p r o v i d e c o n t a i n e r

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

    s u p p l i e d .

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

    C a f e O B J > s h o w f e a t u r e s

    ( s e e S e c t i o n 1 . 3 . 3 f o r s h o w c o m m a n d ) .

    T o c o n t i n u e t h e a b o v e e x a m p l e , p r o v i d e d t h e r e i s a l e c o n t a i n e r - 1 . m o d t h a t d e n e s l i s t s , b a g s , e t

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

    C a f e O B J > p r o v i d e n u m b e r s

    C a f e O B J > r e q u i r e c o n t a i n e r c o n t a i n e r - 1

    p r o c e s s i n g i n p u t : . / c o n t a i n e r - 1 . m o d

    - - d e f i n i n g m o d u l e L I S T _ * d o n e .

    - - d e f i n i n g m o d u l e B A G _ * d o n e .

    - - d e f i n i n g m o d u l e S E T _ * d o n e .

    C a f e O B J > r e q u i r e c o n t a i n e r c o n t a i n e r - 1

    C a f e O B J > s h o w f e a t u r e s

    c o n t a i n e r n u m b e r s

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

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

    1 . 3 S o m e H e l p f u l C o m m a n d s

    1 . 3 . 1 H e l p C o m m a n d a n d T o p - l e v e l C o m m a n d s

    H e l p c o m m a n d s o f C a f e O B J i n g e n e r a l e m p l o y \ ? " , i n s t e a d o f \ h e l p " , \ a i d e - m o i " , \ s o c o r r o " , a n d s o

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

  • 8/2/2019 Manual CafeObj Ingles Completo

    19/168

    1 8 C H A P T E R 1 . D I A L O G U E W I T H T H E S Y S T E M

    T y p e ? f o r h e l p

    s a y i n g t h a t t h e t o p m o s t h e l p c o m m a n d i s

    S y n t a x 1 1 : c o m m a n d l i s t i n g c o m m a n d

    \ ? "

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

    - S t a r t i n g m o d u l e d e c l a r a t i o n s . m o d u l e ( S e c t i o n 2 . 1 ) , v i e w ( S e c t i o n 8 . 2 . 3 ) , a n d s o m e o t h e r s i n -

    t r o d u c e b u i l d i n g b l o c k s o f C a f e O B J c o d e s . T h e y a r e t o b e e x p l a i n e d i n d e t a i l , i n t h e r e s t o f t h e

    m a n u a l .

    - C h e c k i n g p r o p e r t i e s o f m o d u l e s . c h e c k ( S e c t i o n 1 0 . 1 ) .

    - M a n a g i n g s y s t e m s . q u i t ( S e c t i o n 1 . 1 ) , s e l e c t ( S e c t i o n 8 . 1 . 1 ) , s e t ( S e c t i o n 1 . 3 . 2 ) , p r o t e c t

    ( S e c t i o n 2 . 1 ) , a n d o t h e r s .

    - M a n a g i n g l e s . i n p u t ( S e c t i o n 1 . 2 . 1 ) , s a v e ( S e c t i o n 1 . 2 . 2 ) , a n d o t h e r s . T h e y s h o u l d b e a l r e a d y

    f a m i l i a r t o y o u .

    - P e e p i n g s y s t e m s . s h o w a n d d e s c r i b e ( S e c t i o n 1 . 3 . 3 ) a r e a t y o u r c o m m a n d .

    - E v a l u a t i n g t e r m s . r e d u c e e x e c u t e , a n d s o m e o t h e r s . P a r t o f s e t c o m m a n d a l s o c o n c e r n s

    e v a l u a t i o n . T h e y a r e a l l e x p l a i n e d i n C h a p t e r .

    - H e l p i n g t h e o r e m p r o v i n g . a p p l y o p e n , e t a l . T h e y s h a l l b e e x p l a i n e d i n C h a p t e r 9 .

    M a n y c o m m a n d s h a v e a b b r e v i a t i o n s . W e l i s t t h e m b e l o w .

    m o d u l e m o d m o d u l e ! m o d !

    m o d u l e * m o d * q u i t q

    s h o w s h d e s c r i b e d e s c

    i n p u t i n r e d u c e r e d

    e x e c u t e e x e c b - r e d u c e b r e d |

    W a r n i n g O t h e r a b b r e v i a t i o n s m a y b e a c c e p t e d b y t h e s y s t e m . B u t u n l e s s e x p l i c i t l y s t a t e d i n t h e

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

    S o m e o f t h e c o m m a n d s t a k e s m a n y d i e r e n t k i n d s o f a r g u m e n t s . I t i s u n l i k e l y f o r y o u t o r e m e m b e r

    a l l . I n s u c h c a s e s , t h e s y s t e m i n t e r p r e t s t h e a r g u m e n t \ ? " a s y o u r d e s p e r a t e c a l l . F o r e x a m p l e ,

    C a f e O B J > s e t ?

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

    1 . 3 . 2 S w i t c h - T o g g l i n g C o m m a n d

    T h e s y s t e m m a i n t a i n s v a r i o u s k i n d o f s w i t c h e s . B y d e n i t i o n a s w i t c h i s t w o - v a l u e d ( o n a n d o f f ) . T h e

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

    S y n t a x 1 2 : s e t c o m m a n d f o r s w i t c h e s

    s e t s w i t c h n a m e f o n j o f f g

    A s e x p l a i n e d i n S e c t i o n 1 . 3 . 1 , y o u g e t a l i s t o f a v a i l a b l e s w i t c h e s b y j u s t t y p i n g

    C a f e O B J > s e t ?

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

  • 8/2/2019 Manual CafeObj Ingles Completo

    20/168

    1 . 3 . S O M E H E L P F U L C O M M A N D S 1 9

    C a f e O B J > s h o w s w i t c h e s

    ( f o r s h o w c o m m a n d , s e e S e c t i o n 1 . 3 . 3 ) .

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

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

    A n o t h e r s u c h s w i t c h i s q u i e t . I f t h i s s w i t c h i s o n , t h e s y s t e m d o e s n o t b o t h e r y o u w i t h m e s s a g e s o t h e r

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

    w i l l b e e x p l a i n e d a s t h e n e e d a r i s e s .

    W a r n i n g A v a i l a b l e s w i t c h e s a r e s u b j e c t t o f r e q u e n t c h a n g e s .

    S o m e a r g u m e n t s t o s e t c o m m a n d a r e n o t s w i t c h e s , a n d m a y r a n g e o v e r m a n y v a l u e s . A n e x a m p l e i s

    l i b p a t h , w h i c h w a s a p p e a r e d i n S e c t i o n 1 . 2 . 5 . T h e g e n e r a l s y n t a x m i g h t b e

    S y n t a x 1 3 : s e t c o m m a n d f o r o t h e r s

    s e t a n a m e [ o p t i o n v a l u e

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

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

    1 . 3 . 3 I n s p e c t i o n C o m m a n d s

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

    m a n y , s o y o u a r e w i s e t o r e m e m b e r t h a t

    C a f e O B J > s h o w ?

    l i s t s t h e m a l l ( c f . S e c t i o n 1 . 3 . 1 ) .

    T h e g e n e r a l s y n t a x i s c o m p l i c a t e d . I t i s b e t t e r u n d e r s t o o d w h e n d i v i d e d i n t o t w o . F o r t h e r s t h a l f ,

    y o u h a v e

    S y n t a x 1 4 : s h o w c o m m a n d f o r m o d u l e i n s p e c t i o n

    s h o w [ m o d u l e e x p r e s s i o n

    s h o w [ a l l f s o r t s j o p s j s i g n j a x i o m s g [ m o d u l e e x p r e s s i o n

    s h o w f v a r s j p a r a m s j s u b s g [ m o d u l e e x p r e s s i o n

    s h o w f s o r t s o r t n a m e g j f o p o p e r a t o r n a m e g [ m o d u l e e x p r e s s i o n

    s h o w f s u b n u m b e r g j f p a r a m p a r a m e t e r n a m e g j f [ a l l r u l e s g [ m o d u l e e x p r e s s i o n

    s h o w v i e w v i e w n a m e

    D o n o t b o t h e r t o m e m o r i s e a l l o f t h e s e f o r n o w | o r e v e r . W e i l l u s t r a t e t h e m a f t e r m o d u l e b u i l d i n g

    c o n s t r u c t s a r e e x p l a i n e d ( c f . C h a p t e r 5 ) . F o r t h e s e c o n d h a l f , y o u h a v e

    S y n t a x 1 5 : s h o w c o m m a n d f o r o t h e r i n s p e c t i o n

    s h o w t r e e j f t e r m [ l e t v a r i a b l e [ t r e e g j f s u b t e r m [ t r e e g

    s h o w [ l e t j s e l e c t i o n j p e n d i n g j c o n t e x t j m o d u l e s j v i e w s j

    t i m e j l i m i t j s t o p j f e a t u r e s j m e m o

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

    A g a i n , d o n o t b o t h e r n o w . M o s t o f t h e s e a r g u m e n t s a r e u n r e l a t e d , a n d w e e x p l a i n t h e s y s t e m ' s r e s p o n s e

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

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

    S y n t a x 1 : d e s c r i b e c o m m a n d

    d e s c r i b e [ m o d u l e e x p r e s s i o n

    d e s c r i b e [ a l l f s o r t s j o p s j s i g n j a x i o m s g [ m o d u l e e x p r e s s i o n

    d e s c r i b e f v a r s j p a r a m s j s u b s g [ m o d u l e e x p r e s s i o n

    d e s c r i b e f s o r t s o r t n a m e g j f o p o p e r a t o r n a m e g [ m o d u l e e x p r e s s i o n

  • 8/2/2019 Manual CafeObj Ingles Completo

    21/168

    2 0 C H A P T E R 1 . D I A L O G U E W I T H T H E S Y S T E M

    W a r n i n g I n u s i n g t h e s y s t e m , y o u m a y n o t i c e t h a t i t t r e a t s s h o w a n d d e s c r i b e i n c o m b i n a t i o n . I n

    f a c t

    C a f e O B J > s h o w ?

    l e t s y o u k n o w t h e s y n t a x o f d e s c r i b e a s w e l l a s s h o w . T r y a l s o

    C a f e O B J > d e s c r i b e ?

  • 8/2/2019 Manual CafeObj Ingles Completo

    22/168

    C h a p t e r 2

    M o d u l e D e c l a r a t i o n

    T h e b a s i c b u i l d i n g b l o c k s o f C a f e O B J a r e m o d u l e s . T h i s c h a p t e r e x p l a i n s t h e o u t e r m o s t s t r u c t u r e o f

    a m o d u l e .

    2 . 1 O v e r a l l S t r u c t u r e

    A m o d u l e w i t h o u t p a r a m e t e r s h a s t h e f o l l o w i n g s y n t a x .

    S y n t a x 1 7 : m o d u l e w i t h o u t p a r a m e t e r s

    m o d u l e m o d u l e n a m e \ f "

    m o d u l e e l e m e n t 3

    \ g "

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

    ( 2 ) s o r t d e c l a r a t i o n ( w i t h o r d e r i n g ) , ( 3 ) o p e r a t o r d e c l a r a t i o n , ( 4 ) r e c o r d d e c l a r a t i o n , ( 5 ) v a r i a b l e

    d e c l a r a t i o n , ( ) e q u a t i o n d e c l a r a t i o n , o r ( 7 ) t r a n s i t i o n d e c l a r a t i o n . I n t h e s u b s e q u e n t c h a p t e r s , w e

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

    A g e n e r a l r u l e a b o u t m o d u l e e l e m e n t s i s t h a t a r e f e r e n t m u s t p r e c e d e i n t h e t e x t u a l o r d e r . F o r e x a m p l e ,

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

    m o d u l e e l e m e n t b e l o n g s t o t h e m o d u l e w h e r e i t a p p e a r s , a n d , u n l e s s i m p o r t e d ( S e c t i o n 2 . 5 ) , i t c a n n o t

    b e r e f e r r e d t o i n o t h e r m o d u l e s .

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

    Y o u c a n n o t r e c o v e r p r e v i o u s d e c l a r a t i o n s . T h e s y s t e m g i v e s a w a r n i n g w h e n a p r e v i o u s d e c l a r a t i o n i s

    d i s c a r d e d .

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

    T h e r e a r e o t h e r s p e c i a l m o d u l e s , n o t s o v i t a l b u t w o r t h a d i l i g e n t p r o t e c t i o n . A n e x a m p l e i s a m o d u l e

    t h a t d e n e s n a t u r a l n u m b e r a r i t h m e t i c , c a l l e d N A T ( c f . C h a p t e r 1 1 ) . Y o u m a y r e m o v e t h e g u a r d f r o m

    t h o s e m o d u l e s , b y t h e c o m m a n d

    S y n t a x 1 8 : u n p r o t e c t c o m m a n d

    u n p r o t e c t m o d u l e n a m e

    F o r t h e r e v e r s e e e c t , y o u m a y u s e

    S y n t a x 1 9 : p r o t e c t c o m m a n d

    p r o t e c t m o d u l e n a m e

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

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

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

    2 1

  • 8/2/2019 Manual CafeObj Ingles Completo

    23/168

    2 2 C H A P T E R 2 . M O D U L E D E C L A R A T I O N

    C a f e O B J > m o d u l e T E S T { }

    - - d e f i n i n g m o d u l e T E S T _ * d o n e .

    C a f e O B J > m o d u l e T E S T { }

    - - d e f i n i n g m o d u l e T E S T

    [ W a r n i n g ] : r e d e f i n i n g m o d u l e T E S T _ * d o n e .

    C a f e O B J > p r o t e c t T E S T

    C a f e O B J > m o d u l e T E S T { }

    - - d e f i n i n g m o d u l e T E S T

    [ E r r o r ] : m o d u l e T E S T i s p r o t e c t e d !

    C a f e O B J > u n p r o t e c t T E S T

    C a f e O B J > m o d u l e T E S T { }

    - - d e f i n i n g m o d u l e T E S T

    [ W a r n i n g ] : r e d e f i n i n g m o d u l e T E S T _ * d o n e .

    C a f e O B J >

    A c c o r d i n g t o t h e s y n t a x o f m o d u l e d e c l a r a t i o n s , e m p t y m o d u l e s a r e a l l o w e d , a s w a s t h e T E S T h e r e .

    Y o u a r e w a r n e d e v e n i f t h e u n p r o t e c t e d T E S T i s o v e r w r i t t e n . O n c e u n d e r p r o t e c t i o n , T E S T c a n n o t b e

    r e d e n e d . S t r i p p e d o f p r o t e c t i o n , i t i s s u b j e c t t o r e d e n i t i o n a g a i n .

    2 . 2 B l o c k s i n a M o d u l e

    M o d u l e e l e m e n t s c a n b e c l a s s i e d i n t h r e e c a t e g o r i e s : ( 1 ) r e f e r e n c e s t o o t h e r m o d u l e s , ( 2 ) s i g n a t u r e

    d e n i t i o n s , a n d ( 3 ) a x i o m s . I t i s p o s s i b l e t o g a t h e r e l e m e n t s i n e a c h c a t e g o r y i n t o b l o c k s . R e f e r e n c e s

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

    S y n t a x 2 0 : i m p o r t s b l o c k

    i m p o r t s \ f " m o d u l e e l e m e n t 3 \ g "

    w h e r e m o d u l e e l e m e n t s a r e r e s t r i c t e d t o i m p o r t d e c l a r a t i o n s ( S e c t i o n 2 . 5 ) . S i m i l a r l y , s i g n a t u r e d e n i -

    t i o n s a n d a x i o m s m a y b e c l u s t e r e d b y

    S y n t a x 2 1 : s i g n a t u r e b l o c k

    s i g n a t u r e \ f " m o d u l e e l e m e n t 3 \ g "

    S y n t a x 2 2 : a x i o m s b l o c k

    a x i o m s \ f " m o d u l e e l e m e n t 3 \ g "

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

    r e c o r d s ( C h a p t e r 3 ) , w h i l e t h o s e i n a n a x i o m s b l o c k a r e r e s t r i c t e d t o d e c l a r a t i o n s o f v a r i a b l e s , e q u a -

    t i o n s , a n d t r a n s i t i o n s ( C h a p t e r 4 ) .

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

    m a y b e a b b r e v i a t e d t o s i g , a n d a x i o m s t o a x s

    T h e s e b l o c k c o n s t r u c t s a r e f o r t h e s a k e o f l e g i b i l i t y , a n d h a v e n o s e m a n t i c c o n n o t a t i o n . F o r e x a m p l e ,

    m o d u l e S I M P L E - N A T {

    s i g n a t u r e {

    [ Z e r o N z N a t < N a t ]

    o p 0 : - > Z e r o

    o p s : N a t - > N z N a t

  • 8/2/2019 Manual CafeObj Ingles Completo

    24/168

    2 . 3 . T I G H T M O D U L E S , L O O S E M O D U L E S 2 3

    o p _ + _ : N a t N a t - > N a t

    }

    a x i o m s {

    v a r s N N ' : N a t

    e q 0 + N = N .

    e q s ( N ) + N ' = s ( N + N ' ) .

    }

    }

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

    m o d u l e S I M P L E - N A T {

    [ Z e r o N z N a t < N a t ]

    o p 0 : - > Z e r o

    o p s : N a t - > N z N a t

    o p _ + _ : N a t N a t - > N a t

    v a r s N N ' : N a t

    e q 0 + N = N .

    e q N + s ( N ' ) = s ( N + N ' ) .

    }

    o r m i n u t e l y b l o c k e d

    m o d u l e S I M P L E - N A T {

    s i g n a t u r e {

    [ Z e r o N z N a t < N a t ]

    }

    s i g n a t u r e {

    o p 0 : - > Z e r o

    o p s : N a t - > N z N a t

    }

    s i g n a t u r e {

    o p _ + _ : N a t N a t - > N a t

    }

    a x i o m s {

    v a r s N N ' : N a t

    }

    a x i o m s {

    e q 0 + N = N .

    e q N + s ( N ' ) = s ( N + N ' ) .

    }

    }

    W a r n i n g I n i n s p e c t i n g m o d u l e s b y s h o w c o m m a n d ( S e c t i o n 1 . 3 . 3 ) , y o u m a y n o t i c e t h a t t h e s y s t e m

    u s e s t h e s e b l o c k c o n s t r u c t s , e v e n i f y o u d i d n o t s u p p l y t h e m ( c f . C h a p t e r 5 ) .

    2 . 3 T i g h t M o d u l e s , L o o s e M o d u l e s

    I n C a f e O B J , a m o d u l e p l a y s t w o d i e r e n t r ^ o l e s , d e p e n d i n g o n w h e r e i t a p p e a r s o r w h a t i t c o n t a i n s .

    I n o n e g u i s e , a m o d u l e d e n o t e s a u n i q u e ( u p t o i s o ) m o d e l ( t i g h t d e n o t a t i o n ) . I n t h e o t h e r , i t d e n o t e s

    a c l a s s o f m o d e l s ( l o o s e d e n o t a t i o n ) . T h e l a t t e r i s t h e c a s e w h e n a m o d u l e i s u s e d a s p a r a m e t e r ( s e e

    S e c t i o n 8 . 2 . 1 ) ; w h e n i t d e n e s b e h a v i o u r a l p r o p e r t i e s ( S e c t i o n 5 . 2 . 4 ) , a n d s o o n . W e d o n o t g o i n t o t h e

    d e t a i l i n t h i s m a n u a l , b u t t h e d i s t i n c t i o n i s v e r y i m p o r t a n t . Y o u s h o u l d c o n s u l t [ 3 ] o r o t h e r t e c h n i c a l

    m a t e r i a l s a t l e a s t o n c e .

  • 8/2/2019 Manual CafeObj Ingles Completo

    25/168

    2 4 C H A P T E R 2 . M O D U L E D E C L A R A T I O N

    S o m e t i m e s i t i s n e c e s s a r y o r c o n v e n i e n t t o r e s t r i c t t h e r ^ o l e o f a m o d u l e . A l t e r n a t i v e m o d u l e d e c l a r a t i o n s

    b e l o w a l l o w y o u t o d o t h a t .

    S y n t a x 2 3 : m o d u l e f o r t i g h t d e n o t a t i o n

    m o d u l e ! m o d u l e n a m e \ f "

    m o d u l e e l e m e n t 3

    \ g "

    S y n t a x 2 4 : m o d u l e f o r l o o s e d e n o t a t i o n

    m o d u l e * m o d u l e n a m e \ f "

    m o d u l e e l e m e n t 3

    \ g "

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

    W h e n a m o d u l e i s d e c l a r e d w i t h \ m o d u l e ! " , i t a l w a y s d e n o t e s a u n i q u e m o d e l . W h e n d e c l a r e d w i t h

    \ m o d u l e * " , i t a l w a y s d e n o t e s a c l a s s o f m o d e l s .

    2 . 4 C o m m e n t

    A c o m m e n t o f C a f e O B J i s o n e o f t h e f o l l o w i n g s .

    a . F r o m \ * * " t o t h e e n d o f l i n e ( e o l ) .

    b . F r o m \ * * > " t o t h e e o l .

    c . F r o m \ - - " t o t h e e o l .

    d . F r o m \ - - > " t o t h e e o l .

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

    A c o m m e n t t h a t s t a r t s w i t h \ * * > " o r \ - - > " i s d i s p l a y e d w h e n i t i s i n p u t t o t h e s y s t e m . T h i s f a c i l i t y

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

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

    * * > i m m e d i a t e l y a b o v e T E S T

    m o d u l e T E S T {

    - - > j u s t e n t e r e d i n t o T E S T

    * * > n o w s o r t d e c l a r a t i o n

    [ E l t ] - - t h i s c o m m e n t s h o u l d b e s u p r e s s e d

    * * > s o r t d e c l a r a t i o n e n d e d

    - - > o p e r a t o r d e c l a r a t i o n s t a r t s

    o p a : - > E l t - - t h i s c o m m e n t s h o u l d b e s u p r e s s e d

    - - > o p e r a t o r d e c l a r a t i o n e n d e d

    * * > f i n i s h i n g T E S T d e c l a r a r t i o n

    }

    - - > f i n i s h e d !

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

    C a f e O B J > i n t e s t

    p r o c e s s i n g i n p u t : . / t e s t . m o d

    * * > i m m e d i a t e l y a b o v e T E S T

    - - d e f i n i n g m o d u l e T E S T

    - - j u s t e n t e r e d i n t o T E S T .

  • 8/2/2019 Manual CafeObj Ingles Completo

    26/168

    2 . 5 . I M P O R T D E C L A R A T I O N 2 5

    * * n o w s o r t d e c l a r a t i o n . .

    * * s o r t d e c l a r a t i o n e n d e d .

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

    - - o p e r a t o r d e c l a r a t i o n e n d e d .

    * * f i n i s h i n g T E S T d e c l a r a r t i o n . _ * d o n e

    - - > f i n i s h e d !

    C a f e O B J >

    A s s h o w n a b o v e , \ > " i s s t r i p p e d w h e n t h e c o m m e n t a p p e a r e d w i t h i n a m o d u l e d e c l a r a t i o n .

    A s a n a s i d e , y o u m a y h a v e n o t i c e d a c o u p l e o f \ " ' s i n t h e s y s t e m m e s s a g e s . T h e s e d o t s i n d i c a t e t h a t

    t h e s y s t e m i s r u n n i n g h a r d . M o r e d o t s m e a n m o r e l a b o u r . \ " a n d \ * " j u s t b e f o r e d o n e w e r e a l s o

    f r o m t h e s y s t e m .

    2 . 5 I m p o r t D e c l a r a t i o n

    A n i m p o r t d e c l a r a t i o n i s [ s i c ] t o i m p o r t d e c l a r a t i o n s f r o m a n o t h e r m o d u l e .

    S y n t a x 2 5 : i m p o r t d e c l a r a t i o n

    f p r o t e c t i n g j e x t e n d i n g j u s i n g g \ ( " m o d u l e e x p r e s s i o n \ ) "

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

    Y o u m a y a b b r e v i a t e t h e m o d e s t o p r e x , a n d u s r e s p e c t i v e l y . A m o d u l e e x p r e s s i o n i s a d e s i g n a t i o n

    o f a m o d u l e , a n d i s e x p l a i n e d l a t e r ( S e c t i o n 8 . 4 ) . F o r t h e c u r r e n t p u r p o s e , i t i s e n o u g h t o k n o w t h a t

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

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

    m o d u l e B A R E - N A T {

    [ N a t ]

    o p 0 : - > N a t

    o p s : N a t - > N a t

    }

    m o d u l e B A R E - N A T - A G A I N {

    p r o t e c t i n g ( B A R E - N A T )

    }

    T h e d e c l a r a t i o n o f B A R E - N A T - A G A I N i s e q u i v a l e n t t o

    m o d u l e B A R E - N A T - A G A I N {

    [ N a t ]

    o p 0 : - > N a t

    o p s : N a t - > N a t

    }

    i . e . i t i s a c o p y , a s a d s h a d o w , o f B A R E - N A T . O n l y t h e n a m e i s c h a n g e d .

    T o e x p l a i n t h e p r e c i s e m e a n i n g o f i m p o r t a t i o n m o d e s , w e h a v e t o d e l v e i n t o a m o d e l - t h e o r e t i c t h e a t r e ,

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

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

    m o d u l e s . I n t u i t i v e l y , w h e n M ' i s i m p o r t e d ,

  • 8/2/2019 Manual CafeObj Ingles Completo

    27/168

    2 C H A P T E R 2 . M O D U L E D E C L A R A T I O N

    p r o t e c t i n g i s t h e s t r o n g e s t c o m m a n d m e n t . T h i s m o d e r e q u i r e s a l l t h e i n t e n d e d m o d e l s o f M '

    b e p r e s e r v e d a s t h e y a r e .

    e x t e n d i n g a l l o w s t h e m o d e l s o f M ' t o b e i n a t e d , b u t d o e s n o t a l l o w t h e m t o b e c o l l a p s e d .

    u s i n g a l l o w s t o t a l d e s t r u c t i o n .

    W a r n i n g T o p r o v e m o d e l - t h e o r e t i c p r o p e r t i e s i s v e r y h a r d , a n d t h e s y s t e m d o e s n o t c h e c k w h e t h e r

    i n d e e d t h e s e r e s t r i c t i o n s a r e o b s e r v e d . I t i s o n t h e u s e r t o c h o o s e c o r r e c t m o d e s .

    A s a s p e c i a l c a s e , a c o u p l e o f b u i l t - i n m o d u l e s a r e i m p l i c i t l y i m p o r t e d w i t h p r o t e c t i n g m o d e . I n

    p a r t i c u l a r , B O O L i s o f p r a c t i c a l i m p o r t a n c e . I t d e n e s B o o l e a n o p e r a t o r s . I t i s i m p o r t e d t o a d m i t

    c o n d i t i o n a l a x i o m s . Y o u m a y p r o h i b i t i m p l i c i t i m p o r t a t i o n b y s e t c o m m a n d , a s

    C a f e O B J > s e t i n c l u d e B O O L o f f

    b u t b e c a r e f u l : B o o l e a n o p e r a t o r s a r e i n d i s p e n s a b l e t o w r i t e c o n d i t i o n a l a x i o m s ( S e c t i o n 4 . 2 . 2 ) , a n d

    a n a t t e m p t t o u s e t h e m w i l l c a u s e e r r o r s i f B O O L i s n o t i m p o r t e d .

    I m p o r t d e c l a r a t i o n s d e n e a m o d u l e h i e r a r c h y . W e s h a l l p r o b e i t l a t e r ( C h a p t e r 8 ) .

  • 8/2/2019 Manual CafeObj Ingles Completo

    28/168

    C h a p t e r 3

    S i g n a t u r e

    A s i g n a t u r e d e c i d e s w h a t i s a n d i s n o t a w e l l - f o r m e d t e r m ( s e e S e c t i o n 3 . 3 . 1 f o r d e t a i l ) . A v e r y b a s i c

    d e n i t i o n w o u l d t e l l y o u t h a t i t c o n s i s t s o f s o r t ( n a m e ) s a n d o p e r a t o r ( s y m b o l ) s p a i r e d w i t h r a n k s . A

    s i g n a t u r e f o r C a f e O B J i s m o r e e l a b o r a t e . A s b r i e y s t a t e d i n t h e i n t r o d u c t o r y c h a p t e r ,

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

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

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

    3 . 1 S o r t D e c l a r a t i o n

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

    C a f e O B J h a s t w o k i n d s o f s o r t s , h e r e a f t e r c a l l e d v i s i b l e s o r t s a n d h i d d e n s o r t s . W e l e a v e i t t o y o u t o

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

    3 . 1 . 1 S o r t D e c l a r a t i o n

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

    S y n t a x 2 : v i s i b l e s o r t d e c l a r a t i o n

    \ [ " l i s t o f s o r t n a m e s \ ] "

    A s o r t n a m e i s a n a r b i t r a r y c h a r a c t e r s e q u e n c e , a n d a l i s t o f s o r t n a m e s i s a l i s t o f s u c h n a m e s s e p a r a t e d

    b y b l a n k s . F o r e x a m p l e ,

    [ N a t ]

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

    [ N a t I n t R a t ]

    d e c l a r e s v i s i b l e s o r t s N a t I n t , a n d R a t . B y r e p l a c i n g \ [ " a n d \ ] " w i t h \ * [ " a n d \ ] * " r e s p e c t i v e l y ,

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

    S y n t a x 2 7 : h i d d e n s o r t d e c l a r a t i o n

    \ * [ " l i s t o f s o r t n a m e s \ ] * "

    2 7

  • 8/2/2019 Manual CafeObj Ingles Completo

    29/168

    2 8 C H A P T E R 3 . S I G N A T U R E

    I n d e c l a r i n g o p e r a t o r s ( S e c t i o n 3 . 2 . 1 ) a n d a x i o m s ( C h a p t e r 4 ) , y o u h a v e t o d i s t i n g u i s h v i s i b l e s o r t s

    a n d h i d d e n s o r t s . T h e y g i v e r i s e t o d i e r e n t k i n d s o f m o d e l s , a n d a r e t o t a l l y d i s j o i n t . S y n t a c t i c a l l y ,

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

    W a r n i n g T h e c u r r e n t i m p l e m e n t a t i o n s i m p l y i g n o r e s d u a l d e c l a r a t i o n s . F o r e x a m p l e , i n t h e p r e s e n c e

    o f a h i d d e n s o r t S , t h e d e c l a r a t i o n

    [ S ]

    i s s i l e n t l y i g n o r e d .

    3 . 1 . 2 S u b s o r t D e c l a r a t i o n

    Y o u m a y d e n e a p a r t i a l o r d e r o v e r s e t s o f s o r t s , w h i c h i s i n t e r p r e t e d a s s e t i n c l u s i o n . S u c h a n o r d e r i s

    d e n o t e d w i t h \

  • 8/2/2019 Manual CafeObj Ingles Completo

    30/168

    3 . 2 . O P E R A T O R D E C L A R A T I O N 2 9

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

    I f N a t I n t a n d R a t h a v e n o t b e e n d e c l a r e d , t h e r e f o r e ,

    [ N a t < I n t < R a t ]

    a n d

    [ N a t I n t R a t , N a t < I n t < R a t ]

    a r e i n t e r p r e t e d i d e n t i c a l l y . B e w a r e , e s p e c i a l l y , o f m i s t y p i n g u p p e r / l o w e r c a s e s . F o r e x a m p l e , i f y o u

    i m p o r t e d a s o r t N a t a n d d e c l a r e d

    [ N A T < I n t ]

    N A T i s r e g a r d e d a s a n e w l y d e c l a r e d s o r t , n o t a n i m p o r t e d o n e .

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

    s y s t e m t o b e h a v e c o r r e c t l y . S u b s o r t r e l a t i o n i s s e t i n c l u s i o n , s o c i r c u l a r r e l a t i o n m e a n s t h a t a l l t h e

    s o r t s i n v o l v e d a r e t h e s a m e . B u t C a f e O B J d o e s n o t r e c o m m e n t s u c h i n d i r e c t \ r e n a m i n g " , a n d m a y

    r e f u s e t o s u p p o r t t h i s i n t e r p r e t a t i o n .

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

    o b v i o u s c a s e s . I f c i r c u l a r i t y i s d e t e c t e d , y o u a r e s e v e r e l y w a r n e d .

    N o t e t h a t i t i s i m p o s s i b l e t o m a k e a v i s i b l e s o r t a s u b s o r t o f a h i d d e n s o r t , o r v i c e v e r s a . Y o u c a n n o t

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