home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: Mailbox/MIME Entity
(archive/mbox).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Newsgroup Content (archive/news)
| magic
| Supported |
100%
| dexvert
| Mailbox/MIME Entity (archive/mbox)
| magic
| Supported |
100%
| dexvert
| Internet Message Format (text/imf)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| news, ASCII text, with CRLF line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| dexmagic
| PrintFox/Pagefox WEAK
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/950 MIME Email (1.0)
| default
| |
100%
| detectItEasy
| Format: Plain text[CRLF]
| default
| |
100%
| xdgMime
| message/news
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 73 65 | 6e 61 74 6f 72 2d 62 65 |Path: se|nator-be|
|00000010| 64 66 65 6c 6c 6f 77 2e | 6d 69 74 2e 65 64 75 21 |dfellow.|mit.edu!|
|00000020| 62 6c 6f 6f 6d 2d 62 65 | 61 63 6f 6e 2e 6d 69 74 |bloom-be|acon.mit|
|00000030| 2e 65 64 75 21 6e 65 77 | 73 2e 6b 65 69 2e 63 6f |.edu!new|s.kei.co|
|00000040| 6d 21 6e 65 77 73 2e 6d | 61 74 68 77 6f 72 6b 73 |m!news.m|athworks|
|00000050| 2e 63 6f 6d 21 74 61 6e | 6b 2e 6e 65 77 73 2e 70 |.com!tan|k.news.p|
|00000060| 69 70 65 78 2e 6e 65 74 | 21 70 69 70 65 78 21 6f |ipex.net|!pipex!o|
|00000070| 6c 65 61 6e 65 21 69 6e | 32 70 33 2e 66 72 21 73 |leane!in|2p3.fr!s|
|00000080| 77 69 64 69 72 2e 73 77 | 69 74 63 68 2e 63 68 21 |widir.sw|itch.ch!|
|00000090| 65 70 66 6c 6e 65 77 73 | 21 64 69 6e 65 77 73 2e |epflnews|!dinews.|
|000000a0| 65 70 66 6c 2e 63 68 21 | 4d 61 67 6e 75 73 2e 4b |epfl.ch!|Magnus.K|
|000000b0| 65 6d 70 65 0d 0a 46 72 | 6f 6d 3a 20 4d 61 67 6e |empe..Fr|om: Magn|
|000000c0| 75 73 2e 4b 65 6d 70 65 | 40 64 69 2e 65 70 66 6c |us.Kempe|@di.epfl|
|000000d0| 2e 63 68 20 28 4d 61 67 | 6e 75 73 20 4b 65 6d 70 |.ch (Mag|nus Kemp|
|000000e0| 65 29 0d 0a 4e 65 77 73 | 67 72 6f 75 70 73 3a 20 |e)..News|groups: |
|000000f0| 63 6f 6d 70 2e 6c 61 6e | 67 2e 61 64 61 2c 63 6f |comp.lan|g.ada,co|
|00000100| 6d 70 2e 61 6e 73 77 65 | 72 73 2c 6e 65 77 73 2e |mp.answe|rs,news.|
|00000110| 61 6e 73 77 65 72 73 0d | 0a 53 75 62 6a 65 63 74 |answers.|.Subject|
|00000120| 3a 20 41 64 61 20 46 41 | 51 3a 20 50 72 6f 67 72 |: Ada FA|Q: Progr|
|00000130| 61 6d 6d 69 6e 67 20 77 | 69 74 68 20 41 64 61 20 |amming w|ith Ada |
|00000140| 28 70 61 72 74 20 32 20 | 6f 66 20 34 29 0d 0a 46 |(part 2 |of 4)..F|
|00000150| 6f 6c 6c 6f 77 75 70 2d | 54 6f 3a 20 70 6f 73 74 |ollowup-|To: post|
|00000160| 65 72 0d 0a 44 61 74 65 | 3a 20 31 37 20 4d 61 72 |er..Date|: 17 Mar|
|00000170| 20 31 39 39 36 20 31 34 | 3a 32 32 3a 32 34 20 47 | 1996 14|:22:24 G|
|00000180| 4d 54 0d 0a 4f 72 67 61 | 6e 69 7a 61 74 69 6f 6e |MT..Orga|nization|
|00000190| 3a 20 4e 6f 6e 65 0d 0a | 4c 69 6e 65 73 3a 20 36 |: None..|Lines: 6|
|000001a0| 34 32 0d 0a 53 65 6e 64 | 65 72 3a 20 6d 61 67 6e |42..Send|er: magn|
|000001b0| 75 73 40 6c 67 6c 73 75 | 6e 34 2e 65 70 66 6c 2e |us@lglsu|n4.epfl.|
|000001c0| 63 68 20 28 4d 61 67 6e | 75 73 20 4b 65 6d 70 65 |ch (Magn|us Kempe|
|000001d0| 29 0d 0a 41 70 70 72 6f | 76 65 64 3a 20 6e 65 77 |)..Appro|ved: new|
|000001e0| 73 2d 61 6e 73 77 65 72 | 73 2d 72 65 71 75 65 73 |s-answer|s-reques|
|000001f0| 74 40 4d 49 54 2e 45 44 | 55 0d 0a 44 69 73 74 72 |t@MIT.ED|U..Distr|
|00000200| 69 62 75 74 69 6f 6e 3a | 20 77 6f 72 6c 64 0d 0a |ibution:| world..|
|00000210| 4d 65 73 73 61 67 65 2d | 49 44 3a 20 3c 34 69 68 |Message-|ID: <4ih|
|00000220| 37 37 30 24 66 71 32 40 | 64 69 73 75 6e 6d 73 2e |770$fq2@|disunms.|
|00000230| 65 70 66 6c 2e 63 68 3e | 0d 0a 52 65 70 6c 79 2d |epfl.ch>|..Reply-|
|00000240| 54 6f 3a 20 4d 61 67 6e | 75 73 2e 4b 65 6d 70 65 |To: Magn|us.Kempe|
|00000250| 40 64 69 2e 65 70 66 6c | 2e 63 68 20 28 4d 61 67 |@di.epfl|.ch (Mag|
|00000260| 6e 75 73 20 4b 65 6d 70 | 65 29 0d 0a 4e 4e 54 50 |nus Kemp|e)..NNTP|
|00000270| 2d 50 6f 73 74 69 6e 67 | 2d 48 6f 73 74 3a 20 6c |-Posting|-Host: l|
|00000280| 67 6c 73 75 6e 34 2e 65 | 70 66 6c 2e 63 68 0d 0a |glsun4.e|pfl.ch..|
|00000290| 4d 69 6d 65 2d 56 65 72 | 73 69 6f 6e 3a 20 31 2e |Mime-Ver|sion: 1.|
|000002a0| 30 0d 0a 43 6f 6e 74 65 | 6e 74 2d 54 79 70 65 3a |0..Conte|nt-Type:|
|000002b0| 20 74 65 78 74 2f 70 6c | 61 69 6e 3b 20 63 68 61 | text/pl|ain; cha|
|000002c0| 72 73 65 74 3d 69 73 6f | 2d 38 38 35 39 2d 31 0d |rset=iso|-8859-1.|
|000002d0| 0a 43 6f 6e 74 65 6e 74 | 2d 54 72 61 6e 73 66 65 |.Content|-Transfe|
|000002e0| 72 2d 45 6e 63 6f 64 69 | 6e 67 3a 20 38 62 69 74 |r-Encodi|ng: 8bit|
|000002f0| 0d 0a 53 75 6d 6d 61 72 | 79 3a 20 41 64 61 20 50 |..Summar|y: Ada P|
|00000300| 72 6f 67 72 61 6d 6d 65 | 72 27 73 20 46 72 65 71 |rogramme|r's Freq|
|00000310| 75 65 6e 74 6c 79 20 41 | 73 6b 65 64 20 51 75 65 |uently A|sked Que|
|00000320| 73 74 69 6f 6e 73 20 28 | 61 6e 64 20 61 6e 73 77 |stions (|and answ|
|00000330| 65 72 73 29 2c 0d 0a 20 | 20 20 20 20 20 20 20 20 |ers),.. | |
|00000340| 20 20 70 61 72 74 20 32 | 20 6f 66 20 34 2e 0d 0a | part 2| of 4...|
|00000350| 20 20 20 20 20 20 20 20 | 20 50 6c 65 61 73 65 20 | | Please |
|00000360| 72 65 61 64 20 62 65 66 | 6f 72 65 20 70 6f 73 74 |read bef|ore post|
|00000370| 69 6e 67 2e 0d 0a 4b 65 | 79 77 6f 72 64 73 3a 20 |ing...Ke|ywords: |
|00000380| 61 64 76 61 6e 63 65 64 | 20 6c 61 6e 67 75 61 67 |advanced| languag|
|00000390| 65 2c 20 61 72 74 69 66 | 69 63 69 61 6c 20 6c 61 |e, artif|icial la|
|000003a0| 6e 67 75 61 67 65 73 2c | 20 63 6f 6d 70 75 74 65 |nguages,| compute|
|000003b0| 72 20 73 6f 66 74 77 61 | 72 65 2c 0d 0a 20 20 20 |r softwa|re,.. |
|000003c0| 20 20 20 20 20 20 20 64 | 61 74 61 20 70 72 6f 63 | d|ata proc|
|000003d0| 65 73 73 69 6e 67 2c 20 | 70 72 6f 67 72 61 6d 6d |essing, |programm|
|000003e0| 69 6e 67 20 6c 61 6e 67 | 75 61 67 65 73 2c 20 41 |ing lang|uages, A|
|000003f0| 64 61 0d 0a 58 72 65 66 | 3a 20 73 65 6e 61 74 6f |da..Xref|: senato|
|00000400| 72 2d 62 65 64 66 65 6c | 6c 6f 77 2e 6d 69 74 2e |r-bedfel|low.mit.|
|00000410| 65 64 75 20 63 6f 6d 70 | 2e 6c 61 6e 67 2e 61 64 |edu comp|.lang.ad|
|00000420| 61 3a 34 32 34 37 36 20 | 63 6f 6d 70 2e 61 6e 73 |a:42476 |comp.ans|
|00000430| 77 65 72 73 3a 31 37 36 | 31 33 20 6e 65 77 73 2e |wers:176|13 news.|
|00000440| 61 6e 73 77 65 72 73 3a | 36 37 31 37 37 0d 0a 0d |answers:|67177...|
|00000450| 0a 41 72 63 68 69 76 65 | 2d 6e 61 6d 65 3a 20 63 |.Archive|-name: c|
|00000460| 6f 6d 70 75 74 65 72 2d | 6c 61 6e 67 2f 41 64 61 |omputer-|lang/Ada|
|00000470| 2f 70 72 6f 67 72 61 6d | 6d 69 6e 67 2f 70 61 72 |/program|ming/par|
|00000480| 74 32 0d 0a 43 6f 6d 70 | 2d 6c 61 6e 67 2d 61 64 |t2..Comp|-lang-ad|
|00000490| 61 2d 61 72 63 68 69 76 | 65 2d 6e 61 6d 65 3a 20 |a-archiv|e-name: |
|000004a0| 70 72 6f 67 72 61 6d 6d | 69 6e 67 2f 70 61 72 74 |programm|ing/part|
|000004b0| 32 0d 0a 50 6f 73 74 69 | 6e 67 2d 46 72 65 71 75 |2..Posti|ng-Frequ|
|000004c0| 65 6e 63 79 3a 20 6d 6f | 6e 74 68 6c 79 0d 0a 4c |ency: mo|nthly..L|
|000004d0| 61 73 74 2d 6d 6f 64 69 | 66 69 65 64 3a 20 32 38 |ast-modi|fied: 28|
|000004e0| 20 46 65 62 72 75 61 72 | 79 20 31 39 39 36 0d 0a | Februar|y 1996..|
|000004f0| 4c 61 73 74 2d 70 6f 73 | 74 65 64 3a 20 32 36 20 |Last-pos|ted: 26 |
|00000500| 4a 61 6e 75 61 72 79 20 | 31 39 39 36 0d 0a 0d 0a |January |1996....|
|00000510| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000520| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 41 | | A|
|00000530| 64 61 20 50 72 6f 67 72 | 61 6d 6d 65 72 27 73 0d |da Progr|ammer's.|
|00000540| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00000550| 20 20 20 20 20 20 20 20 | 46 72 65 71 75 65 6e 74 | |Frequent|
|00000560| 6c 79 20 41 73 6b 65 64 | 20 51 75 65 73 74 69 6f |ly Asked| Questio|
|00000570| 6e 73 20 28 46 41 51 29 | 0d 0a 0d 0a 20 20 20 49 |ns (FAQ)|.... I|
|00000580| 4d 50 4f 52 54 41 4e 54 | 20 4e 4f 54 45 3a 20 4e |MPORTANT| NOTE: N|
|00000590| 6f 20 46 41 51 20 63 61 | 6e 20 73 75 62 73 74 69 |o FAQ ca|n substi|
|000005a0| 74 75 74 65 20 66 6f 72 | 20 72 65 61 6c 20 74 65 |tute for| real te|
|000005b0| 61 63 68 69 6e 67 20 61 | 6e 64 0d 0a 20 20 20 64 |aching a|nd.. d|
|000005c0| 6f 63 75 6d 65 6e 74 61 | 74 69 6f 6e 2e 20 54 68 |ocumenta|tion. Th|
|000005d0| 65 72 65 20 69 73 20 61 | 6e 20 61 6e 6e 6f 74 61 |ere is a|n annota|
|000005e0| 74 65 64 20 6c 69 73 74 | 20 6f 66 20 41 64 61 20 |ted list| of Ada |
|000005f0| 62 6f 6f 6b 73 20 69 6e | 20 74 68 65 0d 0a 20 20 |books in| the.. |
|00000600| 20 63 6f 6d 70 61 6e 69 | 6f 6e 20 63 6f 6d 70 2e | compani|on comp.|
|00000610| 6c 61 6e 67 2e 61 64 61 | 20 46 41 51 2e 0d 0a 0d |lang.ada| FAQ....|
|00000620| 0a 54 68 69 73 20 69 73 | 20 70 61 72 74 20 32 20 |.This is| part 2 |
|00000630| 6f 66 20 61 20 34 2d 70 | 61 72 74 20 70 6f 73 74 |of a 4-p|art post|
|00000640| 69 6e 67 2e 0d 0a 50 61 | 72 74 20 33 20 62 65 67 |ing...Pa|rt 3 beg|
|00000650| 69 6e 73 20 77 69 74 68 | 20 71 75 65 73 74 69 6f |ins with| questio|
|00000660| 6e 20 36 2e 0d 0a 50 61 | 72 74 20 34 20 62 65 67 |n 6...Pa|rt 4 beg|
|00000670| 69 6e 73 20 77 69 74 68 | 20 71 75 65 73 74 69 6f |ins with| questio|
|00000680| 6e 20 39 2e 0d 0a 50 61 | 72 74 73 20 33 20 61 6e |n 9...Pa|rts 3 an|
|00000690| 64 20 34 20 73 68 6f 75 | 6c 64 20 62 65 20 74 68 |d 4 shou|ld be th|
|000006a0| 65 20 6e 65 78 74 20 70 | 6f 73 74 69 6e 67 73 20 |e next p|ostings |
|000006b0| 69 6e 20 74 68 69 73 20 | 74 68 72 65 61 64 2e 0d |in this |thread..|
|000006c0| 0a 50 61 72 74 20 31 20 | 73 68 6f 75 6c 64 20 62 |.Part 1 |should b|
|000006d0| 65 20 74 68 65 20 70 72 | 65 76 69 6f 75 73 20 70 |e the pr|evious p|
|000006e0| 6f 73 74 69 6e 67 20 69 | 6e 20 74 68 69 73 20 74 |osting i|n this t|
|000006f0| 68 72 65 61 64 2e 0d 0a | 0d 0a 20 20 20 20 52 65 |hread...|.. Re|
|00000700| 63 65 6e 74 20 63 68 61 | 6e 67 65 73 20 74 6f 20 |cent cha|nges to |
|00000710| 74 68 69 73 20 46 41 51 | 20 61 72 65 20 6c 69 73 |this FAQ| are lis|
|00000720| 74 65 64 20 69 6e 20 74 | 68 65 20 66 69 72 73 74 |ted in t|he first|
|00000730| 20 73 65 63 74 69 6f 6e | 20 61 66 74 65 72 20 74 | section| after t|
|00000740| 68 65 20 74 61 62 6c 65 | 0d 0a 20 20 20 20 6f 66 |he table|.. of|
|00000750| 20 63 6f 6e 74 65 6e 74 | 73 20 28 69 6e 20 70 61 | content|s (in pa|
|00000760| 72 74 20 31 29 2e 20 54 | 68 69 73 20 64 6f 63 75 |rt 1). T|his docu|
|00000770| 6d 65 6e 74 20 69 73 20 | 75 6e 64 65 72 20 65 78 |ment is |under ex|
|00000780| 70 6c 69 63 69 74 20 63 | 6f 70 79 72 69 67 68 74 |plicit c|opyright|
|00000790| 2e 0d 0a 0d 0a 0d 0a 35 | 3a 20 4f 62 6a 65 63 74 |.......5|: Object|
|000007a0| 2d 4f 72 69 65 6e 74 65 | 64 20 50 72 6f 67 72 61 |-Oriente|d Progra|
|000007b0| 6d 6d 69 6e 67 20 77 69 | 74 68 20 41 64 61 0d 0a |mming wi|th Ada..|
|000007c0| 0d 0a 0d 0a 35 2e 31 3a | 20 57 68 79 20 64 6f 65 |....5.1:| Why doe|
|000007d0| 73 20 41 64 61 20 68 61 | 76 65 20 22 74 61 67 67 |s Ada ha|ve "tagg|
|000007e0| 65 64 20 74 79 70 65 73 | 22 20 69 6e 73 74 65 61 |ed types|" instea|
|000007f0| 64 20 6f 66 20 63 6c 61 | 73 73 65 73 3f 0d 0a 0d |d of cla|sses?...|
|00000800| 0a 20 20 20 28 54 75 63 | 6b 65 72 20 54 61 66 74 |. (Tuc|ker Taft|
|00000810| 20 72 65 73 70 6f 6e 64 | 73 29 3a 0d 0a 0d 0a 20 | respond|s):.... |
|00000820| 20 20 53 6f 6d 65 6f 6e | 65 20 72 65 63 65 6e 74 | Someon|e recent|
|00000830| 6c 79 20 61 73 6b 65 64 | 20 6d 65 20 74 6f 20 65 |ly asked| me to e|
|00000840| 78 70 6c 61 69 6e 20 74 | 68 65 20 64 69 66 66 65 |xplain t|he diffe|
|00000850| 72 65 6e 63 65 20 62 65 | 74 77 65 65 6e 20 74 68 |rence be|tween th|
|00000860| 65 0d 0a 20 20 20 6d 65 | 61 6e 69 6e 67 20 6f 66 |e.. me|aning of|
|00000870| 20 74 68 65 20 74 65 72 | 6d 20 22 63 6c 61 73 73 | the ter|m "class|
|00000880| 22 20 69 6e 20 43 2b 2b | 20 61 6e 64 20 69 74 73 |" in C++| and its|
|00000890| 20 6d 65 61 6e 69 6e 67 | 20 69 6e 20 41 64 61 20 | meaning| in Ada |
|000008a0| 39 58 2e 20 48 65 72 65 | 20 69 73 0d 0a 20 20 20 |9X. Here| is.. |
|000008b0| 61 20 73 79 6e 6f 70 73 | 69 73 20 6f 66 20 74 68 |a synops|is of th|
|000008c0| 65 20 61 6e 73 77 65 72 | 3a 0d 0a 0d 0a 20 20 20 |e answer|:.... |
|000008d0| 49 6e 20 43 2b 2b 2c 20 | 74 68 65 20 74 65 72 6d |In C++, |the term|
|000008e0| 20 22 63 6c 61 73 73 22 | 20 72 65 66 65 72 73 20 | "class"| refers |
|000008f0| 74 6f 20 74 68 72 65 65 | 20 64 69 66 66 65 72 65 |to three| differe|
|00000900| 6e 74 2c 20 62 75 74 20 | 72 65 6c 61 74 65 64 0d |nt, but |related.|
|00000910| 0a 20 20 20 74 68 69 6e | 67 73 3a 0d 0a 20 20 20 |. thin|gs:.. |
|00000920| 20 20 2a 20 61 20 6c 61 | 6e 67 75 61 67 65 20 63 | * a la|nguage c|
|00000930| 6f 6e 73 74 72 75 63 74 | 2c 20 74 68 61 74 20 65 |onstruct|, that e|
|00000940| 6e 63 61 70 73 75 6c 61 | 74 65 73 20 74 68 65 20 |ncapsula|tes the |
|00000950| 64 65 66 69 6e 69 74 69 | 6f 6e 73 20 6f 66 20 64 |definiti|ons of d|
|00000960| 61 74 61 0d 0a 20 20 20 | 20 20 20 20 6d 65 6d 62 |ata.. | memb|
|00000970| 65 72 73 2c 20 6d 65 6d | 62 65 72 20 66 75 6e 63 |ers, mem|ber func|
|00000980| 74 69 6f 6e 73 2c 20 6e | 65 73 74 65 64 20 74 79 |tions, n|ested ty|
|00000990| 70 65 73 2c 20 65 74 63 | 2e 3b 0d 0a 0d 0a 20 20 |pes, etc|.;.... |
|000009a0| 20 20 20 2a 20 61 20 70 | 61 72 74 69 63 75 6c 61 | * a p|articula|
|000009b0| 72 20 6b 69 6e 64 20 6f | 66 20 74 79 70 65 2c 20 |r kind o|f type, |
|000009c0| 64 65 66 69 6e 65 64 20 | 62 79 20 61 20 63 6c 61 |defined |by a cla|
|000009d0| 73 73 20 63 6f 6e 73 74 | 72 75 63 74 20 28 6f 72 |ss const|ruct (or|
|000009e0| 20 62 79 0d 0a 20 20 20 | 20 20 20 20 22 73 74 72 | by.. | "str|
|000009f0| 75 63 74 22 20 77 68 69 | 63 68 20 69 73 20 61 20 |uct" whi|ch is a |
|00000a00| 73 70 65 63 69 61 6c 20 | 63 61 73 65 20 6f 66 20 |special |case of |
|00000a10| 22 63 6c 61 73 73 22 29 | 3b 0d 0a 0d 0a 20 20 20 |"class")|;.... |
|00000a20| 20 20 2a 20 61 20 73 65 | 74 20 6f 66 20 74 79 70 | * a se|t of typ|
|00000a30| 65 73 20 63 6f 6e 73 69 | 73 74 69 6e 67 20 6f 66 |es consi|sting of|
|00000a40| 20 61 20 74 79 70 65 20 | 61 6e 64 20 61 6c 6c 20 | a type |and all |
|00000a50| 6f 66 20 69 74 73 20 64 | 65 72 69 76 61 74 69 76 |of its d|erivativ|
|00000a60| 65 73 2c 0d 0a 20 20 20 | 20 20 20 20 64 69 72 65 |es,.. | dire|
|00000a70| 63 74 20 61 6e 64 20 69 | 6e 64 69 72 65 63 74 2e |ct and i|ndirect.|
|00000a80| 0d 0a 0d 0a 0d 0a 20 20 | 20 49 6e 20 41 64 61 20 |...... | In Ada |
|00000a90| 39 58 2c 20 74 68 65 20 | 74 65 72 6d 20 22 63 6c |9X, the |term "cl|
|00000aa0| 61 73 73 22 20 72 65 66 | 65 72 73 20 6f 6e 6c 79 |ass" ref|ers only|
|00000ab0| 20 74 6f 20 74 68 65 20 | 74 68 69 72 64 20 6f 66 | to the |third of|
|00000ac0| 20 74 68 65 20 61 62 6f | 76 65 0d 0a 20 20 20 64 | the abo|ve.. d|
|00000ad0| 65 66 69 6e 69 74 69 6f | 6e 73 2e 20 41 64 61 20 |efinitio|ns. Ada |
|00000ae0| 39 58 20 28 61 6e 64 20 | 41 64 61 20 38 33 29 20 |9X (and |Ada 83) |
|00000af0| 68 61 73 20 74 68 72 65 | 65 20 64 69 66 66 65 72 |has thre|e differ|
|00000b00| 65 6e 74 20 74 65 72 6d | 73 20 66 6f 72 20 74 68 |ent term|s for th|
|00000b10| 65 0d 0a 20 20 20 63 6f | 6e 63 65 70 74 73 20 63 |e.. co|ncepts c|
|00000b20| 6f 72 72 65 73 70 6f 6e | 64 69 6e 67 20 74 6f 20 |orrespon|ding to |
|00000b30| 74 68 65 20 61 62 6f 76 | 65 20 74 68 72 65 65 20 |the abov|e three |
|00000b40| 74 68 69 6e 67 73 3a 0d | 0a 20 20 20 20 20 2a 20 |things:.|. * |
|00000b50| 61 20 22 70 61 63 6b 61 | 67 65 22 20 65 6e 63 61 |a "packa|ge" enca|
|00000b60| 70 73 75 6c 61 74 65 73 | 20 74 68 65 20 64 65 66 |psulates| the def|
|00000b70| 69 6e 69 74 69 6f 6e 73 | 20 6f 66 20 74 79 70 65 |initions| of type|
|00000b80| 73 2c 20 6f 62 6a 65 63 | 74 73 2c 0d 0a 20 20 20 |s, objec|ts,.. |
|00000b90| 20 20 20 20 6f 70 65 72 | 61 74 69 6f 6e 73 2c 20 | oper|ations, |
|00000ba0| 65 78 63 65 70 74 69 6f | 6e 73 2c 20 65 74 63 20 |exceptio|ns, etc |
|00000bb0| 77 68 69 63 68 20 61 72 | 65 20 6c 6f 67 69 63 61 |which ar|e logica|
|00000bc0| 6c 6c 79 20 72 65 6c 61 | 74 65 64 2e 20 28 54 68 |lly rela|ted. (Th|
|00000bd0| 65 0d 0a 20 20 20 20 20 | 20 20 6f 70 65 72 61 74 |e.. | operat|
|00000be0| 69 6f 6e 73 20 6f 66 20 | 61 20 74 79 70 65 20 64 |ions of |a type d|
|00000bf0| 65 66 69 6e 65 64 20 69 | 6d 6d 65 64 69 61 74 65 |efined i|mmediate|
|00000c00| 6c 79 20 77 69 74 68 69 | 6e 20 74 68 65 20 70 61 |ly withi|n the pa|
|00000c10| 63 6b 61 67 65 20 77 68 | 65 72 65 0d 0a 20 20 20 |ckage wh|ere.. |
|00000c20| 20 20 20 20 74 68 65 20 | 74 79 70 65 20 69 73 20 | the |type is |
|00000c30| 64 65 63 6c 61 72 65 64 | 20 61 72 65 20 63 61 6c |declared| are cal|
|00000c40| 6c 65 64 2c 20 69 6e 20 | 39 58 2c 20 74 68 65 20 |led, in |9X, the |
|00000c50| 22 70 72 69 6d 69 74 69 | 76 65 20 6f 70 65 72 61 |"primiti|ve opera|
|00000c60| 74 69 6f 6e 73 22 0d 0a | 20 20 20 20 20 20 20 6f |tions"..| o|
|00000c70| 66 20 74 68 65 20 74 79 | 70 65 2c 20 61 6e 64 20 |f the ty|pe, and |
|00000c80| 69 6e 20 73 6f 6d 65 20 | 73 65 6e 73 65 2c 20 64 |in some |sense, d|
|00000c90| 65 66 69 6e 65 20 74 68 | 65 20 22 70 72 69 6d 69 |efine th|e "primi|
|00000ca0| 74 69 76 65 22 20 73 65 | 6d 61 6e 74 69 63 73 0d |tive" se|mantics.|
|00000cb0| 0a 20 20 20 20 20 20 20 | 6f 66 20 74 68 65 20 74 |. |of the t|
|00000cc0| 79 70 65 2c 20 65 73 70 | 65 63 69 61 6c 6c 79 20 |ype, esp|ecially |
|00000cd0| 69 66 20 69 74 20 69 73 | 20 61 20 70 72 69 76 61 |if it is| a priva|
|00000ce0| 74 65 20 74 79 70 65 2e | 29 0d 0a 0d 0a 20 20 20 |te type.|).... |
|00000cf0| 20 20 2a 20 61 20 22 74 | 79 70 65 22 20 69 73 20 | * a "t|ype" is |
|00000d00| 63 68 61 72 61 63 74 65 | 72 69 7a 65 64 20 62 79 |characte|rized by|
|00000d10| 20 61 20 73 65 74 20 6f | 66 20 76 61 6c 75 65 73 | a set o|f values|
|00000d20| 20 61 6e 64 20 61 20 73 | 65 74 20 6f 66 0d 0a 20 | and a s|et of.. |
|00000d30| 20 20 20 20 20 20 70 72 | 69 6d 69 74 69 76 65 20 | pr|imitive |
|00000d40| 6f 70 65 72 61 74 69 6f | 6e 73 20 28 74 68 65 72 |operatio|ns (ther|
|00000d50| 65 20 61 72 65 20 61 20 | 6d 69 6c 6c 69 6f 6e 20 |e are a |million |
|00000d60| 64 65 66 69 6e 69 74 69 | 6f 6e 73 20 6f 66 20 22 |definiti|ons of "|
|00000d70| 74 79 70 65 2c 22 0d 0a | 20 20 20 20 20 20 20 75 |type,"..| u|
|00000d80| 6e 66 6f 72 74 75 6e 61 | 74 65 6c 79 2c 20 62 75 |nfortuna|tely, bu|
|00000d90| 74 20 79 6f 75 20 6b 6e | 6f 77 20 77 68 61 74 20 |t you kn|ow what |
|00000da0| 49 20 6d 65 61 6e 2e 2e | 2e 29 3b 0d 0a 0d 0a 20 |I mean..|.);.... |
|00000db0| 20 20 20 20 2a 20 61 20 | 22 63 6c 61 73 73 22 20 | * a |"class" |
|00000dc0| 69 73 20 61 20 73 65 74 | 20 6f 66 20 74 79 70 65 |is a set| of type|
|00000dd0| 73 20 77 69 74 68 20 73 | 69 6d 69 6c 61 72 20 76 |s with s|imilar v|
|00000de0| 61 6c 75 65 73 20 61 6e | 64 20 6f 70 65 72 61 74 |alues an|d operat|
|00000df0| 69 6f 6e 73 3b 20 69 6e | 0d 0a 20 20 20 20 20 20 |ions; in|.. |
|00000e00| 20 70 61 72 74 69 63 75 | 6c 61 72 2c 20 61 20 74 | particu|lar, a t|
|00000e10| 79 70 65 20 61 6e 64 20 | 61 6e 64 20 61 6c 6c 20 |ype and |and all |
|00000e20| 6f 66 20 69 74 73 20 64 | 65 72 69 76 61 74 69 76 |of its d|erivativ|
|00000e30| 65 73 2c 20 64 69 72 65 | 63 74 20 61 6e 64 0d 0a |es, dire|ct and..|
|00000e40| 20 20 20 20 20 20 20 69 | 6e 64 69 72 65 63 74 2c | i|ndirect,|
|00000e50| 20 72 65 70 72 65 73 65 | 6e 74 73 20 61 20 28 64 | represe|nts a (d|
|00000e60| 65 72 69 76 61 74 69 6f | 6e 29 20 63 6c 61 73 73 |erivatio|n) class|
|00000e70| 2e 20 41 6c 73 6f 2c 20 | 74 68 65 20 73 65 74 20 |. Also, |the set |
|00000e80| 6f 66 0d 0a 20 20 20 20 | 20 20 20 69 6e 74 65 67 |of.. | integ|
|00000e90| 65 72 20 74 79 70 65 73 | 20 66 6f 72 6d 20 74 68 |er types| form th|
|00000ea0| 65 20 69 6e 74 65 67 65 | 72 20 22 63 6c 61 73 73 |e intege|r "class|
|00000eb0| 2c 22 20 61 6e 64 20 73 | 6f 20 6f 6e 20 66 6f 72 |," and s|o on for|
|00000ec0| 20 74 68 65 20 6f 74 68 | 65 72 0d 0a 20 20 20 20 | the oth|er.. |
|00000ed0| 20 20 20 6c 61 6e 67 75 | 61 67 65 2d 64 65 66 69 | langu|age-defi|
|00000ee0| 6e 65 64 20 63 6c 61 73 | 73 65 73 20 6f 66 20 74 |ned clas|ses of t|
|00000ef0| 79 70 65 73 20 69 6e 20 | 74 68 65 20 6c 61 6e 67 |ypes in |the lang|
|00000f00| 75 61 67 65 2e 0d 0a 0d | 0a 0d 0a 20 20 20 53 6f |uage....|... So|
|00000f10| 6d 65 20 4f 4f 50 20 6c | 61 6e 67 75 61 67 65 73 |me OOP l|anguages|
|00000f20| 20 74 61 6b 65 20 61 6e | 20 69 6e 74 65 72 6d 65 | take an| interme|
|00000f30| 64 69 61 72 79 20 70 6f | 73 69 74 69 6f 6e 2e 20 |diary po|sition. |
|00000f40| 49 6e 20 43 4c 4f 53 2c | 20 61 20 22 63 6c 61 73 |In CLOS,| a "clas|
|00000f50| 73 22 0d 0a 20 20 20 69 | 73 20 6e 6f 74 20 61 6e |s".. i|s not an|
|00000f60| 20 65 6e 63 61 70 73 75 | 6c 61 74 69 6e 67 20 63 | encapsu|lating c|
|00000f70| 6f 6e 73 74 72 75 63 74 | 20 28 43 4c 4f 53 20 68 |onstruct| (CLOS h|
|00000f80| 61 73 20 22 70 61 63 6b | 61 67 65 73 22 29 2e 20 |as "pack|ages"). |
|00000f90| 48 6f 77 65 76 65 72 2c | 20 61 0d 0a 20 20 20 22 |However,| a.. "|
|00000fa0| 63 6c 61 73 73 22 20 69 | 73 20 62 6f 74 68 20 61 |class" i|s both a|
|00000fb0| 20 74 79 70 65 20 61 6e | 64 20 61 20 73 65 74 20 | type an|d a set |
|00000fc0| 6f 66 20 74 79 70 65 73 | 2c 20 64 65 70 65 6e 64 |of types|, depend|
|00000fd0| 69 6e 67 20 6f 6e 20 63 | 6f 6e 74 65 78 74 2e 0d |ing on c|ontext..|
|00000fe0| 0a 20 20 20 28 4d 65 74 | 68 6f 64 73 20 22 66 6c |. (Met|hods "fl|
|00000ff0| 6f 61 74 22 20 66 72 65 | 65 6c 79 2e 29 0d 0a 0d |oat" fre|ely.)...|
|00001000| 0a 20 20 20 54 68 65 20 | 64 69 73 74 69 6e 63 74 |. The |distinct|
|00001010| 69 6f 6e 20 41 64 61 20 | 39 58 20 6d 61 6b 65 73 |ion Ada |9X makes|
|00001020| 20 62 65 74 77 65 65 6e | 20 74 79 70 65 73 20 61 | between| types a|
|00001030| 6e 64 20 63 6c 61 73 73 | 65 73 20 28 3d 20 73 65 |nd class|es (= se|
|00001040| 74 20 6f 66 0d 0a 20 20 | 20 74 79 70 65 73 29 20 |t of.. | types) |
|00001050| 63 61 72 72 69 65 73 20 | 6f 76 65 72 20 69 6e 74 |carries |over int|
|00001060| 6f 20 74 68 65 20 73 65 | 6d 61 6e 74 69 63 20 6d |o the se|mantic m|
|00001070| 6f 64 65 6c 2c 20 61 6e | 64 20 61 6c 6c 6f 77 73 |odel, an|d allows|
|00001080| 20 73 6f 6d 65 0d 0a 20 | 20 20 69 6e 74 65 72 65 | some.. | intere|
|00001090| 73 74 69 6e 67 20 63 61 | 70 61 62 69 6c 69 74 69 |sting ca|pabiliti|
|000010a0| 65 73 20 6e 6f 74 20 70 | 72 65 73 65 6e 74 20 69 |es not p|resent i|
|000010b0| 6e 20 43 2b 2b 2e 20 49 | 6e 20 70 61 72 74 69 63 |n C++. I|n partic|
|000010c0| 75 6c 61 72 2c 20 69 6e | 20 41 64 61 20 39 58 0d |ular, in| Ada 9X.|
|000010d0| 0a 20 20 20 6f 6e 65 20 | 63 61 6e 20 64 65 63 6c |. one |can decl|
|000010e0| 61 72 65 20 61 20 22 63 | 6c 61 73 73 2d 77 69 64 |are a "c|lass-wid|
|000010f0| 65 22 20 6f 62 6a 65 63 | 74 20 69 6e 69 74 69 61 |e" objec|t initia|
|00001100| 6c 69 7a 65 64 20 62 79 | 20 63 6f 70 79 20 66 72 |lized by| copy fr|
|00001110| 6f 6d 20 61 0d 0a 20 20 | 20 22 63 6c 61 73 73 2d |om a.. | "class-|
|00001120| 77 69 64 65 22 20 66 6f | 72 6d 61 6c 20 70 61 72 |wide" fo|rmal par|
|00001130| 61 6d 65 74 65 72 2c 20 | 77 69 74 68 20 74 68 65 |ameter, |with the|
|00001140| 20 6e 65 77 20 6f 62 6a | 65 63 74 20 63 61 72 72 | new obj|ect carr|
|00001150| 79 69 6e 67 20 6f 76 65 | 72 20 74 68 65 0d 0a 20 |ying ove|r the.. |
|00001160| 20 20 75 6e 64 65 72 6c | 79 69 6e 67 20 74 79 70 | underl|ying typ|
|00001170| 65 20 6f 66 20 74 68 65 | 20 61 63 74 75 61 6c 20 |e of the| actual |
|00001180| 70 61 72 61 6d 65 74 65 | 72 2e 20 46 6f 72 20 65 |paramete|r. For e|
|00001190| 78 61 6d 70 6c 65 3a 0d | 0a 0d 0a 20 20 20 20 20 |xample:.|... |
|000011a0| 70 72 6f 63 65 64 75 72 | 65 20 50 72 69 6e 74 5f |procedur|e Print_|
|000011b0| 49 6e 5f 42 6f 6c 64 20 | 28 58 20 3a 20 54 27 43 |In_Bold |(X : T'C|
|000011c0| 6c 61 73 73 29 20 69 73 | 0d 0a 20 20 20 20 20 20 |lass) is|.. |
|000011d0| 20 2d 2d 20 43 6f 70 79 | 20 58 2c 20 6d 61 6b 65 | -- Copy| X, make|
|000011e0| 20 69 74 20 62 6f 6c 64 | 20 66 61 63 65 2c 20 61 | it bold| face, a|
|000011f0| 6e 64 20 74 68 65 6e 20 | 70 72 69 6e 74 20 69 74 |nd then |print it|
|00001200| 2e 0d 0a 20 20 20 20 20 | 20 20 43 6f 70 79 5f 4f |... | Copy_O|
|00001210| 66 5f 58 20 3a 20 54 27 | 43 6c 61 73 73 20 3a 3d |f_X : T'|Class :=|
|00001220| 20 58 3b 0d 0a 20 20 20 | 20 20 62 65 67 69 6e 0d | X;.. | begin.|
|00001230| 0a 20 20 20 20 20 20 20 | 20 4d 61 6b 65 5f 42 6f |. | Make_Bo|
|00001240| 6c 64 20 28 43 6f 70 79 | 5f 4f 66 5f 58 29 3b 0d |ld (Copy|_Of_X);.|
|00001250| 0a 20 20 20 20 20 20 20 | 20 50 72 69 6e 74 20 28 |. | Print (|
|00001260| 43 6f 70 79 5f 4f 66 5f | 58 29 3b 0d 0a 20 20 20 |Copy_Of_|X);.. |
|00001270| 20 20 65 6e 64 20 50 3b | 0d 0a 0d 0a 0d 0a 20 20 | end P;|...... |
|00001280| 20 49 6e 20 43 2b 2b 2c | 20 77 68 65 6e 20 79 6f | In C++,| when yo|
|00001290| 75 20 64 65 63 6c 61 72 | 65 20 61 6e 20 6f 62 6a |u declar|e an obj|
|000012a0| 65 63 74 2c 20 79 6f 75 | 20 6d 75 73 74 20 73 70 |ect, you| must sp|
|000012b0| 65 63 69 66 79 20 74 68 | 65 20 22 65 78 61 63 74 |ecify th|e "exact|
|000012c0| 22 20 63 6c 61 73 73 0d | 0a 20 20 20 6f 66 20 74 |" class.|. of t|
|000012d0| 68 65 20 6f 62 6a 65 63 | 74 20 2d 2d 20 69 74 20 |he objec|t -- it |
|000012e0| 63 61 6e 6e 6f 74 20 62 | 65 20 64 65 74 65 72 6d |cannot b|e determ|
|000012f0| 69 6e 65 64 20 62 79 20 | 74 68 65 20 75 6e 64 65 |ined by |the unde|
|00001300| 72 6c 79 69 6e 67 20 63 | 6c 61 73 73 20 6f 66 0d |rlying c|lass of.|
|00001310| 0a 20 20 20 74 68 65 20 | 69 6e 69 74 69 61 6c 69 |. the |initiali|
|00001320| 7a 69 6e 67 20 76 61 6c | 75 65 2e 20 49 6d 70 6c |zing val|ue. Impl|
|00001330| 65 6d 65 6e 74 69 6e 67 | 20 74 68 65 20 61 62 6f |ementing| the abo|
|00001340| 76 65 20 70 72 6f 63 65 | 64 75 72 65 20 69 6e 20 |ve proce|dure in |
|00001350| 61 20 67 65 6e 65 72 61 | 6c 0d 0a 20 20 20 77 61 |a genera|l.. wa|
|00001360| 79 20 69 6e 20 43 2b 2b | 20 77 6f 75 6c 64 20 62 |y in C++| would b|
|00001370| 65 20 73 6c 69 67 68 74 | 6c 79 20 6d 6f 72 65 20 |e slight|ly more |
|00001380| 74 65 64 69 6f 75 73 2e | 0d 0a 0d 0a 20 20 20 53 |tedious.|.... S|
|00001390| 69 6d 69 6c 61 72 6c 79 | 2c 20 69 6e 20 41 64 61 |imilarly|, in Ada|
|000013a0| 20 39 58 20 6f 6e 65 20 | 63 61 6e 20 64 65 66 69 | 9X one |can defi|
|000013b0| 6e 65 20 61 6e 20 61 63 | 63 65 73 73 20 74 79 70 |ne an ac|cess typ|
|000013c0| 65 20 74 68 61 74 20 64 | 65 73 69 67 6e 61 74 65 |e that d|esignate|
|000013d0| 73 0d 0a 20 20 20 6f 6e | 6c 79 20 6f 6e 65 20 73 |s.. on|ly one s|
|000013e0| 70 65 63 69 66 69 63 20 | 74 79 70 65 2c 20 6f 72 |pecific |type, or|
|000013f0| 20 61 6c 74 65 72 6e 61 | 74 69 76 65 6c 79 2c 20 | alterna|tively, |
|00001400| 6f 6e 65 20 63 61 6e 20 | 64 65 66 69 6e 65 20 6f |one can |define o|
|00001410| 6e 65 20 74 68 61 74 20 | 63 61 6e 0d 0a 20 20 20 |ne that |can.. |
|00001420| 64 65 73 69 67 6e 61 74 | 65 20 6f 62 6a 65 63 74 |designat|e object|
|00001430| 73 20 6f 66 20 61 6e 79 | 20 74 79 70 65 20 69 6e |s of any| type in|
|00001440| 20 61 20 63 6c 61 73 73 | 20 28 61 20 22 63 6c 61 | a class| (a "cla|
|00001450| 73 73 2d 77 69 64 65 22 | 20 61 63 63 65 73 73 20 |ss-wide"| access |
|00001460| 74 79 70 65 29 2e 0d 0a | 20 20 20 46 6f 72 20 65 |type)...| For e|
|00001470| 78 61 6d 70 6c 65 3a 0d | 0a 0d 0a 20 20 20 20 20 |xample:.|... |
|00001480| 74 79 70 65 20 46 61 6e | 63 79 5f 57 69 6e 64 6f |type Fan|cy_Windo|
|00001490| 77 5f 50 74 72 20 69 73 | 20 61 63 63 65 73 73 20 |w_Ptr is| access |
|000014a0| 46 61 6e 63 79 5f 57 69 | 6e 64 6f 77 3b 0d 0a 20 |Fancy_Wi|ndow;.. |
|000014b0| 20 20 20 20 20 20 2d 2d | 20 4f 6e 6c 79 20 70 6f | --| Only po|
|000014c0| 69 6e 74 73 20 61 74 20 | 46 61 6e 63 79 20 57 69 |ints at |Fancy Wi|
|000014d0| 6e 64 6f 77 73 20 2d 2d | 20 6e 6f 20 64 65 72 69 |ndows --| no deri|
|000014e0| 76 61 74 69 76 65 73 20 | 61 6c 6c 6f 77 65 64 0d |vatives |allowed.|
|000014f0| 0a 20 20 20 20 20 74 79 | 70 65 20 41 6e 79 5f 57 |. ty|pe Any_W|
|00001500| 69 6e 64 6f 77 5f 50 74 | 72 20 69 73 20 61 63 63 |indow_Pt|r is acc|
|00001510| 65 73 73 20 57 69 6e 64 | 6f 77 27 43 6c 61 73 73 |ess Wind|ow'Class|
|00001520| 3b 0d 0a 20 20 20 20 20 | 20 20 2d 2d 20 50 6f 69 |;.. | -- Poi|
|00001530| 6e 74 73 20 61 74 20 57 | 69 6e 64 6f 77 73 2c 20 |nts at W|indows, |
|00001540| 61 6e 64 20 61 6e 79 20 | 64 65 72 69 76 61 74 69 |and any |derivati|
|00001550| 76 65 73 20 74 68 65 72 | 65 6f 66 2e 0d 0a 0d 0a |ves ther|eof.....|
|00001560| 0d 0a 20 20 20 49 6e 20 | 43 2b 2b 2c 20 61 6c 6c |.. In |C++, all|
|00001570| 20 70 6f 69 6e 74 65 72 | 73 2f 72 65 66 65 72 65 | pointer|s/refere|
|00001580| 6e 63 65 73 20 61 72 65 | 20 22 63 6c 61 73 73 2d |nces are| "class-|
|00001590| 77 69 64 65 22 20 69 6e | 20 74 68 69 73 20 73 65 |wide" in| this se|
|000015a0| 6e 73 65 3b 20 79 6f 75 | 0d 0a 20 20 20 63 61 6e |nse; you|.. can|
|000015b0| 27 74 20 72 65 73 74 72 | 69 63 74 20 74 68 65 6d |'t restr|ict them|
|000015c0| 20 74 6f 20 70 6f 69 6e | 74 20 61 74 20 6f 6e 6c | to poin|t at onl|
|000015d0| 79 20 6f 6e 65 20 22 73 | 70 65 63 69 66 69 63 22 |y one "s|pecific"|
|000015e0| 20 74 79 70 65 2e 0d 0a | 0d 0a 20 20 20 49 6e 20 | type...|.. In |
|000015f0| 6f 74 68 65 72 20 77 6f | 72 64 73 2c 20 43 2b 2b |other wo|rds, C++|
|00001600| 20 6d 61 6b 65 73 20 74 | 68 65 20 64 69 73 74 69 | makes t|he disti|
|00001610| 6e 63 74 69 6f 6e 20 62 | 65 74 77 65 65 6e 20 22 |nction b|etween "|
|00001620| 73 70 65 63 69 66 69 63 | 22 20 61 6e 64 0d 0a 20 |specific|" and.. |
|00001630| 20 20 22 63 6c 61 73 73 | 2d 77 69 64 65 22 20 62 | "class|-wide" b|
|00001640| 61 73 65 64 20 6f 6e 20 | 70 6f 69 6e 74 65 72 2f |ased on |pointer/|
|00001650| 72 65 66 65 72 65 6e 63 | 65 20 76 65 72 73 75 73 |referenc|e versus|
|00001660| 20 6f 62 6a 65 63 74 2f | 76 61 6c 75 65 2c 20 77 | object/|value, w|
|00001670| 68 65 72 65 61 73 0d 0a | 20 20 20 69 6e 20 41 64 |hereas..| in Ad|
|00001680| 61 20 39 58 2c 20 74 68 | 69 73 20 64 69 73 74 69 |a 9X, th|is disti|
|00001690| 6e 63 74 69 6f 6e 20 69 | 73 20 65 78 70 6c 69 63 |nction i|s explic|
|000016a0| 69 74 2c 20 61 6e 64 20 | 63 6f 72 72 65 73 70 6f |it, and |correspo|
|000016b0| 6e 64 73 20 74 6f 20 74 | 68 65 0d 0a 20 20 20 64 |nds to t|he.. d|
|000016c0| 69 73 74 69 6e 63 74 69 | 6f 6e 20 62 65 74 77 65 |istincti|on betwe|
|000016d0| 65 6e 20 22 74 79 70 65 | 22 20 28 6f 6e 65 20 73 |en "type|" (one s|
|000016e0| 70 65 63 69 66 69 63 20 | 74 79 70 65 29 20 61 6e |pecific |type) an|
|000016f0| 64 20 22 63 6c 61 73 73 | 22 20 28 73 65 74 20 6f |d "class|" (set o|
|00001700| 66 0d 0a 20 20 20 74 79 | 70 65 73 29 2e 0d 0a 0d |f.. ty|pes)....|
|00001710| 0a 20 20 20 54 68 65 20 | 41 64 61 20 39 58 20 61 |. The |Ada 9X a|
|00001720| 70 70 72 6f 61 63 68 20 | 77 65 20 62 65 6c 69 65 |pproach |we belie|
|00001730| 76 65 20 28 68 6f 70 65 | 20 3b 2d 29 20 67 69 76 |ve (hope| ;-) giv|
|00001740| 65 73 20 73 6f 6d 65 77 | 68 61 74 20 62 65 74 74 |es somew|hat bett|
|00001750| 65 72 20 63 6f 6e 74 72 | 6f 6c 0d 0a 20 20 20 6f |er contr|ol.. o|
|00001760| 76 65 72 20 73 74 61 74 | 69 63 20 76 65 72 73 75 |ver stat|ic versu|
|00001770| 73 20 64 79 6e 61 6d 69 | 63 20 62 69 6e 64 69 6e |s dynami|c bindin|
|00001780| 67 2c 20 61 6e 64 20 69 | 73 20 6c 65 73 73 20 65 |g, and i|s less e|
|00001790| 72 72 6f 72 20 70 72 6f | 6e 65 20 73 69 6e 63 65 |rror pro|ne since|
|000017a0| 20 69 74 0d 0a 20 20 20 | 69 73 20 74 79 70 65 2d | it.. |is type-|
|000017b0| 62 61 73 65 64 2c 20 72 | 61 74 68 65 72 20 74 68 |based, r|ather th|
|000017c0| 61 6e 20 62 65 69 6e 67 | 20 62 61 73 65 64 20 6f |an being| based o|
|000017d0| 6e 20 72 65 66 65 72 65 | 6e 63 65 20 76 73 2e 20 |n refere|nce vs. |
|000017e0| 76 61 6c 75 65 2e 0d 0a | 0d 0a 20 20 20 49 6e 20 |value...|.. In |
|000017f0| 61 6e 79 20 63 61 73 65 | 2c 20 69 6e 20 41 64 61 |any case|, in Ada|
|00001800| 20 39 58 2c 20 43 2b 2b | 2c 20 61 6e 64 20 43 4c | 9X, C++|, and CL|
|00001810| 4f 53 20 69 74 20 6d 61 | 6b 65 73 20 73 65 6e 73 |OS it ma|kes sens|
|00001820| 65 20 74 6f 20 74 61 6c | 6b 20 61 62 6f 75 74 0d |e to tal|k about.|
|00001830| 0a 20 20 20 22 63 6c 61 | 73 73 20 6c 69 62 72 61 |. "cla|ss libra|
|00001840| 72 69 65 73 2c 22 20 73 | 69 6e 63 65 20 61 20 67 |ries," s|ince a g|
|00001850| 69 76 65 6e 20 6c 69 62 | 72 61 72 79 20 77 69 6c |iven lib|rary wil|
|00001860| 6c 20 67 65 6e 65 72 61 | 6c 6c 79 20 63 6f 6e 73 |l genera|lly cons|
|00001870| 69 73 74 20 6f 66 20 61 | 0d 0a 20 20 20 73 65 74 |ist of a|.. set|
|00001880| 20 6f 66 20 69 6e 74 65 | 72 72 65 6c 61 74 65 64 | of inte|rrelated|
|00001890| 20 74 79 70 65 73 2e 20 | 49 6e 20 41 64 61 20 39 | types. |In Ada 9|
|000018a0| 58 20 61 6e 64 20 43 4c | 4f 53 2c 20 6f 6e 65 20 |X and CL|OS, one |
|000018b0| 63 6f 75 6c 64 20 61 6c | 74 65 72 6e 61 74 69 76 |could al|ternativ|
|000018c0| 65 6c 79 0d 0a 20 20 20 | 74 61 6c 6b 20 61 62 6f |ely.. |talk abo|
|000018d0| 75 74 20 61 20 73 65 74 | 20 6f 66 20 22 72 65 75 |ut a set| of "reu|
|000018e0| 73 61 62 6c 65 20 70 61 | 63 6b 61 67 65 73 22 20 |sable pa|ckages" |
|000018f0| 61 6e 64 20 6d 65 61 6e | 20 65 73 73 65 6e 74 69 |and mean| essenti|
|00001900| 61 6c 6c 79 20 74 68 65 | 20 73 61 6d 65 0d 0a 20 |ally the| same.. |
|00001910| 20 20 74 68 69 6e 67 2e | 0d 0a 0d 0a 0d 0a 35 2e | thing.|......5.|
|00001920| 32 3a 20 56 61 72 69 61 | 6e 74 20 72 65 63 6f 72 |2: Varia|nt recor|
|00001930| 64 73 20 73 65 65 6d 20 | 6c 69 6b 65 20 61 20 64 |ds seem |like a d|
|00001940| 65 61 64 20 66 65 61 74 | 75 72 65 20 6e 6f 77 2e |ead feat|ure now.|
|00001950| 20 57 68 65 6e 20 73 68 | 6f 75 6c 64 20 49 20 75 | When sh|ould I u|
|00001960| 73 65 20 74 68 65 6d 0d | 0a 69 6e 73 74 65 61 64 |se them.|.instead|
|00001970| 20 6f 66 20 74 61 67 67 | 65 64 20 74 79 70 65 73 | of tagg|ed types|
|00001980| 3f 0d 0a 0d 0a 20 20 20 | 54 68 69 73 20 69 73 20 |?.... |This is |
|00001990| 61 6e 20 69 6e 73 74 61 | 6e 63 65 20 6f 66 20 61 |an insta|nce of a|
|000019a0| 20 6d 75 63 68 20 6d 6f | 72 65 20 67 65 6e 65 72 | much mo|re gener|
|000019b0| 61 6c 20 71 75 65 73 74 | 69 6f 6e 3a 20 22 57 68 |al quest|ion: "Wh|
|000019c0| 65 6e 20 73 68 6f 75 6c | 64 20 49 0d 0a 20 20 20 |en shoul|d I.. |
|000019d0| 75 73 65 20 77 68 61 74 | 20 6b 69 6e 64 20 6f 66 |use what| kind of|
|000019e0| 20 74 79 70 65 3f 22 20 | 54 68 65 20 73 69 6d 70 | type?" |The simp|
|000019f0| 6c 65 20 61 6e 73 77 65 | 72 20 69 73 3a 20 22 57 |le answe|r is: "W|
|00001a00| 68 65 6e 20 69 74 20 6d | 61 6b 65 73 20 73 65 6e |hen it m|akes sen|
|00001a10| 73 65 20 74 6f 0d 0a 20 | 20 20 64 6f 20 73 6f 2e |se to.. | do so.|
|00001a20| 22 20 54 68 65 20 72 65 | 61 6c 20 6b 65 79 20 74 |" The re|al key t|
|00001a30| 6f 20 63 68 6f 73 69 6e | 67 20 61 20 74 79 70 65 |o chosin|g a type|
|00001a40| 20 69 6e 20 41 64 61 20 | 69 73 20 74 6f 20 6c 6f | in Ada |is to lo|
|00001a50| 6f 6b 20 61 74 20 74 68 | 65 0d 0a 20 20 20 61 70 |ok at th|e.. ap|
|00001a60| 70 6c 69 63 61 74 69 6f | 6e 2c 20 61 6e 64 20 70 |plicatio|n, and p|
|00001a70| 69 63 6b 20 74 68 65 20 | 74 79 70 65 20 74 68 61 |ick the |type tha|
|00001a80| 74 20 6d 6f 73 74 20 63 | 6c 6f 73 65 6c 79 20 6d |t most c|losely m|
|00001a90| 6f 64 65 6c 73 20 74 68 | 65 20 70 72 6f 62 6c 65 |odels th|e proble|
|00001aa0| 6d 2e 0d 0a 0d 0a 20 20 | 20 46 6f 72 20 69 6e 73 |m..... | For ins|
|00001ab0| 74 61 6e 63 65 2c 20 69 | 66 20 79 6f 75 20 61 72 |tance, i|f you ar|
|00001ac0| 65 20 6d 6f 64 65 6c 6c | 69 6e 67 20 64 61 74 61 |e modell|ing data|
|00001ad0| 20 74 72 61 6e 73 6d 69 | 73 73 69 6f 6e 20 77 68 | transmi|ssion wh|
|00001ae0| 65 72 65 20 74 68 65 20 | 6d 65 73 73 61 67 65 0d |ere the |message.|
|00001af0| 0a 20 20 20 70 61 63 6b | 65 74 73 20 6d 61 79 20 |. pack|ets may |
|00001b00| 63 6f 6e 74 61 69 6e 20 | 76 61 72 69 61 62 6c 65 |contain |variable|
|00001b10| 20 66 6f 72 6d 73 20 6f | 66 20 64 61 74 61 2c 20 | forms o|f data, |
|00001b20| 61 20 76 61 72 69 61 6e | 74 20 72 65 63 6f 72 64 |a varian|t record|
|00001b30| 20 2d 2d 6e 6f 74 20 61 | 0d 0a 20 20 20 68 69 65 | --not a|.. hie|
|00001b40| 72 61 72 63 68 79 20 6f | 66 20 74 61 67 67 65 64 |rarchy o|f tagged|
|00001b50| 20 74 79 70 65 73 2d 2d | 20 69 73 20 61 6e 20 61 | types--| is an a|
|00001b60| 70 70 72 6f 70 72 69 61 | 74 65 20 6d 6f 64 65 6c |ppropria|te model|
|00001b70| 2c 20 73 69 6e 63 65 20 | 74 68 65 72 65 20 6d 61 |, since |there ma|
|00001b80| 79 0d 0a 20 20 20 62 65 | 20 6e 6f 20 72 65 6c 61 |y.. be| no rela|
|00001b90| 74 69 6f 6e 73 68 69 70 | 20 62 65 74 77 65 65 6e |tionship| between|
|00001ba0| 20 74 68 65 20 64 61 74 | 61 20 69 74 65 6d 73 20 | the dat|a items |
|00001bb0| 6f 74 68 65 72 20 74 68 | 61 6e 20 74 68 65 69 72 |other th|an their|
|00001bc0| 20 62 65 69 6e 67 0d 0a | 20 20 20 74 72 61 6e 73 | being..| trans|
|00001bd0| 6d 69 74 74 65 64 20 6f | 76 65 72 20 6f 6e 65 20 |mitted o|ver one |
|00001be0| 63 68 61 6e 6e 65 6c 2e | 20 49 66 20 79 6f 75 20 |channel.| If you |
|00001bf0| 63 68 6f 6f 73 65 20 74 | 6f 20 6d 6f 64 65 6c 20 |choose t|o model |
|00001c00| 74 68 65 20 62 61 73 65 | 20 74 79 70 65 20 6f 66 |the base| type of|
|00001c10| 0d 0a 20 20 20 74 68 65 | 20 6d 65 73 73 61 67 65 |.. the| message|
|00001c20| 73 20 77 69 74 68 20 61 | 20 74 61 67 67 65 64 20 |s with a| tagged |
|00001c30| 74 79 70 65 2c 20 74 68 | 61 74 20 6d 61 79 20 70 |type, th|at may p|
|00001c40| 72 65 73 65 6e 74 20 6d | 6f 72 65 20 70 72 6f 62 |resent m|ore prob|
|00001c50| 6c 65 6d 73 20 74 68 61 | 6e 0d 0a 20 20 20 69 74 |lems tha|n.. it|
|00001c60| 20 73 6f 6c 76 65 73 20 | 77 68 65 6e 20 63 6f 6d | solves |when com|
|00001c70| 6d 75 6e 69 63 61 74 69 | 6e 67 20 61 63 72 6f 73 |municati|ng acros|
|00001c80| 73 20 64 69 73 74 69 6e | 63 74 20 61 72 63 68 69 |s distin|ct archi|
|00001c90| 74 65 63 74 75 72 65 73 | 2e 0d 0a 0d 0a 20 20 20 |tectures|..... |
|00001ca0| 5b 4d 6f 72 65 20 74 6f | 20 62 65 20 73 61 69 64 |[More to| be said|
|00001cb0| 20 61 62 6f 75 74 20 76 | 61 72 69 61 6e 74 20 70 | about v|ariant p|
|00001cc0| 72 6f 67 72 61 6d 6d 69 | 6e 67 20 76 73 2e 20 69 |rogrammi|ng vs. i|
|00001cd0| 6e 63 72 65 6d 65 6e 74 | 61 6c 0d 0a 20 20 20 70 |ncrement|al.. p|
|00001ce0| 72 6f 67 72 61 6d 6d 69 | 6e 67 2e 5d 0d 0a 0d 0a |rogrammi|ng.]....|
|00001cf0| 0d 0a 35 2e 33 3a 20 57 | 68 61 74 20 69 73 20 6d |..5.3: W|hat is m|
|00001d00| 65 61 6e 74 20 62 79 20 | 22 69 6e 74 65 72 66 61 |eant by |"interfa|
|00001d10| 63 65 20 69 6e 68 65 72 | 69 74 61 6e 63 65 22 20 |ce inher|itance" |
|00001d20| 61 6e 64 20 68 6f 77 20 | 64 6f 65 73 20 41 64 61 |and how |does Ada|
|00001d30| 20 73 75 70 70 6f 72 74 | 20 69 74 3f 0d 0a 0d 0a | support| it?....|
|00001d40| 20 20 20 54 68 69 73 20 | 61 6e 73 77 65 72 20 69 | This |answer i|
|00001d50| 6e 74 65 6e 74 69 6f 6e | 61 6c 6c 79 20 6c 65 66 |ntention|ally lef|
|00001d60| 74 20 62 6c 61 6e 6b 2e | 0d 0a 0d 0a 0d 0a 35 2e |t blank.|......5.|
|00001d70| 34 3a 20 48 6f 77 20 64 | 6f 20 79 6f 75 20 64 6f |4: How d|o you do|
|00001d80| 20 6d 75 6c 74 69 70 6c | 65 20 69 6e 68 65 72 69 | multipl|e inheri|
|00001d90| 74 61 6e 63 65 20 69 6e | 20 41 64 61 20 39 58 3f |tance in| Ada 9X?|
|00001da0| 0d 0a 0d 0a 20 20 20 54 | 68 65 72 65 20 69 73 20 |.... T|here is |
|00001db0| 61 20 6c 65 6e 67 74 68 | 79 20 70 61 70 65 72 20 |a length|y paper |
|00001dc0| 69 6e 20 66 69 6c 65 0d | 0a 20 20 20 66 74 70 3a |in file.|. ftp:|
|00001dd0| 2f 2f 73 77 2d 65 6e 67 | 2e 66 61 6c 6c 73 2d 63 |//sw-eng|.falls-c|
|00001de0| 68 75 72 63 68 2e 76 61 | 2e 75 73 2f 70 75 62 6c |hurch.va|.us/publ|
|00001df0| 69 63 2f 41 64 61 49 43 | 2f 66 6c 79 65 72 73 2f |ic/AdaIC|/flyers/|
|00001e00| 39 78 6d 2d 69 6e 68 2e | 74 78 74 0d 0a 0d 0a 20 |9xm-inh.|txt.... |
|00001e10| 20 20 54 68 61 74 20 64 | 6f 63 75 6d 65 6e 74 20 | That d|ocument |
|00001e20| 64 65 73 63 72 69 62 65 | 73 20 73 65 76 65 72 61 |describe|s severa|
|00001e30| 6c 20 6d 65 63 68 61 6e | 69 73 6d 73 20 66 6f 72 |l mechan|isms for|
|00001e40| 20 61 63 68 69 65 76 69 | 6e 67 20 4d 49 20 69 6e | achievi|ng MI in|
|00001e50| 20 41 64 61 2e 20 49 74 | 0d 0a 20 20 20 69 73 20 | Ada. It|.. is |
|00001e60| 6e 6f 74 20 75 6e 75 73 | 75 61 6c 2c 20 68 6f 77 |not unus|ual, how|
|00001e70| 65 76 65 72 2c 20 74 6f | 20 66 69 6e 64 20 63 6f |ever, to| find co|
|00001e80| 6d 70 6c 61 69 6e 74 73 | 20 61 62 6f 75 74 20 74 |mplaints| about t|
|00001e90| 68 65 20 73 79 6e 74 61 | 78 20 61 6e 64 20 74 68 |he synta|x and th|
|00001ea0| 65 0d 0a 20 20 20 70 65 | 72 63 65 69 76 65 64 20 |e.. pe|rceived |
|00001eb0| 62 75 72 64 65 6e 20 69 | 74 20 70 6c 61 63 65 73 |burden i|t places|
|00001ec0| 20 6f 6e 20 74 68 65 20 | 64 65 76 65 6c 6f 70 65 | on the |develope|
|00001ed0| 72 2e 20 54 68 69 73 20 | 69 73 20 77 68 61 74 20 |r. This |is what |
|00001ee0| 54 75 63 6b 65 72 20 54 | 61 66 74 0d 0a 20 20 20 |Tucker T|aft.. |
|00001ef0| 68 61 64 20 74 6f 20 73 | 61 79 20 77 68 65 6e 20 |had to s|ay when |
|00001f00| 72 65 73 70 6f 6e 67 69 | 6e 67 20 74 6f 20 73 75 |respongi|ng to su|
|00001f10| 63 68 20 61 20 63 72 69 | 74 69 63 69 73 6d 20 6f |ch a cri|ticism o|
|00001f20| 6e 20 63 6f 6d 70 2e 6c | 61 6e 67 2e 61 64 61 3a |n comp.l|ang.ada:|
|00001f30| 0d 0a 0d 0a 20 20 20 43 | 6f 6d 69 6e 67 20 75 70 |.... C|oming up|
|00001f40| 20 77 69 74 68 20 61 20 | 73 79 6e 74 61 78 20 66 | with a |syntax f|
|00001f50| 6f 72 20 6d 75 6c 74 69 | 70 6c 65 20 69 6e 68 65 |or multi|ple inhe|
|00001f60| 72 69 74 61 6e 63 65 20 | 77 61 73 20 6e 6f 74 20 |ritance |was not |
|00001f70| 74 68 65 0d 0a 20 20 20 | 63 68 61 6c 6c 65 6e 67 |the.. |challeng|
|00001f80| 65 2e 20 54 68 65 20 63 | 68 61 6c 6c 65 6e 67 65 |e. The c|hallenge|
|00001f90| 20 77 61 73 20 63 6f 6d | 69 6e 67 20 75 70 20 77 | was com|ing up w|
|00001fa0| 69 74 68 20 61 20 73 65 | 74 20 6f 66 20 73 74 72 |ith a se|t of str|
|00001fb0| 61 69 67 68 74 66 6f 72 | 77 61 72 64 0d 0a 20 20 |aightfor|ward.. |
|00001fc0| 20 79 65 74 20 66 6c 65 | 78 69 62 6c 65 20 72 75 | yet fle|xible ru|
|00001fd0| 6c 65 73 20 66 6f 72 20 | 72 65 73 6f 6c 76 69 6e |les for |resolvin|
|00001fe0| 67 20 74 68 65 20 77 65 | 6c 6c 20 6b 6e 6f 77 6e |g the we|ll known|
|00001ff0| 20 70 72 6f 62 6c 65 6d | 73 20 61 73 73 6f 63 69 | problem|s associ|
|00002000| 61 74 65 64 0d 0a 20 20 | 20 77 69 74 68 20 6d 75 |ated.. | with mu|
|00002010| 6c 74 69 70 6c 65 20 69 | 6e 68 65 72 69 74 61 6e |ltiple i|nheritan|
|00002020| 63 65 2c 20 6e 61 6d 65 | 6c 79 3a 0d 0a 20 20 20 |ce, name|ly:.. |
|00002030| 20 20 2a 20 49 66 20 74 | 68 65 20 73 61 6d 65 20 | * If t|he same |
|00002040| 74 79 70 65 20 61 70 70 | 65 61 72 73 20 61 73 20 |type app|ears as |
|00002050| 61 6e 20 61 6e 63 65 73 | 74 6f 72 20 6d 6f 72 65 |an ances|tor more|
|00002060| 20 74 68 61 6e 20 6f 6e | 63 65 2c 20 73 68 6f 75 | than on|ce, shou|
|00002070| 6c 64 20 61 6c 6c 0d 0a | 20 20 20 20 20 20 20 6f |ld all..| o|
|00002080| 72 20 73 6f 6d 65 20 6f | 66 20 69 74 73 20 64 61 |r some o|f its da|
|00002090| 74 61 20 63 6f 6d 70 6f | 6e 65 6e 74 73 20 62 65 |ta compo|nents be|
|000020a0| 20 64 75 70 6c 69 63 61 | 74 65 64 2c 20 6f 72 20 | duplica|ted, or |
|000020b0| 73 68 61 72 65 64 3f 20 | 49 66 20 61 6e 79 0d 0a |shared? |If any..|
|000020c0| 20 20 20 20 20 20 20 61 | 72 65 20 64 75 70 6c 69 | a|re dupli|
|000020d0| 63 61 74 65 64 2c 20 68 | 6f 77 20 61 72 65 20 74 |cated, h|ow are t|
|000020e0| 68 65 79 20 72 65 66 65 | 72 65 6e 63 65 64 20 75 |hey refe|renced u|
|000020f0| 6e 61 6d 62 69 67 75 6f | 75 73 6c 79 3f 0d 0a 0d |nambiguo|usly?...|
|00002100| 0a 20 20 20 20 20 2a 20 | 49 66 20 74 68 65 20 73 |. * |If the s|
|00002110| 61 6d 65 2d 6e 61 6d 65 | 64 20 28 69 6e 63 6c 75 |ame-name|d (inclu|
|00002120| 64 69 6e 67 20 73 61 6d | 65 20 70 61 72 61 6d 65 |ding sam|e parame|
|00002130| 74 65 72 2f 72 65 73 75 | 6c 74 20 70 72 6f 66 69 |ter/resu|lt profi|
|00002140| 6c 65 29 0d 0a 20 20 20 | 20 20 20 20 6f 70 65 72 |le).. | oper|
|00002150| 61 74 69 6f 6e 20 69 73 | 20 69 6e 68 65 72 69 74 |ation is| inherit|
|00002160| 65 64 20 61 6c 6f 6e 67 | 20 74 77 6f 20 70 61 74 |ed along| two pat|
|00002170| 68 73 2c 20 68 6f 77 20 | 69 73 20 74 68 65 20 61 |hs, how |is the a|
|00002180| 6d 62 69 67 75 69 74 79 | 0d 0a 20 20 20 20 20 20 |mbiguity|.. |
|00002190| 20 72 65 73 6f 6c 76 65 | 64 3f 20 43 61 6e 20 79 | resolve|d? Can y|
|000021a0| 6f 75 20 6f 76 65 72 72 | 69 64 65 20 65 61 63 68 |ou overr|ide each|
|000021b0| 20 77 69 74 68 20 64 69 | 66 66 65 72 65 6e 74 20 | with di|fferent |
|000021c0| 63 6f 64 65 3f 20 48 6f | 77 20 64 6f 20 79 6f 75 |code? Ho|w do you|
|000021d0| 0d 0a 20 20 20 20 20 20 | 20 72 65 66 65 72 20 74 |.. | refer t|
|000021e0| 6f 20 74 68 65 6d 20 6c | 61 74 65 72 3f 0d 0a 0d |o them l|ater?...|
|000021f0| 0a 20 20 20 20 20 2a 20 | 45 74 63 2e 0d 0a 0d 0a |. * |Etc.....|
|00002200| 0d 0a 20 20 20 46 6f 72 | 20 61 6e 73 77 65 72 73 |.. For| answers|
|00002210| 2c 20 79 6f 75 20 63 61 | 6e 20 6c 6f 6f 6b 20 61 |, you ca|n look a|
|00002220| 74 20 74 68 65 20 76 61 | 72 69 6f 75 73 20 6c 61 |t the va|rious la|
|00002230| 6e 67 75 61 67 65 73 20 | 74 68 61 74 20 64 65 66 |nguages |that def|
|00002240| 69 6e 65 20 61 0d 0a 20 | 20 20 62 75 69 6c 74 2d |ine a.. | built-|
|00002250| 69 6e 20 61 70 70 72 6f | 61 63 68 20 74 6f 20 6d |in appro|ach to m|
|00002260| 75 6c 74 69 70 6c 65 20 | 69 6e 68 65 72 69 74 61 |ultiple |inherita|
|00002270| 6e 63 65 2e 20 55 6e 66 | 6f 72 74 75 6e 61 74 65 |nce. Unf|ortunate|
|00002280| 6c 79 2c 20 79 6f 75 20 | 77 69 6c 6c 0d 0a 20 20 |ly, you |will.. |
|00002290| 20 67 65 6e 65 72 61 6c | 6c 79 20 67 65 74 20 61 | general|ly get a|
|000022a0| 20 64 69 66 66 65 72 65 | 6e 74 20 61 6e 73 77 65 | differe|nt answe|
|000022b0| 72 20 66 6f 72 20 65 61 | 63 68 20 6c 61 6e 67 75 |r for ea|ch langu|
|000022c0| 61 67 65 20 2d 2d 20 68 | 61 72 64 6c 79 20 61 0d |age -- h|ardly a.|
|000022d0| 0a 20 20 20 73 69 74 75 | 61 74 69 6f 6e 20 74 68 |. situ|ation th|
|000022e0| 61 74 20 73 75 67 67 65 | 73 74 73 20 77 65 20 77 |at sugge|sts we w|
|000022f0| 69 6c 6c 20 62 65 20 61 | 62 6c 65 20 74 6f 20 63 |ill be a|ble to c|
|00002300| 72 61 66 74 20 61 6e 20 | 69 6e 74 65 72 6e 61 74 |raft an |internat|
|00002310| 69 6f 6e 61 6c 0d 0a 20 | 20 20 63 6f 6e 73 65 6e |ional.. | consen|
|00002320| 73 75 73 2e 20 45 69 66 | 66 65 6c 20 75 73 65 73 |sus. Eif|fel uses|
|00002330| 20 72 65 6e 61 6d 69 6e | 67 20 61 6e 64 20 6f 74 | renamin|g and ot|
|00002340| 68 65 72 20 74 65 63 68 | 6e 69 71 75 65 73 2c 20 |her tech|niques, |
|00002350| 77 68 69 63 68 20 73 65 | 65 6d 20 71 75 69 74 65 |which se|em quite|
|00002360| 0d 0a 20 20 20 66 6c 65 | 78 69 62 6c 65 2c 20 62 |.. fle|xible, b|
|00002370| 75 74 20 61 74 20 6c 65 | 61 73 74 20 69 6e 20 73 |ut at le|ast in s|
|00002380| 6f 6d 65 20 65 78 61 6d | 70 6c 65 73 2c 20 63 61 |ome exam|ples, ca|
|00002390| 6e 20 62 65 20 71 75 69 | 74 65 20 63 6f 6e 66 75 |n be qui|te confu|
|000023a0| 73 69 6e 67 20 28 77 68 | 65 72 65 0d 0a 20 20 20 |sing (wh|ere.. |
|000023b0| 79 6f 75 20 6f 76 65 72 | 72 69 64 65 20 22 42 22 |you over|ride "B"|
|000023c0| 20 74 6f 20 63 68 61 6e | 67 65 20 77 68 61 74 20 | to chan|ge what |
|000023d0| 22 41 22 20 64 6f 65 73 | 20 69 6e 20 73 6f 6d 65 |"A" does| in some|
|000023e0| 20 64 69 73 74 61 6e 74 | 20 61 6e 63 65 73 74 6f | distant| ancesto|
|000023f0| 72 29 2e 0d 0a 20 20 20 | 43 2b 2b 20 68 61 73 20 |r)... |C++ has |
|00002400| 62 6f 74 68 20 6e 6f 6e | 2d 76 69 72 74 75 61 6c |both non|-virtual|
|00002410| 20 61 6e 64 20 76 69 72 | 74 75 61 6c 20 62 61 73 | and vir|tual bas|
|00002420| 65 20 63 6c 61 73 65 73 | 2c 20 77 69 74 68 20 61 |e clases|, with a|
|00002430| 20 6e 75 6d 62 65 72 20 | 6f 66 0d 0a 20 20 20 72 | number |of.. r|
|00002440| 75 6c 65 73 20 61 73 73 | 6f 63 69 61 74 65 64 20 |ules ass|ociated |
|00002450| 77 69 74 68 20 65 61 63 | 68 2c 20 61 6e 64 20 76 |with eac|h, and v|
|00002460| 61 72 69 6f 75 73 20 6c | 69 6d 69 74 61 74 69 6f |arious l|imitatio|
|00002470| 6e 73 20 72 65 6c 61 74 | 69 6e 67 20 74 6f 0d 0a |ns relat|ing to..|
|00002480| 20 20 20 64 6f 77 6e 63 | 61 73 74 69 6e 67 20 61 | downc|asting a|
|00002490| 6e 64 20 76 69 72 74 75 | 61 6c 20 62 61 73 65 20 |nd virtu|al base |
|000024a0| 63 6c 61 73 73 65 73 2e | 20 43 4c 4f 53 20 75 73 |classes.| CLOS us|
|000024b0| 65 73 20 73 69 6d 70 6c | 65 20 6e 61 6d 65 20 6d |es simpl|e name m|
|000024c0| 61 74 63 68 69 6e 67 0d | 0a 20 20 20 74 6f 20 63 |atching.|. to c|
|000024d0| 6f 6e 74 72 6f 6c 20 22 | 73 6c 6f 74 22 20 6d 65 |ontrol "|slot" me|
|000024e0| 72 67 69 6e 67 2e 20 53 | 6f 6d 65 20 6c 61 6e 67 |rging. S|ome lang|
|000024f0| 75 61 67 65 73 20 72 65 | 71 75 69 72 65 20 74 68 |uages re|quire th|
|00002500| 61 74 20 61 6c 6c 20 62 | 75 74 20 6f 6e 65 20 6f |at all b|ut one o|
|00002510| 66 0d 0a 20 20 20 74 68 | 65 20 70 61 72 65 6e 74 |f.. th|e parent|
|00002520| 20 74 79 70 65 73 20 62 | 65 20 61 62 73 74 72 61 | types b|e abstra|
|00002530| 63 74 2c 20 64 61 74 61 | 2d 6c 65 73 73 20 74 79 |ct, data|-less ty|
|00002540| 70 65 73 2c 20 73 6f 20 | 6f 6e 6c 79 20 69 6e 74 |pes, so |only int|
|00002550| 65 72 66 61 63 65 73 20 | 61 72 65 0d 0a 20 20 20 |erfaces |are.. |
|00002560| 62 65 69 6e 67 20 69 6e | 68 65 72 69 74 65 64 3b |being in|herited;|
|00002570| 20 68 6f 77 65 76 65 72 | 20 69 66 20 74 68 65 20 | however| if the |
|00002580| 69 6e 74 65 72 66 61 63 | 65 73 20 68 61 70 70 65 |interfac|es happe|
|00002590| 6e 20 74 6f 20 63 6f 6c | 6c 69 64 65 2c 20 79 6f |n to col|lide, yo|
|000025a0| 75 0d 0a 20 20 20 73 74 | 69 6c 6c 20 63 61 6e 20 |u.. st|ill can |
|000025b0| 65 6e 64 20 75 70 20 77 | 69 74 68 20 75 6e 64 65 |end up w|ith unde|
|000025c0| 73 69 72 61 62 6c 65 20 | 61 6e 64 20 70 6f 74 65 |sirable |and pote|
|000025d0| 6e 74 69 61 6c 6c 79 20 | 75 6e 72 65 73 6f 6c 76 |ntially |unresolv|
|000025e0| 61 62 6c 65 0d 0a 20 20 | 20 63 6f 6c 6c 69 73 69 |able.. | collisi|
|000025f0| 6f 6e 73 20 28 77 68 65 | 72 65 20 79 6f 75 20 72 |ons (whe|re you r|
|00002600| 65 61 6c 6c 79 20 77 61 | 6e 74 20 64 69 66 66 65 |eally wa|nt diffe|
|00002610| 72 65 6e 74 20 63 6f 64 | 65 20 66 6f 72 20 73 61 |rent cod|e for sa|
|00002620| 6d 65 2d 6e 61 6d 65 64 | 0d 0a 20 20 20 69 6e 74 |me-named|.. int|
|00002630| 65 72 66 61 63 65 73 20 | 69 6e 68 65 72 69 74 65 |erfaces |inherite|
|00002640| 64 20 66 72 6f 6d 20 64 | 69 66 66 65 72 65 6e 74 |d from d|ifferent|
|00002650| 20 61 6e 63 65 73 74 6f | 72 73 29 2e 0d 0a 0d 0a | ancesto|rs).....|
|00002660| 20 20 20 4f 6e 65 20 61 | 72 67 75 6d 65 6e 74 20 | One a|rgument |
|00002670| 69 73 20 74 68 61 74 20 | 63 6f 6c 6c 69 73 69 6f |is that |collisio|
|00002680| 6e 73 20 61 72 65 20 72 | 61 72 65 20 74 6f 20 62 |ns are r|are to b|
|00002690| 65 67 69 6e 20 77 69 74 | 68 2c 20 73 6f 20 69 74 |egin wit|h, so it|
|000026a0| 20 64 6f 65 73 6e 27 74 | 0d 0a 20 20 20 6d 61 6b | doesn't|.. mak|
|000026b0| 65 20 6d 75 63 68 20 64 | 69 66 66 65 72 65 6e 74 |e much d|ifferent|
|000026c0| 20 68 6f 77 20 74 68 65 | 79 20 61 72 65 20 72 65 | how the|y are re|
|000026d0| 73 6f 6c 76 65 64 2e 20 | 54 68 61 74 20 69 73 20 |solved. |That is |
|000026e0| 70 72 6f 62 61 62 6c 79 | 20 74 72 75 65 2c 20 62 |probably| true, b|
|000026f0| 75 74 0d 0a 20 20 20 74 | 68 65 20 61 72 67 75 6d |ut.. t|he argum|
|00002700| 65 6e 74 20 64 6f 65 73 | 6e 27 74 20 77 6f 72 6b |ent does|n't work|
|00002710| 20 74 6f 6f 20 77 65 6c | 6c 20 64 75 72 69 6e 67 | too wel|l during|
|00002720| 20 61 6e 20 6f 70 65 6e | 20 6c 61 6e 67 75 61 67 | an open| languag|
|00002730| 65 20 64 65 73 69 67 6e | 0d 0a 20 20 20 70 72 6f |e design|.. pro|
|00002740| 63 65 73 73 20 2d 2d 20 | 70 65 6f 70 6c 65 20 67 |cess -- |people g|
|00002750| 65 74 20 75 70 73 65 74 | 20 61 74 20 74 68 65 20 |et upset| at the |
|00002760| 6d 6f 73 74 20 75 6e 62 | 65 6c 69 65 76 61 62 6c |most unb|elievabl|
|00002770| 79 20 74 72 69 76 69 61 | 6c 20 61 6e 64 0d 0a 20 |y trivia|l and.. |
|00002780| 20 20 72 61 72 65 6c 79 | 20 75 73 65 64 20 66 65 | rarely| used fe|
|00002790| 61 74 75 72 65 73 20 69 | 66 20 6e 6f 74 20 22 63 |atures i|f not "c|
|000027a0| 6f 72 72 65 63 74 6c 79 | 22 20 64 65 73 69 67 6e |orrectly|" design|
|000027b0| 65 64 20 28 73 70 65 61 | 6b 69 6e 67 20 66 72 6f |ed (spea|king fro|
|000027c0| 6d 0d 0a 20 20 20 65 78 | 70 65 72 69 65 6e 63 65 |m.. ex|perience|
|000027d0| 20 68 65 72 65 20 3b 2d | 29 2e 0d 0a 0d 0a 20 20 | here ;-|)..... |
|000027e0| 20 46 75 72 74 68 65 72 | 6d 6f 72 65 2c 20 67 69 | Further|more, gi|
|000027f0| 76 65 6e 20 74 68 61 74 | 20 6d 61 6e 79 20 6f 66 |ven that| many of|
|00002800| 20 74 68 65 20 70 72 65 | 64 6f 6d 69 6e 61 6e 74 | the pre|dominant|
|00002810| 20 75 73 65 73 20 6f 66 | 20 4d 49 20 28 73 65 70 | uses of| MI (sep|
|00002820| 61 72 61 74 69 6f 6e 0d | 0a 20 20 20 6f 66 20 69 |aration.|. of i|
|00002830| 6e 74 65 72 66 61 63 65 | 20 69 6e 68 65 72 69 74 |nterface| inherit|
|00002840| 61 6e 63 65 20 66 72 6f | 6d 20 69 6d 70 6c 65 6d |ance fro|m implem|
|00002850| 65 6e 74 61 74 69 6f 6e | 20 69 6e 68 65 72 69 74 |entation| inherit|
|00002860| 61 6e 63 65 2c 20 67 61 | 69 6e 69 6e 67 0d 0a 20 |ance, ga|ining.. |
|00002870| 20 20 63 6f 6e 76 65 6e | 69 65 6e 74 20 61 63 63 | conven|ient acc|
|00002880| 65 73 73 20 74 6f 20 61 | 6e 6f 74 68 65 72 20 63 |ess to a|nother c|
|00002890| 6c 61 73 73 27 73 20 66 | 65 61 74 75 72 65 73 2c |lass's f|eatures,|
|000028a0| 20 68 61 73 2d 61 20 72 | 65 6c 61 74 69 6f 6e 73 | has-a r|elations|
|000028b0| 68 69 70 73 0d 0a 20 20 | 20 62 65 69 6e 67 20 63 |hips.. | being c|
|000028c0| 6f 64 65 64 20 75 73 69 | 6e 67 20 4d 49 20 66 6f |oded usi|ng MI fo|
|000028d0| 72 20 63 6f 6e 76 65 6e | 69 65 6e 63 65 2c 20 65 |r conven|ience, e|
|000028e0| 74 63 2e 29 20 61 72 65 | 20 61 6c 72 65 61 64 79 |tc.) are| already|
|000028f0| 20 68 61 6e 64 6c 65 64 | 20 76 65 72 79 0d 0a 20 | handled| very.. |
|00002900| 20 20 77 65 6c 6c 20 69 | 6e 20 41 64 61 20 39 58 | well i|n Ada 9X|
|00002910| 2c 20 69 74 20 69 73 20 | 68 61 72 64 20 74 6f 20 |, it is |hard to |
|00002920| 6a 75 73 74 69 66 79 20 | 67 65 74 74 69 6e 67 20 |justify |getting |
|00002930| 69 6e 74 6f 20 74 68 65 | 20 4d 49 20 6c 61 6e 67 |into the| MI lang|
|00002940| 75 61 67 65 0d 0a 20 20 | 20 64 65 73 69 67 6e 20 |uage.. | design |
|00002950| 66 72 61 79 20 61 74 20 | 61 6c 6c 2e 20 54 68 65 |fray at |all. The|
|00002960| 20 62 61 73 69 63 20 69 | 6e 68 65 72 69 74 61 6e | basic i|nheritan|
|00002970| 63 65 20 6d 6f 64 65 6c | 20 69 6e 20 41 64 61 20 |ce model| in Ada |
|00002980| 39 58 20 69 73 20 73 69 | 6d 70 6c 65 0d 0a 20 20 |9X is si|mple.. |
|00002990| 20 61 6e 64 20 65 6c 65 | 67 61 6e 74 2e 20 57 68 | and ele|gant. Wh|
|000029a0| 79 20 63 6c 75 74 74 65 | 72 20 69 74 20 75 70 20 |y clutte|r it up |
|000029b0| 77 69 74 68 20 61 20 6c | 6f 74 20 6f 66 20 72 65 |with a l|ot of re|
|000029c0| 6c 61 74 69 76 65 6c 79 | 20 61 64 2d 68 6f 63 20 |latively| ad-hoc |
|000029d0| 72 75 6c 65 73 0d 0a 20 | 20 20 74 6f 20 68 61 6e |rules.. | to han|
|000029e0| 64 6c 65 20 6f 6e 65 20 | 70 61 72 74 69 63 75 6c |dle one |particul|
|000029f0| 61 72 20 61 70 70 72 6f | 61 63 68 20 74 6f 20 4d |ar appro|ach to M|
|00002a00| 49 3f 20 46 6f 72 20 74 | 68 65 20 72 61 72 65 20 |I? For t|he rare |
|00002a10| 63 61 73 65 73 20 77 68 | 65 72 65 20 4d 49 0d 0a |cases wh|ere MI..|
|00002a20| 20 20 20 69 73 20 72 65 | 61 6c 6c 79 20 63 72 69 | is re|ally cri|
|00002a30| 74 69 63 61 6c 2c 20 74 | 68 65 20 6c 61 73 74 20 |tical, t|he last |
|00002a40| 74 68 69 6e 67 20 74 68 | 65 20 70 72 6f 67 72 61 |thing th|e progra|
|00002a50| 6d 6d 65 72 20 77 61 6e | 74 73 20 69 6e 20 74 68 |mmer wan|ts in th|
|00002a60| 65 0d 0a 20 20 20 6c 61 | 6e 67 75 61 67 65 20 69 |e.. la|nguage i|
|00002a70| 73 20 74 68 65 20 22 77 | 72 6f 6e 67 22 20 4d 49 |s the "w|rong" MI|
|00002a80| 20 61 70 70 72 6f 61 63 | 68 20 62 75 69 6c 74 20 | approac|h built |
|00002a90| 69 6e 2e 0d 0a 0d 0a 20 | 20 20 53 6f 20 74 68 65 |in..... | So the|
|00002aa0| 20 62 61 73 69 63 20 61 | 6e 73 77 65 72 20 69 73 | basic a|nswer is|
|00002ab0| 20 74 68 61 74 20 61 74 | 20 74 68 69 73 20 70 6f | that at| this po|
|00002ac0| 69 6e 74 20 69 6e 20 74 | 68 65 20 65 76 6f 6c 75 |int in t|he evolu|
|00002ad0| 74 69 6f 6e 20 6f 66 20 | 4f 4f 0d 0a 20 20 20 6c |tion of |OO.. l|
|00002ae0| 61 6e 67 75 61 67 65 20 | 64 65 73 69 67 6e 2c 20 |anguage |design, |
|00002af0| 69 74 20 73 65 65 6d 65 | 64 20 77 69 73 65 72 20 |it seeme|d wiser |
|00002b00| 74 6f 20 70 72 6f 76 69 | 64 65 20 4d 49 20 62 75 |to provi|de MI bu|
|00002b10| 69 6c 64 69 6e 67 20 62 | 6c 6f 63 6b 73 2c 20 72 |ilding b|locks, r|
|00002b20| 61 74 68 65 72 0d 0a 20 | 20 20 74 68 61 6e 20 74 |ather.. | than t|
|00002b30| 6f 20 66 6f 69 73 74 20 | 74 68 65 20 77 72 6f 6e |o foist |the wron|
|00002b40| 67 20 61 70 70 72 6f 61 | 63 68 20 6f 6e 20 74 68 |g approa|ch on th|
|00002b50| 65 20 70 72 6f 67 72 61 | 6d 6d 65 72 2c 20 61 6e |e progra|mmer, an|
|00002b60| 64 20 62 65 20 72 65 67 | 72 65 74 74 69 6e 67 0d |d be reg|retting.|
|00002b70| 0a 20 20 20 69 74 20 61 | 6e 64 20 77 6f 72 6b 69 |. it a|nd worki|
|00002b80| 6e 67 20 61 72 6f 75 6e | 64 20 69 74 20 66 6f 72 |ng aroun|d it for|
|00002b90| 20 79 65 61 72 73 20 74 | 6f 20 63 6f 6d 65 2e 0d | years t|o come..|
|00002ba0| 0a 0d 0a 20 20 20 50 65 | 72 68 61 70 73 20 5b 44 |... Pe|rhaps [D|
|00002bb0| 6f 75 67 6c 61 73 20 41 | 72 6e 64 74 5d 20 73 61 |ouglas A|rndt] sa|
|00002bc0| 69 64 20 69 74 20 62 65 | 73 74 2e 2e 2e 0d 0a 0d |id it be|st......|
|00002bd0| 0a 20 20 20 20 20 46 69 | 6e 61 6c 20 6e 6f 74 65 |. Fi|nal note|
|00002be0| 3a 20 69 6e 68 65 72 69 | 74 61 6e 63 65 20 69 73 |: inheri|tance is|
|00002bf0| 20 6f 76 65 72 72 61 74 | 65 64 2c 20 65 73 70 65 | overrat|ed, espe|
|00002c00| 63 69 61 6c 6c 79 20 4d | 49 2e 20 2e 2e 2e 0d 0a |cially M|I. .....|
|00002c10| 0d 0a 0d 0a 20 20 20 49 | 66 20 74 68 65 20 6f 6e |.... I|f the on|
|00002c20| 6c 79 20 6f 72 20 70 72 | 69 6d 61 72 79 20 74 79 |ly or pr|imary ty|
|00002c30| 70 65 20 63 6f 6d 70 6f | 73 69 74 69 6f 6e 20 6d |pe compo|sition m|
|00002c40| 65 63 68 61 6e 69 73 6d | 20 69 6e 20 74 68 65 20 |echanism| in the |
|00002c50| 6c 61 6e 67 75 61 67 65 | 20 69 73 0d 0a 20 20 20 |language| is.. |
|00002c60| 62 61 73 65 64 20 6f 6e | 20 69 6e 68 65 72 69 74 |based on| inherit|
|00002c70| 61 6e 63 65 2c 20 74 68 | 65 6e 20 62 79 20 61 6c |ance, th|en by al|
|00002c80| 6c 20 6d 65 61 6e 73 2c | 20 6c 6f 61 64 20 69 74 |l means,| load it|
|00002c90| 20 75 70 2e 20 42 75 74 | 20 41 64 61 20 39 58 0d | up. But| Ada 9X.|
|00002ca0| 0a 20 20 20 70 72 6f 76 | 69 64 65 73 20 73 65 76 |. prov|ides sev|
|00002cb0| 65 72 61 6c 20 65 66 66 | 69 63 69 65 6e 74 20 61 |eral eff|icient a|
|00002cc0| 6e 64 20 66 6c 65 78 69 | 62 6c 65 20 74 79 70 65 |nd flexi|ble type|
|00002cd0| 20 63 6f 6d 70 6f 73 69 | 74 69 6f 6e 20 6d 65 63 | composi|tion mec|
|00002ce0| 68 61 6e 69 73 6d 73 2c | 0d 0a 20 20 20 61 6e 64 |hanisms,|.. and|
|00002cf0| 20 74 68 65 72 65 20 69 | 73 20 6e 6f 20 6e 65 65 | there i|s no nee|
|00002d00| 64 20 74 6f 20 6f 76 65 | 72 62 75 72 64 65 6e 20 |d to ove|rburden |
|00002d10| 69 6e 68 65 72 69 74 61 | 6e 63 65 20 77 69 74 68 |inherita|nce with|
|00002d20| 20 75 6e 6e 65 63 65 73 | 73 61 72 79 20 61 6e 64 | unneces|sary and|
|00002d30| 0d 0a 20 20 20 63 6f 6d | 70 6c 69 63 61 74 65 64 |.. com|plicated|
|00002d40| 20 62 61 67 67 61 67 65 | 2e 0d 0a 0d 0a 0d 0a 35 | baggage|.......5|
|00002d50| 2e 35 3a 20 57 68 79 20 | 61 72 65 20 43 6f 6e 74 |.5: Why |are Cont|
|00002d60| 72 6f 6c 6c 65 64 20 74 | 79 70 65 73 20 73 6f 2c |rolled t|ypes so,|
|00002d70| 20 77 65 6c 6c 2c 20 73 | 74 72 61 6e 67 65 3f 0d | well, s|trange?.|
|00002d80| 0a 0d 0a 20 20 20 28 54 | 75 63 6b 65 72 20 54 61 |... (T|ucker Ta|
|00002d90| 66 74 20 72 65 73 70 6f | 6e 64 73 29 3a 0d 0a 0d |ft respo|nds):...|
|00002da0| 0a 20 20 20 57 65 20 63 | 6f 6e 73 69 64 65 72 65 |. We c|onsidere|
|00002db0| 64 20 6d 61 6e 79 20 61 | 70 70 72 6f 61 63 68 65 |d many a|pproache|
|00002dc0| 73 20 74 6f 20 75 73 65 | 72 2d 64 65 66 69 6e 65 |s to use|r-define|
|00002dd0| 64 20 66 69 6e 61 6c 69 | 7a 61 74 69 6f 6e 20 61 |d finali|zation a|
|00002de0| 6e 64 0d 0a 20 20 20 75 | 73 65 72 2d 64 65 66 69 |nd.. u|ser-defi|
|00002df0| 6e 65 64 20 61 73 73 69 | 67 6e 6d 65 6e 74 2e 20 |ned assi|gnment. |
|00002e00| 41 64 61 20 70 72 65 73 | 65 6e 74 73 20 63 68 61 |Ada pres|ents cha|
|00002e10| 6c 6c 65 6e 67 65 73 20 | 74 68 61 74 20 6d 61 6b |llenges |that mak|
|00002e20| 65 20 69 74 20 68 61 72 | 64 65 72 0d 0a 20 20 20 |e it har|der.. |
|00002e30| 74 6f 20 64 65 66 69 6e | 65 20 61 73 73 69 67 6e |to defin|e assign|
|00002e40| 6d 65 6e 74 20 74 68 61 | 6e 20 69 6e 20 6f 74 68 |ment tha|n in oth|
|00002e50| 65 72 20 6c 61 6e 67 75 | 61 67 65 73 2c 20 62 65 |er langu|ages, be|
|00002e60| 63 61 75 73 65 20 61 73 | 73 69 67 6e 6d 65 6e 74 |cause as|signment|
|00002e70| 20 69 73 0d 0a 20 20 20 | 75 73 65 64 20 69 6d 70 | is.. |used imp|
|00002e80| 6c 69 63 69 74 6c 79 20 | 69 6e 20 73 65 76 65 72 |licitly |in sever|
|00002e90| 61 6c 20 6f 70 65 72 61 | 74 69 6f 6e 73 20 28 62 |al opera|tions (b|
|00002ea0| 79 2d 63 6f 70 79 20 70 | 61 72 61 6d 65 74 65 72 |y-copy p|arameter|
|00002eb0| 20 70 61 73 73 69 6e 67 | 2c 0d 0a 20 20 20 66 75 | passing|,.. fu|
|00002ec0| 6e 63 74 69 6f 6e 20 72 | 65 74 75 72 6e 2c 20 61 |nction r|eturn, a|
|00002ed0| 67 67 72 65 67 61 74 65 | 73 2c 20 6f 62 6a 65 63 |ggregate|s, objec|
|00002ee0| 74 20 69 6e 69 74 69 61 | 6c 69 7a 61 74 69 6f 6e |t initia|lization|
|00002ef0| 2c 20 69 6e 69 74 69 61 | 6c 69 7a 65 64 0d 0a 20 |, initia|lized.. |
|00002f00| 20 20 61 6c 6c 6f 63 61 | 74 6f 72 73 2c 20 65 74 | alloca|tors, et|
|00002f10| 63 2e 29 2c 20 61 6e 64 | 20 62 65 63 61 75 73 65 |c.), and| because|
|00002f20| 20 41 64 61 20 68 61 73 | 20 74 79 70 65 73 20 77 | Ada has| types w|
|00002f30| 68 6f 73 65 20 73 65 74 | 20 6f 66 20 63 6f 6d 70 |hose set| of comp|
|00002f40| 6f 6e 65 6e 74 73 0d 0a | 20 20 20 63 61 6e 20 62 |onents..| can b|
|00002f50| 65 20 63 68 61 6e 67 65 | 64 20 61 73 20 61 20 72 |e change|d as a r|
|00002f60| 65 73 75 6c 74 20 6f 66 | 20 61 6e 20 61 73 73 69 |esult of| an assi|
|00002f70| 67 6e 6d 65 6e 74 2e 0d | 0a 0d 0a 20 20 20 46 6f |gnment..|... Fo|
|00002f80| 72 20 65 78 61 6d 70 6c | 65 3a 0d 0a 0d 0a 20 20 |r exampl|e:.... |
|00002f90| 20 20 20 74 79 70 65 20 | 54 20 28 44 20 3a 20 42 | type |T (D : B|
|00002fa0| 6f 6f 6c 65 61 6e 20 3a | 3d 20 46 61 6c 73 65 29 |oolean :|= False)|
|00002fb0| 20 69 73 20 72 65 63 6f | 72 64 0d 0a 20 20 20 20 | is reco|rd.. |
|00002fc0| 20 20 20 63 61 73 65 20 | 44 20 69 73 0d 0a 20 20 | case |D is.. |
|00002fd0| 20 20 20 20 20 20 20 77 | 68 65 6e 20 46 61 6c 73 | w|hen Fals|
|00002fe0| 65 20 3d 3e 20 6e 75 6c | 6c 3b 0d 0a 20 20 20 20 |e => nul|l;.. |
|00002ff0| 20 20 20 20 20 77 68 65 | 6e 20 54 72 75 65 20 3d | whe|n True =|
|00003000| 3e 20 48 20 3a 20 49 6e | 5f 48 61 6e 64 73 3b 0d |> H : In|_Hands;.|
|00003010| 0a 20 20 20 20 20 20 20 | 65 6e 64 20 63 61 73 65 |. |end case|
|00003020| 3b 0d 0a 20 20 20 20 20 | 65 6e 64 20 72 65 63 6f |;.. |end reco|
|00003030| 72 64 3b 0d 0a 0d 0a 20 | 20 20 20 20 58 2c 5a 20 |rd;.... | X,Z |
|00003040| 3a 20 54 3b 0d 0a 20 20 | 20 20 20 59 20 3a 20 54 |: T;.. | Y : T|
|00003050| 20 3a 3d 20 28 54 72 75 | 65 2c 20 48 20 3d 3e 20 | := (Tru|e, H => |
|00003060| 2e 2e 2e 29 3b 0d 0a 0d | 0a 20 20 20 20 20 2e 2e |...);...|. ..|
|00003070| 2e 0d 0a 0d 0a 20 20 20 | 20 20 58 20 3a 3d 20 59 |..... | X := Y|
|00003080| 3b 20 20 20 2d 2d 20 22 | 58 2e 48 22 20 63 6f 6d |; -- "|X.H" com|
|00003090| 70 6f 6e 65 6e 74 20 63 | 6f 6d 69 6e 67 20 69 6e |ponent c|oming in|
|000030a0| 74 6f 20 65 78 69 73 74 | 65 6e 63 65 0d 0a 20 20 |to exist|ence.. |
|000030b0| 20 20 20 59 20 3a 3d 20 | 5a 3b 20 20 20 2d 2d 20 | Y := |Z; -- |
|000030c0| 22 59 2e 48 22 20 63 6f | 6d 70 6f 6e 65 6e 74 20 |"Y.H" co|mponent |
|000030d0| 67 6f 69 6e 67 20 6f 75 | 74 20 6f 66 20 65 78 69 |going ou|t of exi|
|000030e0| 73 74 65 6e 63 65 0d 0a | 0d 0a 0d 0a 20 20 20 57 |stence..|.... W|
|000030f0| 69 74 68 20 61 20 74 79 | 70 65 20 6c 69 6b 65 20 |ith a ty|pe like |
|00003100| 74 68 65 20 6f 6e 65 20 | 61 62 6f 76 65 2c 20 74 |the one |above, t|
|00003110| 68 65 72 65 20 61 72 65 | 20 63 6f 6d 70 6f 6e 65 |here are| compone|
|00003120| 6e 74 73 20 74 68 61 74 | 20 63 61 6e 20 63 6f 6d |nts that| can com|
|00003130| 65 20 61 6e 64 0d 0a 20 | 20 20 67 6f 20 61 73 20 |e and.. | go as |
|00003140| 61 20 72 65 73 75 6c 74 | 20 6f 66 20 61 73 73 69 |a result| of assi|
|00003150| 67 6e 6d 65 6e 74 2e 20 | 54 68 65 20 6d 6f 73 74 |gnment. |The most|
|00003160| 20 6f 62 76 69 6f 75 73 | 20 64 65 66 69 6e 69 74 | obvious| definit|
|00003170| 69 6f 6e 20 6f 66 0d 0a | 20 20 20 61 73 73 69 67 |ion of..| assig|
|00003180| 6e 6d 65 6e 74 20 77 6f | 75 6c 64 20 62 65 3a 0d |nment wo|uld be:.|
|00003190| 0a 0d 0a 20 20 20 20 20 | 70 72 6f 63 65 64 75 72 |... |procedur|
|000031a0| 65 20 22 3a 3d 22 20 28 | 4c 65 66 74 20 3a 20 69 |e ":=" (|Left : i|
|000031b0| 6e 20 6f 75 74 20 49 6e | 5f 48 61 6e 64 73 3b 20 |n out In|_Hands; |
|000031c0| 52 69 67 68 74 20 3a 20 | 69 6e 20 49 6e 5f 48 61 |Right : |in In_Ha|
|000031d0| 6e 64 73 29 3b 0d 0a 0d | 0a 0d 0a 20 20 20 55 6e |nds);...|... Un|
|000031e0| 66 6f 72 74 75 6e 61 74 | 65 6c 79 2c 20 74 68 69 |fortunat|ely, thi|
|000031f0| 73 20 77 6f 75 6c 64 6e | 27 74 20 77 6f 72 6b 20 |s wouldn|'t work |
|00003200| 66 6f 72 20 74 68 65 20 | 22 48 22 20 63 6f 6d 70 |for the |"H" comp|
|00003210| 6f 6e 65 6e 74 2c 20 62 | 65 63 61 75 73 65 20 74 |onent, b|ecause t|
|00003220| 68 65 72 65 0d 0a 20 20 | 20 69 73 20 6e 6f 20 70 |here.. | is no p|
|00003230| 72 65 65 78 69 73 74 69 | 6e 67 20 22 49 6e 5f 48 |reexisti|ng "In_H|
|00003240| 61 6e 64 73 22 20 63 6f | 6d 70 6f 6e 65 6e 74 20 |ands" co|mponent |
|00003250| 74 6f 20 62 65 20 61 73 | 73 69 67 6e 65 64 20 69 |to be as|signed i|
|00003260| 6e 74 6f 20 69 6e 20 74 | 68 65 0d 0a 20 20 20 66 |nto in t|he.. f|
|00003270| 69 72 73 74 20 63 61 73 | 65 2c 20 61 6e 64 20 69 |irst cas|e, and i|
|00003280| 6e 20 74 68 65 20 73 65 | 63 6f 6e 64 20 63 61 73 |n the se|cond cas|
|00003290| 65 2c 20 74 68 65 72 65 | 20 69 73 20 6e 6f 20 22 |e, there| is no "|
|000032a0| 49 6e 5f 48 61 6e 64 73 | 22 20 63 6f 6d 70 6f 6e |In_Hands|" compon|
|000032b0| 65 6e 74 0d 0a 20 20 20 | 74 6f 20 61 73 73 69 67 |ent.. |to assig|
|000032c0| 6e 20 22 66 72 6f 6d 2e | 22 0d 0a 0d 0a 20 20 20 |n "from.|".... |
|000032d0| 54 68 65 72 65 66 6f 72 | 65 2c 20 77 65 20 64 65 |Therefor|e, we de|
|000032e0| 63 69 64 65 64 20 74 6f | 20 64 65 63 6f 6d 70 6f |cided to| decompo|
|000032f0| 73 65 20 74 68 65 20 6f | 70 65 72 61 74 69 6f 6e |se the o|peration|
|00003300| 20 6f 66 20 61 73 73 69 | 67 6e 6d 65 6e 74 20 69 | of assi|gnment i|
|00003310| 6e 74 6f 0d 0a 20 20 20 | 73 65 70 61 72 61 62 6c |nto.. |separabl|
|00003320| 65 20 70 69 65 63 65 73 | 3a 20 66 69 6e 61 6c 69 |e pieces|: finali|
|00003330| 7a 61 74 69 6f 6e 20 6f | 66 20 74 68 65 20 6c 65 |zation o|f the le|
|00003340| 66 74 20 68 61 6e 64 20 | 73 69 64 65 3b 20 73 69 |ft hand |side; si|
|00003350| 6d 70 6c 65 20 63 6f 70 | 79 69 6e 67 0d 0a 20 20 |mple cop|ying.. |
|00003360| 20 6f 66 20 74 68 65 20 | 64 61 74 61 20 66 72 6f | of the |data fro|
|00003370| 6d 20 74 68 65 20 72 69 | 67 68 74 20 68 61 6e 64 |m the ri|ght hand|
|00003380| 20 73 69 64 65 20 74 6f | 20 74 68 65 20 6c 65 66 | side to| the lef|
|00003390| 74 20 68 61 6e 64 20 73 | 69 64 65 3b 20 61 6e 64 |t hand s|ide; and|
|000033a0| 20 74 68 65 6e 0d 0a 20 | 20 20 61 64 6a 75 73 74 | then.. | adjust|
|000033b0| 6d 65 6e 74 20 6f 66 20 | 74 68 65 20 6e 65 77 20 |ment of |the new |
|000033c0| 6c 65 66 74 20 68 61 6e | 64 20 73 69 64 65 2e 20 |left han|d side. |
|000033d0| 4f 74 68 65 72 20 64 65 | 63 6f 6d 70 6f 73 69 74 |Other de|composit|
|000033e0| 69 6f 6e 73 20 61 72 65 | 0d 0a 20 20 20 70 72 6f |ions are|.. pro|
|000033f0| 62 61 62 6c 79 20 70 6f | 73 73 69 62 6c 65 2c 20 |bably po|ssible, |
|00003400| 62 75 74 20 74 68 65 79 | 20 67 65 6e 65 72 61 6c |but they| general|
|00003410| 6c 79 20 73 75 66 66 65 | 72 20 66 72 6f 6d 20 6e |ly suffe|r from n|
|00003420| 6f 74 20 62 65 69 6e 67 | 20 65 61 73 69 6c 79 0d |ot being| easily.|
|00003430| 0a 20 20 20 63 6f 6d 70 | 6f 73 61 62 6c 65 2c 20 |. comp|osable, |
|00003440| 6f 72 20 6e 6f 74 20 68 | 61 6e 64 6c 69 6e 67 20 |or not h|andling |
|00003450| 73 69 74 75 61 74 69 6f | 6e 73 20 6c 69 6b 65 20 |situatio|ns like |
|00003460| 74 68 65 20 76 61 72 69 | 61 6e 74 20 72 65 63 6f |the vari|ant reco|
|00003470| 72 64 20 61 62 6f 76 65 | 2e 0d 0a 0d 0a 20 20 20 |rd above|..... |
|00003480| 49 6d 61 67 69 6e 65 20 | 61 20 66 75 6e 63 74 69 |Imagine |a functi|
|00003490| 6f 6e 20 6e 61 6d 65 64 | 20 22 3a 3d 22 20 74 68 |on named| ":=" th|
|000034a0| 61 74 20 72 65 74 75 72 | 6e 73 20 61 20 63 6f 70 |at retur|ns a cop|
|000034b0| 79 20 6f 66 20 69 74 73 | 20 69 6e 20 70 61 72 61 |y of its| in para|
|000034c0| 6d 65 74 65 72 2e 0d 0a | 20 20 20 54 6f 20 64 6f |meter...| To do|
|000034d0| 20 61 6e 79 74 68 69 6e | 67 20 69 6e 74 65 72 65 | anythin|g intere|
|000034e0| 73 74 69 6e 67 20 69 74 | 20 77 69 6c 6c 20 68 61 |sting it| will ha|
|000034f0| 76 65 20 74 6f 20 63 6f | 70 79 20 74 68 65 20 69 |ve to co|py the i|
|00003500| 6e 20 70 61 72 61 6d 65 | 74 65 72 20 69 6e 74 6f |n parame|ter into|
|00003510| 0d 0a 20 20 20 61 20 6c | 6f 63 61 6c 20 76 61 72 |.. a l|ocal var|
|00003520| 69 61 62 6c 65 2c 20 61 | 6e 64 20 74 68 65 6e 20 |iable, a|nd then |
|00003530| 22 66 69 64 64 6c 65 22 | 20 77 69 74 68 20 74 68 |"fiddle"| with th|
|00003540| 61 74 20 6c 6f 63 61 6c | 20 76 61 72 69 61 62 6c |at local| variabl|
|00003550| 65 0d 0a 20 20 20 28 65 | 73 73 65 6e 74 69 61 6c |e.. (e|ssential|
|00003560| 6c 79 20 77 68 61 74 20 | 22 41 64 6a 75 73 74 22 |ly what |"Adjust"|
|00003570| 20 64 6f 65 73 29 2c 20 | 61 6e 64 20 74 68 65 6e | does), |and then|
|00003580| 20 72 65 74 75 72 6e 20 | 74 68 61 74 20 6c 6f 63 | return |that loc|
|00003590| 61 6c 20 76 61 72 69 61 | 62 6c 65 0d 0a 20 20 20 |al varia|ble.. |
|000035a0| 28 77 68 69 63 68 20 77 | 69 6c 6c 20 6d 61 6b 65 |(which w|ill make|
|000035b0| 20 79 65 74 20 61 6e 6f | 74 68 65 72 20 63 6f 70 | yet ano|ther cop|
|000035c0| 79 29 2e 20 54 68 65 20 | 72 65 74 75 72 6e 65 64 |y). The |returned|
|000035d0| 20 72 65 73 75 6c 74 20 | 77 69 6c 6c 20 68 61 76 | result |will hav|
|000035e0| 65 20 74 6f 0d 0a 20 20 | 20 62 65 20 70 75 74 20 |e to.. | be put |
|000035f0| 62 61 63 6b 20 69 6e 74 | 6f 20 74 68 65 20 64 65 |back int|o the de|
|00003600| 73 69 72 65 64 20 70 6c | 61 63 65 20 28 77 68 69 |sired pl|ace (whi|
|00003610| 63 68 20 6d 69 67 68 74 | 20 6d 61 6b 65 20 79 65 |ch might| make ye|
|00003620| 74 20 61 6e 6f 74 68 65 | 72 0d 0a 20 20 20 63 6f |t anothe|r.. co|
|00003630| 70 79 29 2e 20 46 6f 72 | 20 61 20 6c 61 72 67 65 |py). For| a large|
|00003640| 20 6f 62 6a 65 63 74 2c | 20 74 68 69 73 20 6d 69 | object,| this mi|
|00003650| 67 68 74 20 69 6e 76 6f | 6c 76 65 20 73 65 76 65 |ght invo|lve seve|
|00003660| 72 61 6c 20 65 78 74 72 | 61 20 63 6f 70 69 65 73 |ral extr|a copies|
|00003670| 2e 0d 0a 0d 0a 20 20 20 | 42 79 20 68 61 76 69 6e |..... |By havin|
|00003680| 67 20 74 68 65 20 75 73 | 65 72 20 77 72 69 74 65 |g the us|er write|
|00003690| 20 6a 75 73 74 20 74 68 | 61 74 20 70 61 72 74 20 | just th|at part |
|000036a0| 6f 66 20 74 68 65 20 6f | 70 65 72 61 74 69 6f 6e |of the o|peration|
|000036b0| 20 74 68 61 74 0d 0a 20 | 20 20 22 66 69 64 64 6c | that.. | "fiddl|
|000036c0| 65 73 22 20 77 69 74 68 | 20 74 68 65 20 72 65 73 |es" with| the res|
|000036d0| 75 6c 74 20 61 66 74 65 | 72 20 6d 61 6b 69 6e 67 |ult afte|r making|
|000036e0| 20 61 20 63 6f 70 79 2c | 20 77 65 20 61 6c 6c 6f | a copy,| we allo|
|000036f0| 77 20 74 68 65 0d 0a 20 | 20 20 69 6d 70 6c 65 6d |w the.. | implem|
|00003700| 65 6e 74 61 74 69 6f 6e | 20 74 6f 20 65 6c 69 6d |entation| to elim|
|00003710| 69 6e 61 74 65 20 72 65 | 64 75 6e 64 61 6e 74 20 |inate re|dundant |
|00003720| 63 6f 70 79 69 6e 67 2e | 20 46 75 72 74 68 65 72 |copying.| Further|
|00003730| 6d 6f 72 65 2c 20 73 6f | 6d 65 0d 0a 20 20 20 75 |more, so|me.. u|
|00003740| 73 65 72 2d 64 65 66 69 | 6e 65 64 20 72 65 70 72 |ser-defi|ned repr|
|00003750| 65 73 65 6e 74 61 74 69 | 6f 6e 73 20 6d 69 67 68 |esentati|ons migh|
|00003760| 74 20 62 65 20 70 6f 73 | 69 74 69 6f 6e 20 64 65 |t be pos|ition de|
|00003770| 70 65 6e 64 65 6e 74 2e | 20 54 68 61 74 20 69 73 |pendent.| That is|
|00003780| 2c 20 74 68 65 0d 0a 20 | 20 20 66 69 6e 61 6c 20 |, the.. | final |
|00003790| 22 66 69 64 64 6c 69 6e | 67 22 20 68 61 73 20 74 |"fiddlin|g" has t|
|000037a0| 6f 20 74 61 6b 65 20 70 | 6c 61 63 65 20 6f 6e 20 |o take p|lace on |
|000037b0| 74 68 65 20 6f 62 6a 65 | 63 74 20 69 6e 20 69 74 |the obje|ct in it|
|000037c0| 73 20 66 69 6e 61 6c 0d | 0a 20 20 20 6c 6f 63 61 |s final.|. loca|
|000037d0| 74 69 6f 6e 2e 20 46 6f | 72 20 65 78 61 6d 70 6c |tion. Fo|r exampl|
|000037e0| 65 2c 20 6f 6e 65 20 6d | 69 67 68 74 20 77 61 6e |e, one m|ight wan|
|000037f0| 74 20 74 68 65 20 6f 62 | 6a 65 63 74 20 74 6f 20 |t the ob|ject to |
|00003800| 70 6f 69 6e 74 20 74 6f | 20 69 74 73 65 6c 66 2e |point to| itself.|
|00003810| 0d 0a 20 20 20 49 66 20 | 74 68 65 20 69 6d 70 6c |.. If |the impl|
|00003820| 65 6d 65 6e 74 61 74 69 | 6f 6e 20 63 6f 70 69 65 |ementati|on copie|
|00003830| 73 20 61 6e 20 6f 62 6a | 65 63 74 20 61 66 74 65 |s an obj|ect afte|
|00003840| 72 20 74 68 65 20 75 73 | 65 72 20 63 6f 64 65 20 |r the us|er code |
|00003850| 68 61 73 0d 0a 20 20 20 | 61 64 6a 75 73 74 65 64 |has.. |adjusted|
|00003860| 20 69 74 2c 20 73 75 63 | 68 20 73 65 6c 66 2d 72 | it, suc|h self-r|
|00003870| 65 66 65 72 65 6e 63 65 | 73 20 77 69 6c 6c 20 6e |eference|s will n|
|00003880| 6f 20 6c 6f 6e 67 65 72 | 20 70 6f 69 6e 74 20 74 |o longer| point t|
|00003890| 6f 20 74 68 65 20 72 69 | 67 68 74 0d 0a 20 20 20 |o the ri|ght.. |
|000038a0| 70 6c 61 63 65 2e 0d 0a | 0d 0a 20 20 20 53 6f 2c |place...|.. So,|
|000038b0| 20 61 73 20 75 73 75 61 | 6c 2c 20 6f 6e 63 65 20 | as usua|l, once |
|000038c0| 6f 6e 65 20 67 65 74 73 | 20 69 6e 74 6f 20 77 6f |one gets| into wo|
|000038d0| 72 6b 69 6e 67 20 6f 75 | 74 20 74 68 65 20 64 65 |rking ou|t the de|
|000038e0| 74 61 69 6c 73 20 61 6e | 64 20 61 6c 6c 20 74 68 |tails an|d all th|
|000038f0| 65 0d 0a 20 20 20 69 6e | 74 65 72 61 63 74 69 6f |e.. in|teractio|
|00003900| 6e 73 2c 20 74 68 65 20 | 22 6f 62 76 69 6f 75 73 |ns, the |"obvious|
|00003910| 22 20 70 72 6f 70 6f 73 | 61 6c 20 28 73 75 63 68 |" propos|al (such|
|00003920| 20 61 73 20 61 20 70 72 | 6f 63 65 64 75 72 65 20 | as a pr|ocedure |
|00003930| 22 3a 3d 22 29 20 6e 6f | 0d 0a 20 20 20 6c 6f 6e |":=") no|.. lon|
|00003940| 67 65 72 20 6c 6f 6f 6b | 73 20 6c 69 6b 65 20 74 |ger look|s like t|
|00003950| 68 65 20 62 65 73 74 20 | 61 6e 73 77 65 72 2c 20 |he best |answer, |
|00003960| 61 6e 64 20 74 68 65 20 | 62 65 73 74 20 61 6e 73 |and the |best ans|
|00003970| 77 65 72 20 6f 6e 65 20 | 63 61 6e 20 66 69 6e 64 |wer one |can find|
|00003980| 0d 0a 20 20 20 70 6f 74 | 65 6e 74 69 61 6c 6c 79 |.. pot|entially|
|00003990| 20 6c 6f 6f 6b 73 20 22 | 63 6c 75 6d 73 79 22 20 | looks "|clumsy" |
|000039a0| 28 61 74 20 6c 65 61 73 | 74 20 62 65 66 6f 72 65 |(at leas|t before|
|000039b0| 20 79 6f 75 20 74 72 79 | 20 74 6f 20 77 6f 72 6b | you try| to work|
|000039c0| 20 6f 75 74 20 74 68 65 | 0d 0a 20 20 20 64 65 74 | out the|.. det|
|000039d0| 61 69 6c 73 20 6f 66 20 | 74 68 65 20 61 6c 74 65 |ails of |the alte|
|000039e0| 72 6e 61 74 69 76 65 73 | 29 2e 0d 0a 0d 0a 0d 0a |rnatives|).......|
|000039f0| 35 2e 36 3a 20 57 68 61 | 74 20 64 6f 20 22 63 6f |5.6: Wha|t do "co|
|00003a00| 76 61 72 69 61 6e 63 65 | 22 20 61 6e 64 20 22 63 |variance|" and "c|
|00003a10| 6f 6e 74 72 61 76 61 72 | 69 61 6e 63 65 22 20 6d |ontravar|iance" m|
|00003a20| 65 61 6e 2c 20 61 6e 64 | 20 64 6f 65 73 20 41 64 |ean, and| does Ad|
|00003a30| 61 20 73 75 70 70 6f 72 | 74 0d 0a 65 69 74 68 65 |a suppor|t..eithe|
|00003a40| 72 20 6f 72 20 62 6f 74 | 68 3f 0d 0a 0d 0a 20 20 |r or bot|h?.... |
|00003a50| 20 28 46 72 6f 6d 20 52 | 6f 62 65 72 74 20 4d 61 | (From R|obert Ma|
|00003a60| 72 74 69 6e 29 20 5b 54 | 68 69 73 20 69 73 20 43 |rtin) [T|his is C|
|00003a70| 2b 2b 20 73 74 75 66 66 | 2c 20 69 74 20 73 68 6f |++ stuff|, it sho|
|00003a80| 75 6c 64 20 62 65 20 63 | 6f 6d 70 6c 65 74 65 6c |uld be c|ompletel|
|00003a90| 79 0d 0a 20 20 20 72 65 | 2d 77 72 69 74 74 65 6e |y.. re|-written|
|00003aa0| 20 66 6f 72 20 41 64 61 | 2e 20 2d 2d 4d 4b 5d 0d | for Ada|. --MK].|
|00003ab0| 0a 0d 0a 0d 0a 20 52 3e | 20 63 6f 76 61 72 69 61 |..... R>| covaria|
|00003ac0| 6e 63 65 3a 20 20 22 63 | 68 61 6e 67 65 73 20 77 |nce: "c|hanges w|
|00003ad0| 69 74 68 22 0d 0a 20 52 | 3e 20 63 6f 6e 74 72 61 |ith".. R|> contra|
|00003ae0| 76 61 72 69 61 6e 63 65 | 3a 20 22 63 68 61 6e 67 |variance|: "chang|
|00003af0| 65 73 20 61 67 61 69 6e | 73 74 22 0d 0a 0d 0a 20 |es again|st".... |
|00003b00| 52 3e 20 63 6c 61 73 73 | 20 41 0d 0a 20 52 3e 20 |R> class| A.. R> |
|00003b10| 7b 0d 0a 20 52 3e 20 20 | 20 20 70 75 62 6c 69 63 |{.. R> | public|
|00003b20| 3a 0d 0a 20 52 3e 20 20 | 20 20 20 20 41 2a 20 66 |:.. R> | A* f|
|00003b30| 28 41 2a 29 3b 20 20 20 | 2f 2f 20 6d 65 74 68 6f |(A*); |// metho|
|00003b40| 64 20 6f 66 20 63 6c 61 | 73 73 20 41 2c 20 74 61 |d of cla|ss A, ta|
|00003b50| 6b 65 73 20 41 20 61 72 | 67 75 6d 65 6e 74 20 61 |kes A ar|gument a|
|00003b60| 6e 64 20 72 65 74 75 72 | 6e 73 20 41 0d 0a 20 52 |nd retur|ns A.. R|
|00003b70| 3e 20 20 20 20 20 20 41 | 2a 20 67 28 41 2a 29 3b |> A|* g(A*);|
|00003b80| 20 20 20 2f 2f 20 73 61 | 6d 65 2e 0d 0a 20 52 3e | // sa|me... R>|
|00003b90| 20 7d 3b 0d 0a 0d 0a 20 | 52 3e 20 63 6c 61 73 73 | };.... |R> class|
|00003ba0| 20 42 20 3a 20 70 75 62 | 6c 69 63 20 41 20 2f 2f | B : pub|lic A //|
|00003bb0| 20 63 6c 61 73 73 20 42 | 20 69 73 20 61 20 73 75 | class B| is a su|
|00003bc0| 62 63 6c 61 73 73 20 6f | 66 20 63 6c 61 73 73 20 |bclass o|f class |
|00003bd0| 41 0d 0a 20 52 3e 20 7b | 0d 0a 20 52 3e 20 20 20 |A.. R> {|.. R> |
|00003be0| 70 75 62 6c 69 63 3a 0d | 0a 20 52 3e 20 20 20 20 |public:.|. R> |
|00003bf0| 20 42 2a 20 66 28 42 2a | 29 3b 20 20 2f 2f 20 6d | B* f(B*|); // m|
|00003c00| 65 74 68 6f 64 20 6f 66 | 20 63 6c 61 73 73 20 42 |ethod of| class B|
|00003c10| 20 6f 76 65 72 72 69 64 | 65 73 20 66 20 61 6e 64 | overrid|es f and|
|00003c20| 20 69 73 20 63 6f 76 61 | 72 69 61 6e 74 2e 0d 0a | is cova|riant...|
|00003c30| 20 52 3e 20 20 20 20 20 | 41 2a 20 67 28 41 2a 29 | R> |A* g(A*)|
|00003c40| 3b 20 20 2f 2f 20 6d 65 | 74 68 6f 64 20 6f 66 20 |; // me|thod of |
|00003c50| 63 6c 61 73 73 20 42 20 | 6f 76 65 72 72 69 64 65 |class B |override|
|00003c60| 73 20 67 20 61 6e 64 20 | 69 73 20 63 6f 6e 74 72 |s g and |is contr|
|00003c70| 61 76 61 72 69 61 6e 74 | 2e 0d 0a 20 52 3e 20 7d |avariant|... R> }|
|00003c80| 3b 0d 0a 0d 0a 20 52 3e | 20 54 68 65 20 66 75 6e |;.... R>| The fun|
|00003c90| 63 74 69 6f 6e 20 66 20 | 69 73 20 63 6f 76 61 72 |ction f |is covar|
|00003ca0| 69 61 6e 74 20 62 65 63 | 61 75 73 65 20 74 68 65 |iant bec|ause the|
|00003cb0| 20 74 79 70 65 20 6f 66 | 20 69 74 73 20 72 65 74 | type of| its ret|
|00003cc0| 75 72 6e 20 76 61 6c 75 | 65 20 61 6e 64 0d 0a 20 |urn valu|e and.. |
|00003cd0| 52 3e 20 61 72 67 75 6d | 65 6e 74 20 63 68 61 6e |R> argum|ent chan|
|00003ce0| 67 65 73 20 77 69 74 68 | 20 74 68 65 20 63 6c 61 |ges with| the cla|
|00003cf0| 73 73 20 69 74 20 62 65 | 6c 6f 6e 67 73 20 74 6f |ss it be|longs to|
|00003d00| 2e 20 20 54 68 65 20 66 | 75 6e 63 74 69 6f 6e 20 |. The f|unction |
|00003d10| 67 20 69 73 0d 0a 20 52 | 3e 20 63 6f 6e 74 72 61 |g is.. R|> contra|
|00003d20| 76 61 72 69 61 6e 74 20 | 62 65 63 61 75 73 65 20 |variant |because |
|00003d30| 74 68 65 20 74 79 70 65 | 73 20 6f 66 20 69 74 73 |the type|s of its|
|00003d40| 20 72 65 74 75 72 6e 20 | 76 61 6c 75 65 20 61 6e | return |value an|
|00003d50| 64 20 61 72 67 75 6d 65 | 6e 74 73 20 64 6f 65 73 |d argume|nts does|
|00003d60| 20 6e 6f 74 0d 0a 20 52 | 3e 20 63 68 61 6e 67 65 | not.. R|> change|
|00003d70| 20 77 69 74 68 20 74 68 | 65 20 63 6c 61 73 73 20 | with th|e class |
|00003d80| 69 74 20 62 65 6c 6f 6e | 67 73 20 74 6f 2e 0d 0a |it belon|gs to...|
|00003d90| 0d 0a 0d 0a 20 20 20 41 | 63 74 75 61 6c 6c 79 2c |.... A|ctually,|
|00003da0| 20 49 20 77 6f 75 6c 64 | 20 63 61 6c 6c 20 67 28 | I would| call g(|
|00003db0| 29 20 69 6e 76 61 72 69 | 61 6e 74 2e 20 49 66 20 |) invari|ant. If |
|00003dc0| 79 6f 75 20 6c 6f 6f 6b | 20 69 6e 20 53 61 74 68 |you look| in Sath|
|00003dd0| 65 72 2c 20 28 6f 6e 65 | 20 6f 66 0d 0a 20 20 20 |er, (one| of.. |
|00003de0| 74 68 65 20 70 72 69 6e | 63 69 70 6c 65 20 6c 61 |the prin|ciple la|
|00003df0| 6e 67 75 61 67 65 73 20 | 77 69 74 68 20 63 6f 6e |nguages |with con|
|00003e00| 74 72 61 76 61 72 69 61 | 6e 63 65 29 2c 20 79 6f |travaria|nce), yo|
|00003e10| 75 20 77 69 6c 6c 20 73 | 65 65 20 74 68 61 74 20 |u will s|ee that |
|00003e20| 74 68 65 0d 0a 20 20 20 | 6d 65 74 68 6f 64 20 69 |the.. |method i|
|00003e30| 6e 20 74 68 65 20 64 65 | 73 63 65 6e 64 61 6e 74 |n the de|scendant|
|00003e40| 20 63 6c 61 73 73 20 61 | 63 74 75 61 6c 6c 79 20 | class a|ctually |
|00003e50| 63 61 6e 20 68 61 76 65 | 20 61 72 67 75 6d 65 6e |can have| argumen|
|00003e60| 74 73 20 74 68 61 74 20 | 61 72 65 0d 0a 20 20 20 |ts that |are.. |
|00003e70| 73 75 70 65 72 63 6c 61 | 73 73 65 73 20 6f 66 20 |supercla|sses of |
|00003e80| 74 68 65 20 61 72 67 75 | 6d 65 6e 74 73 20 6f 66 |the argu|ments of|
|00003e90| 20 69 74 73 20 70 61 72 | 65 6e 74 2e 20 53 6f 20 | its par|ent. So |
|00003ea0| 66 6f 72 20 65 78 61 6d | 70 6c 65 3a 0d 0a 0d 0a |for exam|ple:....|
|00003eb0| 63 6c 61 73 73 20 41 20 | 3a 20 70 75 62 6c 69 63 |class A |: public|
|00003ec0| 20 52 4f 4f 54 0d 0a 7b | 0d 0a 20 20 20 70 75 62 | ROOT..{|.. pub|
|00003ed0| 6c 69 63 3a 0d 0a 20 20 | 20 20 20 41 2a 20 66 28 |lic:.. | A* f(|
|00003ee0| 41 2a 29 3b 20 20 20 2f | 2f 20 6d 65 74 68 6f 64 |A*); /|/ method|
|00003ef0| 20 6f 66 20 63 6c 61 73 | 73 20 41 2c 20 74 61 6b | of clas|s A, tak|
|00003f00| 65 73 20 41 20 61 72 67 | 75 6d 65 6e 74 20 61 6e |es A arg|ument an|
|00003f10| 64 20 72 65 74 75 72 6e | 73 20 41 0d 0a 20 20 20 |d return|s A.. |
|00003f20| 20 20 41 2a 20 67 28 41 | 2a 29 3b 20 20 20 2f 2f | A* g(A|*); //|
|00003f30| 20 73 61 6d 65 2e 0d 0a | 7d 3b 0d 0a 0d 0a 63 6c | same...|};....cl|
|00003f40| 61 73 73 20 42 20 3a 20 | 70 75 62 6c 69 63 20 41 |ass B : |public A|
|00003f50| 20 2f 2f 20 63 6c 61 73 | 73 20 42 20 69 73 20 61 | // clas|s B is a|
|00003f60| 20 73 75 62 63 6c 61 73 | 73 20 6f 66 20 63 6c 61 | subclas|s of cla|
|00003f70| 73 73 20 41 0d 0a 7b 0d | 0a 20 20 70 75 62 6c 69 |ss A..{.|. publi|
|00003f80| 63 3a 0d 0a 20 20 20 20 | 42 2a 20 66 28 42 2a 29 |c:.. |B* f(B*)|
|00003f90| 3b 20 20 2f 2f 20 6d 65 | 74 68 6f 64 20 6f 66 20 |; // me|thod of |
|00003fa0| 63 6c 61 73 73 20 42 20 | 6f 76 65 72 72 69 64 65 |class B |override|
|00003fb0| 73 20 66 20 61 6e 64 20 | 69 73 20 63 6f 76 61 72 |s f and |is covar|
|00003fc0| 69 61 6e 74 2e 0d 0a 20 | 20 20 20 52 4f 4f 54 2a |iant... | ROOT*|
|00003fd0| 20 67 28 52 4f 4f 54 2a | 29 3b 20 20 2f 2f 20 6d | g(ROOT*|); // m|
|00003fe0| 65 74 68 6f 64 20 6f 66 | 20 63 6c 61 73 73 20 42 |ethod of| class B|
|00003ff0| 20 6f 76 65 72 72 69 64 | 65 73 20 67 20 61 6e 64 | overrid|es g and|
|00004000| 20 69 73 20 63 6f 6e 74 | 72 61 76 61 72 69 61 6e | is cont|ravarian|
|00004010| 74 2e 0d 0a 7d 3b 0d 0a | 0d 0a 0d 0a 20 20 20 54 |t...};..|.... T|
|00004020| 6f 20 6d 79 20 6b 6e 6f | 77 6c 65 64 67 65 20 74 |o my kno|wledge t|
|00004030| 68 65 20 75 73 65 73 20 | 66 6f 72 20 63 6f 6e 74 |he uses |for cont|
|00004040| 72 61 76 61 72 69 61 6e | 63 65 20 61 72 65 20 72 |ravarian|ce are r|
|00004050| 61 72 65 20 6f 72 20 6e | 6f 6e 65 78 69 73 74 65 |are or n|onexiste|
|00004060| 6e 74 2e 0d 0a 20 20 20 | 28 41 6e 79 6f 6e 65 3f |nt... |(Anyone?|
|00004070| 29 2e 20 49 74 20 6a 75 | 73 74 20 6d 61 6b 65 73 |). It ju|st makes|
|00004080| 20 74 68 65 20 72 75 6c | 65 73 20 65 61 73 79 20 | the rul|es easy |
|00004090| 66 6f 72 20 74 68 65 20 | 63 6f 6d 70 69 6c 65 72 |for the |compiler|
|000040a0| 20 74 6f 20 74 79 70 65 | 0d 0a 20 20 20 63 68 65 | to type|.. che|
|000040b0| 63 6b 2e 20 4f 6e 20 74 | 68 65 20 6f 74 68 65 72 |ck. On t|he other|
|000040c0| 20 68 61 6e 64 2c 20 63 | 6f 2d 76 61 72 69 61 6e | hand, c|o-varian|
|000040d0| 63 65 20 69 73 20 65 78 | 74 72 65 6d 65 6c 79 20 |ce is ex|tremely |
|000040e0| 75 73 65 66 75 6c 2e 20 | 53 75 70 70 6f 73 65 20 |useful. |Suppose |
|000040f0| 79 6f 75 0d 0a 20 20 20 | 77 61 6e 74 20 74 6f 20 |you.. |want to |
|00004100| 74 65 73 74 20 66 6f 72 | 20 65 71 75 61 6c 69 74 |test for| equalit|
|00004110| 79 2c 20 6f 72 20 63 72 | 65 61 74 65 20 61 20 6e |y, or cr|eate a n|
|00004120| 65 77 20 6f 62 6a 65 63 | 74 20 6f 66 20 74 68 65 |ew objec|t of the|
|00004130| 20 73 61 6d 65 20 74 79 | 70 65 20 61 73 0d 0a 20 | same ty|pe as.. |
|00004140| 20 20 74 68 65 20 6f 6e | 65 20 69 6e 20 68 61 6e | the on|e in han|
|00004150| 64 3a 0d 0a 0d 0a 63 6c | 61 73 73 20 41 0d 0a 7b |d:....cl|ass A..{|
|00004160| 0d 0a 20 20 20 70 75 62 | 6c 69 63 3a 0d 0a 20 20 |.. pub|lic:.. |
|00004170| 20 20 20 20 42 4f 4f 4c | 45 41 4e 20 65 71 75 61 | BOOL|EAN equa|
|00004180| 6c 28 41 2a 29 3b 0d 0a | 20 20 20 20 20 20 41 2a |l(A*);..| A*|
|00004190| 20 63 72 65 61 74 65 28 | 29 3b 0d 0a 7d 0d 0a 0d | create(|);..}...|
|000041a0| 0a 63 6c 61 73 73 20 42 | 3a 20 70 75 62 6c 69 63 |.class B|: public|
|000041b0| 20 41 0d 0a 7b 0d 0a 20 | 20 20 70 75 62 6c 69 63 | A..{.. | public|
|000041c0| 3a 0d 0a 20 20 20 20 20 | 20 42 4f 4f 4c 45 41 4e |:.. | BOOLEAN|
|000041d0| 20 65 71 75 61 6c 28 42 | 2a 29 3b 0d 0a 20 20 20 | equal(B|*);.. |
|000041e0| 20 20 20 42 2a 20 63 72 | 65 61 74 65 28 29 3b 0d | B* cr|eate();.|
|000041f0| 0a 7d 0d 0a 0d 0a 0d 0a | 20 20 20 48 65 72 65 20 |.}......| Here |
|00004200| 63 6f 76 61 72 69 61 6e | 63 65 20 69 73 20 65 78 |covarian|ce is ex|
|00004210| 61 63 74 6c 79 20 77 68 | 61 74 20 79 6f 75 20 77 |actly wh|at you w|
|00004220| 61 6e 74 2e 20 45 69 66 | 66 65 6c 20 67 69 76 65 |ant. Eif|fel give|
|00004230| 73 20 74 68 69 73 20 74 | 6f 20 79 6f 75 2c 0d 0a |s this t|o you,..|
|00004240| 20 20 20 62 75 74 20 74 | 68 65 20 63 6f 73 74 20 | but t|he cost |
|00004250| 69 73 20 67 69 76 69 6e | 67 20 75 70 20 31 30 30 |is givin|g up 100|
|00004260| 25 20 63 6f 6d 70 69 6c | 65 20 74 69 6d 65 20 74 |% compil|e time t|
|00004270| 79 70 65 20 73 61 66 65 | 74 79 2e 20 54 68 69 73 |ype safe|ty. This|
|00004280| 20 73 65 65 6d 0d 0a 20 | 20 20 6e 65 63 65 73 73 | seem.. | necess|
|00004290| 61 72 79 20 69 6e 20 63 | 61 73 65 73 20 6c 69 6b |ary in c|ases lik|
|000042a0| 65 20 74 68 65 73 65 2e | 0d 0a 0d 0a 20 20 20 49 |e these.|.... I|
|000042b0| 6e 20 66 61 63 74 2c 20 | 45 69 66 66 65 6c 20 67 |n fact, |Eiffel g|
|000042c0| 69 76 65 73 20 79 6f 75 | 20 61 75 74 6f 6d 61 74 |ives you| automat|
|000042d0| 69 63 20 77 61 79 73 20 | 74 6f 20 6d 61 6b 65 20 |ic ways |to make |
|000042e0| 61 20 6d 65 74 68 6f 64 | 20 63 6f 76 61 72 69 61 |a method| covaria|
|000042f0| 6e 74 2c 0d 0a 20 20 20 | 63 61 6c 6c 65 64 20 22 |nt,.. |called "|
|00004300| 61 6e 63 68 6f 72 65 64 | 20 74 79 70 65 73 22 2e |anchored| types".|
|00004310| 20 53 6f 20 79 6f 75 20 | 63 6f 75 6c 64 20 64 65 | So you |could de|
|00004320| 63 6c 61 72 65 2c 20 28 | 69 6e 20 43 2b 2b 2f 65 |clare, (|in C++/e|
|00004330| 69 66 66 65 73 65 29 3a | 0d 0a 0d 0a 63 6c 61 73 |iffese):|....clas|
|00004340| 73 20 41 0d 0a 7b 0d 0a | 20 20 20 70 75 62 6c 69 |s A..{..| publi|
|00004350| 63 3a 0d 0a 20 20 20 20 | 20 20 42 4f 4f 4c 45 41 |c:.. | BOOLEA|
|00004360| 4e 20 65 71 75 61 6c 28 | 6c 69 6b 65 20 43 75 72 |N equal(|like Cur|
|00004370| 72 65 6e 74 20 2a 29 3b | 0d 0a 20 20 20 20 20 20 |rent *);|.. |
|00004380| 6c 69 6b 65 20 43 75 72 | 72 65 6e 74 20 2a 20 63 |like Cur|rent * c|
|00004390| 72 65 61 74 65 28 29 3b | 0d 0a 7d 0d 0a 0d 0a 0d |reate();|..}.....|
|000043a0| 0a 20 20 20 57 68 69 63 | 68 20 73 61 79 73 20 65 |. Whic|h says e|
|000043b0| 71 75 61 6c 20 74 61 6b | 65 73 20 61 6e 20 61 72 |qual tak|es an ar|
|000043c0| 67 75 6d 65 6e 74 20 74 | 68 65 20 73 61 6d 65 20 |gument t|he same |
|000043d0| 74 79 70 65 20 61 73 20 | 74 68 65 20 63 75 72 72 |type as |the curr|
|000043e0| 65 6e 74 0d 0a 20 20 20 | 6f 62 6a 65 63 74 2c 20 |ent.. |object, |
|000043f0| 61 6e 64 20 63 72 65 61 | 74 65 20 72 65 74 75 72 |and crea|te retur|
|00004400| 6e 73 20 61 6e 20 6f 62 | 6a 65 63 74 20 6f 66 20 |ns an ob|ject of |
|00004410| 74 68 65 20 73 61 6d 65 | 20 74 79 70 65 20 61 73 |the same| type as|
|00004420| 20 63 75 72 72 65 6e 74 | 2e 20 4e 6f 77 2c 0d 0a | current|. Now,..|
|00004430| 20 20 20 74 68 65 72 65 | 20 69 73 20 6e 6f 74 20 | there| is not |
|00004440| 65 76 65 6e 20 61 6e 79 | 20 6e 65 65 64 20 74 6f |even any| need to|
|00004450| 20 72 65 64 65 63 6c 61 | 72 65 20 74 68 65 73 65 | redecla|re these|
|00004460| 20 69 6e 20 63 6c 61 73 | 73 20 42 2e 20 54 68 6f | in clas|s B. Tho|
|00004470| 73 65 0d 0a 20 20 20 74 | 72 61 6e 73 66 6f 72 6d |se.. t|ransform|
|00004480| 61 74 69 6f 6e 73 20 68 | 61 70 70 65 6e 20 66 6f |ations h|appen fo|
|00004490| 72 20 66 72 65 65 21 0d | 0a 0d 0a 0d 0a 35 2e 37 |r free!.|.....5.7|
|000044a0| 3a 20 57 68 61 74 20 69 | 73 20 6d 65 61 6e 74 20 |: What i|s meant |
|000044b0| 62 79 20 75 70 63 61 73 | 74 69 6e 67 2f 65 78 70 |by upcas|ting/exp|
|000044c0| 61 6e 64 69 6e 67 20 61 | 6e 64 20 64 6f 77 6e 63 |anding a|nd downc|
|000044d0| 61 73 74 69 6e 67 2f 6e | 61 72 72 6f 77 69 6e 67 |asting/n|arrowing|
|000044e0| 3f 0d 0a 0d 0a 20 20 20 | 28 54 75 63 6b 65 72 20 |?.... |(Tucker |
|000044f0| 54 61 66 74 20 72 65 70 | 6c 69 65 73 29 3a 0d 0a |Taft rep|lies):..|
|00004500| 0d 0a 20 20 20 48 65 72 | 65 20 69 73 20 74 68 65 |.. Her|e is the|
|00004510| 20 73 79 6d 6d 65 74 72 | 69 63 20 63 61 73 65 20 | symmetr|ic case |
|00004520| 74 6f 20 69 6c 6c 75 73 | 74 72 61 74 65 20 75 70 |to illus|trate up|
|00004530| 63 61 73 74 69 6e 67 20 | 61 6e 64 20 64 6f 77 6e |casting |and down|
|00004540| 63 61 73 74 69 6e 67 2e | 0d 0a 0d 0a 20 20 20 20 |casting.|.... |
|00004550| 20 74 79 70 65 20 41 20 | 69 73 20 74 61 67 67 65 | type A |is tagge|
|00004560| 64 20 2e 2e 2e 3b 20 20 | 20 2d 2d 20 6f 6e 65 20 |d ...; | -- one |
|00004570| 70 61 72 65 6e 74 20 74 | 79 70 65 0d 0a 0d 0a 20 |parent t|ype.... |
|00004580| 20 20 20 20 74 79 70 65 | 20 42 20 69 73 20 74 61 | type| B is ta|
|00004590| 67 67 65 64 20 2e 2e 2e | 3b 20 20 20 2d 2d 20 61 |gged ...|; -- a|
|000045a0| 6e 6f 74 68 65 72 20 70 | 61 72 65 6e 74 20 74 79 |nother p|arent ty|
|000045b0| 70 65 0d 0a 0d 0a 20 20 | 20 20 20 2e 2e 2e 0d 0a |pe.... | .....|
|000045c0| 0d 0a 20 20 20 20 20 74 | 79 70 65 20 43 3b 20 20 |.. t|ype C; |
|000045d0| 20 2d 2d 20 74 68 65 20 | 6e 65 77 20 74 79 70 65 | -- the |new type|
|000045e0| 2c 20 74 6f 20 62 65 20 | 61 20 6d 69 78 74 75 72 |, to be |a mixtur|
|000045f0| 65 20 6f 66 20 41 20 61 | 6e 64 20 42 0d 0a 0d 0a |e of A a|nd B....|
|00004600| 20 20 20 20 20 74 79 70 | 65 20 41 43 20 28 4f 62 | typ|e AC (Ob|
|00004610| 6a 20 3a 20 61 63 63 65 | 73 73 20 43 27 43 6c 61 |j : acce|ss C'Cla|
|00004620| 73 73 29 20 69 73 0d 0a | 20 20 20 20 20 20 20 6e |ss) is..| n|
|00004630| 65 77 20 41 0d 0a 20 20 | 20 20 20 20 20 77 69 74 |ew A.. | wit|
|00004640| 68 20 2e 2e 2e 3b 0d 0a | 20 20 20 20 20 20 20 2d |h ...;..| -|
|00004650| 2d 20 61 6e 20 65 78 74 | 65 6e 73 69 6f 6e 20 6f |- an ext|ension o|
|00004660| 66 20 41 20 74 6f 20 62 | 65 20 6d 69 78 65 64 20 |f A to b|e mixed |
|00004670| 69 6e 74 6f 20 43 0d 0a | 0d 0a 20 20 20 20 20 74 |into C..|.. t|
|00004680| 79 70 65 20 42 43 20 28 | 4f 62 6a 20 3a 20 61 63 |ype BC (|Obj : ac|
|00004690| 63 65 73 73 20 43 27 43 | 6c 61 73 73 29 20 69 73 |cess C'C|lass) is|
|000046a0| 0d 0a 20 20 20 20 20 20 | 20 6e 65 77 20 42 0d 0a |.. | new B..|
|000046b0| 20 20 20 20 20 20 20 77 | 69 74 68 20 2e 2e 2e 3b | w|ith ...;|
|000046c0| 0d 0a 20 20 20 20 20 20 | 20 2d 2d 20 61 6e 20 65 |.. | -- an e|
|000046d0| 78 74 65 6e 73 69 6f 6e | 20 6f 66 20 42 20 74 6f |xtension| of B to|
|000046e0| 20 62 65 20 6d 69 78 65 | 64 20 69 6e 74 6f 20 43 | be mixe|d into C|
|000046f0| 0d 0a 0d 0a 20 20 20 20 | 20 74 79 70 65 20 43 20 |.... | type C |
|00004700| 69 73 0d 0a 20 20 20 20 | 20 20 20 74 61 67 67 65 |is.. | tagge|
|00004710| 64 20 6c 69 6d 69 74 65 | 64 20 72 65 63 6f 72 64 |d limite|d record|
|00004720| 0d 0a 20 20 20 20 20 20 | 20 20 20 41 20 3a 20 41 |.. | A : A|
|00004730| 43 20 28 43 27 41 63 63 | 65 73 73 29 3b 0d 0a 20 |C (C'Acc|ess);.. |
|00004740| 20 20 20 20 20 20 20 20 | 42 20 3a 20 42 43 20 28 | |B : BC (|
|00004750| 43 27 41 63 63 65 73 73 | 29 3b 0d 0a 20 20 20 20 |C'Access|);.. |
|00004760| 20 20 20 20 20 2e 2e 2e | 20 2d 2d 20 6f 74 68 65 | ...| -- othe|
|00004770| 72 20 73 74 75 66 66 20 | 69 66 20 64 65 73 69 72 |r stuff |if desir|
|00004780| 65 64 0d 0a 20 20 20 20 | 20 20 20 65 6e 64 20 72 |ed.. | end r|
|00004790| 65 63 6f 72 64 3b 0d 0a | 0d 0a 0d 0a 20 20 20 57 |ecord;..|.... W|
|000047a0| 65 20 63 61 6e 20 6e 6f | 77 20 70 61 73 73 20 61 |e can no|w pass a|
|000047b0| 6e 20 6f 62 6a 65 63 74 | 20 6f 66 20 74 79 70 65 |n object| of type|
|000047c0| 20 43 20 74 6f 20 61 6e | 79 74 68 69 6e 67 20 74 | C to an|ything t|
|000047d0| 68 61 74 20 74 61 6b 65 | 73 20 61 6e 20 41 20 6f |hat take|s an A o|
|000047e0| 72 20 42 0d 0a 20 20 20 | 61 73 20 66 6f 6c 6c 6f |r B.. |as follo|
|000047f0| 77 73 20 28 74 68 69 73 | 20 70 72 65 73 75 6d 65 |ws (this| presume|
|00004800| 73 20 74 68 61 74 20 46 | 6f 6f 62 61 72 20 61 6e |s that F|oobar an|
|00004810| 64 20 51 42 65 72 74 20 | 61 72 65 20 70 72 69 6d |d QBert |are prim|
|00004820| 69 74 69 76 65 73 20 6f | 66 20 41 0d 0a 20 20 20 |itives o|f A.. |
|00004830| 61 6e 64 20 42 2c 20 72 | 65 73 70 65 63 74 69 76 |and B, r|espectiv|
|00004840| 65 6c 79 2c 20 73 6f 20 | 74 68 65 79 20 61 72 65 |ely, so |they are|
|00004850| 20 69 6e 68 65 72 69 74 | 65 64 3b 20 69 66 20 6e | inherit|ed; if n|
|00004860| 6f 74 2c 20 74 68 65 6e | 20 61 6e 20 65 78 70 6c |ot, then| an expl|
|00004870| 69 63 69 74 0d 0a 20 20 | 20 63 6f 6e 76 65 72 73 |icit.. | convers|
|00004880| 69 6f 6e 20 28 75 70 63 | 61 73 74 29 20 74 6f 20 |ion (upc|ast) to |
|00004890| 41 20 61 6e 64 20 42 20 | 63 6f 75 6c 64 20 62 65 |A and B |could be|
|000048a0| 20 75 73 65 64 20 74 6f | 20 63 61 6c 6c 20 74 68 | used to| call th|
|000048b0| 65 20 6f 72 69 67 69 6e | 61 6c 0d 0a 20 20 20 46 |e origin|al.. F|
|000048c0| 6f 6f 62 61 72 20 61 6e | 64 20 51 42 65 72 74 29 |oobar an|d QBert)|
|000048d0| 2e 0d 0a 0d 0a 20 20 20 | 20 20 58 43 20 3a 20 43 |..... | XC : C|
|000048e0| 3b 0d 0a 20 20 20 2e 2e | 2e 0d 0a 20 20 20 20 20 |;.. ..|... |
|000048f0| 46 6f 6f 62 61 72 20 28 | 58 43 2e 41 29 3b 0d 0a |Foobar (|XC.A);..|
|00004900| 20 20 20 20 20 51 42 65 | 72 74 20 28 58 43 2e 42 | QBe|rt (XC.B|
|00004910| 29 3b 0d 0a 0d 0a 0d 0a | 20 20 20 49 66 20 77 65 |);......| If we|
|00004920| 20 77 61 6e 74 20 74 6f | 20 6f 76 65 72 72 69 64 | want to| overrid|
|00004930| 65 20 77 68 61 74 20 46 | 6f 6f 62 61 72 20 64 6f |e what F|oobar do|
|00004940| 65 73 2c 20 74 68 65 6e | 20 77 65 20 6f 76 65 72 |es, then| we over|
|00004950| 72 69 64 65 20 46 6f 6f | 62 61 72 20 6f 6e 0d 0a |ride Foo|bar on..|
|00004960| 20 20 20 41 43 2e 20 49 | 66 20 77 65 20 77 61 6e | AC. I|f we wan|
|00004970| 74 20 74 6f 20 6f 76 65 | 72 72 69 64 65 20 77 68 |t to ove|rride wh|
|00004980| 61 74 20 51 42 65 72 74 | 20 64 6f 65 73 2c 20 74 |at QBert| does, t|
|00004990| 68 65 6e 20 77 65 20 6f | 76 65 72 72 69 64 65 20 |hen we o|verride |
|000049a0| 51 42 65 72 74 20 6f 6e | 0d 0a 20 20 20 42 43 2e |QBert on|.. BC.|
|000049b0| 0d 0a 0d 0a 20 20 20 4e | 6f 74 65 20 74 68 61 74 |.... N|ote that|
|000049c0| 20 74 68 65 72 65 20 61 | 72 65 20 6e 6f 20 6e 61 | there a|re no na|
|000049d0| 6d 69 6e 67 20 63 6f 6e | 66 6c 69 63 74 73 2c 20 |ming con|flicts, |
|000049e0| 73 69 6e 63 65 20 41 43 | 20 61 6e 64 20 42 43 20 |since AC| and BC |
|000049f0| 61 72 65 20 64 69 73 74 | 69 6e 63 74 0d 0a 20 20 |are dist|inct.. |
|00004a00| 20 74 79 70 65 73 2c 20 | 73 6f 20 65 76 65 6e 20 | types, |so even |
|00004a10| 69 66 20 41 20 61 6e 64 | 20 42 20 68 61 76 65 20 |if A and| B have |
|00004a20| 73 61 6d 65 2d 6e 61 6d | 65 64 20 63 6f 6d 70 6f |same-nam|ed compo|
|00004a30| 6e 65 6e 74 73 20 6f 72 | 20 6f 70 65 72 61 74 69 |nents or| operati|
|00004a40| 6f 6e 73 2c 20 77 65 0d | 0a 20 20 20 63 61 6e 20 |ons, we.|. can |
|00004a50| 74 61 6c 6b 20 61 62 6f | 75 74 20 74 68 65 6d 20 |talk abo|ut them |
|00004a60| 61 6e 64 2f 6f 72 20 6f | 76 65 72 72 69 64 65 20 |and/or o|verride |
|00004a70| 74 68 65 6d 20 69 6e 64 | 69 76 69 64 75 61 6c 6c |them ind|ividuall|
|00004a80| 79 20 75 73 69 6e 67 20 | 41 43 20 61 6e 64 20 42 |y using |AC and B|
|00004a90| 43 2e 0d 0a 0d 0a 0d 0a | 20 20 20 55 70 63 61 73 |C.......| Upcas|
|00004aa0| 74 69 6e 67 20 28 66 72 | 6f 6d 20 43 20 74 6f 20 |ting (fr|om C to |
|00004ab0| 41 20 6f 72 20 43 20 74 | 6f 20 42 29 20 69 73 20 |A or C t|o B) is |
|00004ac0| 74 72 69 76 69 61 6c 20 | 2d 2d 20 41 28 58 43 2e |trivial |-- A(XC.|
|00004ad0| 41 29 20 75 70 63 61 73 | 74 73 20 74 6f 20 41 3b |A) upcas|ts to A;|
|00004ae0| 0d 0a 20 20 20 42 28 58 | 43 2e 42 29 20 75 70 63 |.. B(X|C.B) upc|
|00004af0| 61 73 74 73 20 74 6f 20 | 42 2e 0d 0a 0d 0a 20 20 |asts to |B..... |
|00004b00| 20 44 6f 77 6e 63 61 73 | 74 69 6e 67 20 28 6e 61 | Downcas|ting (na|
|00004b10| 72 72 6f 77 69 6e 67 29 | 20 69 73 20 61 6c 73 6f |rrowing)| is also|
|00004b20| 20 73 74 72 61 69 67 68 | 74 66 6f 72 77 61 72 64 | straigh|tforward|
|00004b30| 20 61 6e 64 20 73 61 66 | 65 2e 20 50 72 65 73 75 | and saf|e. Presu|
|00004b40| 6d 69 6e 67 20 58 41 0d | 0a 20 20 20 6f 66 20 74 |ming XA.|. of t|
|00004b50| 79 70 65 20 41 27 43 6c | 61 73 73 2c 20 61 6e 64 |ype A'Cl|ass, and|
|00004b60| 20 58 42 20 6f 66 20 74 | 79 70 65 20 42 27 43 6c | XB of t|ype B'Cl|
|00004b70| 61 73 73 3a 0d 0a 0d 0a | 20 20 20 20 20 41 43 28 |ass:....| AC(|
|00004b80| 58 41 29 2e 4f 62 6a 2e | 61 6c 6c 20 64 6f 77 6e |XA).Obj.|all down|
|00004b90| 63 61 73 74 73 20 74 6f | 20 43 27 43 6c 61 73 73 |casts to| C'Class|
|00004ba0| 20 28 61 6e 64 20 76 65 | 72 69 66 69 65 73 20 58 | (and ve|rifies X|
|00004bb0| 41 20 69 6e 20 41 43 27 | 43 6c 61 73 73 29 0d 0a |A in AC'|Class)..|
|00004bc0| 20 20 20 20 20 42 43 28 | 58 42 29 2e 4f 62 6a 2e | BC(|XB).Obj.|
|00004bd0| 61 6c 6c 20 64 6f 77 6e | 63 61 73 74 73 20 74 6f |all down|casts to|
|00004be0| 20 43 27 43 6c 61 73 73 | 20 28 61 6e 64 20 76 65 | C'Class| (and ve|
|00004bf0| 72 69 66 69 65 73 20 58 | 42 20 69 6e 20 42 43 27 |rifies X|B in BC'|
|00004c00| 43 6c 61 73 73 29 0d 0a | 0d 0a 0d 0a 20 20 20 59 |Class)..|.... Y|
|00004c10| 6f 75 20 63 61 6e 20 63 | 68 65 63 6b 20 62 65 66 |ou can c|heck bef|
|00004c20| 6f 72 65 20 74 68 65 20 | 64 6f 77 6e 63 61 73 74 |ore the |downcast|
|00004c30| 20 74 6f 20 61 76 6f 69 | 64 20 61 20 43 6f 6e 73 | to avoi|d a Cons|
|00004c40| 74 72 61 69 6e 74 5f 45 | 72 72 6f 72 3a 0d 0a 0d |traint_E|rror:...|
|00004c50| 0a 20 20 20 20 20 69 66 | 20 58 41 20 6e 6f 74 20 |. if| XA not |
|00004c60| 69 6e 20 41 43 27 43 6c | 61 73 73 20 74 68 65 6e |in AC'Cl|ass then|
|00004c70| 20 2d 2d 20 61 70 70 72 | 6f 70 72 69 61 74 65 20 | -- appr|opriate |
|00004c80| 63 6f 6d 70 6c 61 69 6e | 74 0d 0a 0d 0a 20 20 20 |complain|t.... |
|00004c90| 20 20 69 66 20 58 42 20 | 6e 6f 74 20 69 6e 20 42 | if XB |not in B|
|00004ca0| 43 27 43 6c 61 73 73 20 | 74 68 65 6e 20 2d 2d 20 |C'Class |then -- |
|00004cb0| 64 69 74 74 6f 0d 0a 0d | 0a 0d 0a 20 20 20 54 68 |ditto...|... Th|
|00004cc0| 65 20 61 70 70 72 6f 61 | 63 68 20 69 73 20 73 6c |e approa|ch is sl|
|00004cd0| 69 67 68 74 6c 79 20 73 | 69 6d 70 6c 65 72 20 28 |ightly s|impler (|
|00004ce0| 74 68 6f 75 67 68 20 6c | 65 73 73 20 73 79 6d 6d |though l|ess symm|
|00004cf0| 65 74 72 69 63 29 20 69 | 66 20 77 65 20 63 68 6f |etric) i|f we cho|
|00004d00| 6f 73 65 0d 0a 20 20 20 | 74 6f 20 6d 61 6b 65 20 |ose.. |to make |
|00004d10| 41 20 74 68 65 20 22 70 | 72 69 6d 61 72 79 22 20 |A the "p|rimary" |
|00004d20| 70 61 72 65 6e 74 20 61 | 6e 64 20 42 20 61 20 22 |parent a|nd B a "|
|00004d30| 73 65 63 6f 6e 64 61 72 | 79 22 20 70 61 72 65 6e |secondar|y" paren|
|00004d40| 74 3a 0d 0a 0d 0a 20 20 | 20 20 20 74 79 70 65 20 |t:.... | type |
|00004d50| 41 20 69 73 20 2e 2e 2e | 0d 0a 20 20 20 20 20 74 |A is ...|.. t|
|00004d60| 79 70 65 20 42 20 69 73 | 20 2e 2e 2e 0d 0a 0d 0a |ype B is| .......|
|00004d70| 20 20 20 20 20 74 79 70 | 65 20 43 3b 0d 0a 0d 0a | typ|e C;....|
|00004d80| 20 20 20 20 20 74 79 70 | 65 20 42 43 20 28 4f 62 | typ|e BC (Ob|
|00004d90| 6a 20 3a 20 61 63 63 65 | 73 73 20 43 27 43 6c 61 |j : acce|ss C'Cla|
|00004da0| 73 73 29 20 69 73 0d 0a | 20 20 20 20 20 20 20 6e |ss) is..| n|
|00004db0| 65 77 20 42 0d 0a 20 20 | 20 20 20 20 20 77 69 74 |ew B.. | wit|
|00004dc0| 68 20 2e 2e 2e 0d 0a 0d | 0a 20 20 20 20 20 74 79 |h ......|. ty|
|00004dd0| 70 65 20 43 20 69 73 0d | 0a 20 20 20 20 20 20 20 |pe C is.|. |
|00004de0| 6e 65 77 20 41 0d 0a 20 | 20 20 20 20 20 20 77 69 |new A.. | wi|
|00004df0| 74 68 20 72 65 63 6f 72 | 64 0d 0a 20 20 20 20 20 |th recor|d.. |
|00004e00| 20 20 20 20 42 20 3a 20 | 42 43 20 28 43 27 41 63 | B : |BC (C'Ac|
|00004e10| 63 65 73 73 29 3b 0d 0a | 20 20 20 20 20 20 20 20 |cess);..| |
|00004e20| 20 2e 2e 2e 20 2d 2d 20 | 6f 74 68 65 72 20 73 74 | ... -- |other st|
|00004e30| 75 66 66 20 69 66 20 64 | 65 73 69 72 65 64 0d 0a |uff if d|esired..|
|00004e40| 20 20 20 20 20 20 20 65 | 6e 64 20 72 65 63 6f 72 | e|nd recor|
|00004e50| 64 3b 0d 0a 0d 0a 0d 0a | 20 20 20 4e 6f 77 20 43 |d;......| Now C|
|00004e60| 20 69 73 20 61 20 22 6e | 6f 72 6d 61 6c 22 20 65 | is a "n|ormal" e|
|00004e70| 78 74 65 6e 73 69 6f 6e | 20 6f 66 20 41 2c 20 61 |xtension| of A, a|
|00004e80| 6e 64 20 75 70 63 61 73 | 74 69 6e 67 20 66 72 6f |nd upcas|ting fro|
|00004e90| 6d 20 43 20 74 6f 20 41 | 20 61 6e 64 0d 0a 20 20 |m C to A| and.. |
|00004ea0| 20 28 63 68 65 63 6b 65 | 64 29 20 64 6f 77 6e 63 | (checke|d) downc|
|00004eb0| 61 73 74 69 6e 67 20 66 | 72 6f 6d 20 43 27 43 6c |asting f|rom C'Cl|
|00004ec0| 61 73 73 20 74 6f 20 41 | 20 28 6f 72 20 41 27 43 |ass to A| (or A'C|
|00004ed0| 6c 61 73 73 29 20 69 73 | 20 64 6f 6e 65 20 77 69 |lass) is| done wi|
|00004ee0| 74 68 0d 0a 20 20 20 73 | 69 6d 70 6c 65 20 74 79 |th.. s|imple ty|
|00004ef0| 70 65 20 63 6f 6e 76 65 | 72 73 69 6f 6e 73 2e 20 |pe conve|rsions. |
|00004f00| 54 68 65 20 72 65 6c 61 | 74 69 6f 6e 73 68 69 70 |The rela|tionship|
|00004f10| 20 62 65 74 77 65 65 6e | 20 43 20 61 6e 64 20 42 | between| C and B|
|00004f20| 20 69 73 20 61 73 20 61 | 62 6f 76 65 0d 0a 20 20 | is as a|bove.. |
|00004f30| 20 69 6e 20 74 68 65 20 | 73 79 6d 6d 65 74 72 69 | in the |symmetri|
|00004f40| 63 20 61 70 70 72 6f 61 | 63 68 2e 0d 0a 0d 0a 20 |c approa|ch..... |
|00004f50| 20 20 4e 6f 74 20 73 75 | 72 70 72 69 73 69 6e 67 | Not su|rprising|
|00004f60| 6c 79 2c 20 75 73 69 6e | 67 20 62 75 69 6c 64 69 |ly, usin|g buildi|
|00004f70| 6e 67 20 62 6c 6f 63 6b | 73 20 69 73 20 6d 6f 72 |ng block|s is mor|
|00004f80| 65 20 77 6f 72 6b 20 74 | 68 61 6e 20 75 73 69 6e |e work t|han usin|
|00004f90| 67 20 61 0d 0a 20 20 20 | 22 62 75 69 6c 74 69 6e |g a.. |"builtin|
|00004fa0| 22 20 61 70 70 72 6f 61 | 63 68 20 66 6f 72 20 73 |" approa|ch for s|
|00004fb0| 69 6d 70 6c 65 20 63 61 | 73 65 73 20 74 68 61 74 |imple ca|ses that|
|00004fc0| 20 68 61 70 70 65 6e 20 | 74 6f 20 6d 61 74 63 68 | happen |to match|
|00004fd0| 20 74 68 65 20 62 75 69 | 6c 74 69 6e 0d 0a 20 20 | the bui|ltin.. |
|00004fe0| 20 61 70 70 72 6f 61 63 | 68 2c 20 62 75 74 20 68 | approac|h, but h|
|00004ff0| 61 76 69 6e 67 20 62 75 | 69 6c 64 69 6e 67 20 62 |aving bu|ilding b|
|00005000| 6c 6f 63 6b 73 20 64 6f | 65 73 20 75 6c 74 69 6d |locks do|es ultim|
|00005010| 61 74 65 6c 79 20 6d 65 | 61 6e 20 6d 6f 72 65 0d |ately me|an more.|
|00005020| 0a 20 20 20 66 6c 65 78 | 69 62 69 6c 69 74 79 20 |. flex|ibility |
|00005030| 66 6f 72 20 74 68 65 20 | 70 72 6f 67 72 61 6d 6d |for the |programm|
|00005040| 65 72 20 2d 2d 20 74 68 | 65 72 65 20 61 72 65 20 |er -- th|ere are |
|00005050| 6d 61 6e 79 20 6f 74 68 | 65 72 20 73 74 72 75 63 |many oth|er struc|
|00005060| 74 75 72 65 73 20 74 68 | 61 74 0d 0a 20 20 20 61 |tures th|at.. a|
|00005070| 72 65 20 70 6f 73 73 69 | 62 6c 65 20 69 6e 20 61 |re possi|ble in a|
|00005080| 64 64 69 74 69 6f 6e 20 | 74 6f 20 74 68 65 20 74 |ddition |to the t|
|00005090| 77 6f 20 69 6c 6c 75 73 | 74 72 61 74 65 64 20 61 |wo illus|trated a|
|000050a0| 62 6f 76 65 2c 20 75 73 | 69 6e 67 20 74 68 65 0d |bove, us|ing the.|
|000050b0| 0a 20 20 20 61 63 63 65 | 73 73 20 64 69 73 63 72 |. acce|ss discr|
|000050c0| 69 6d 69 6e 61 6e 74 20 | 62 75 69 6c 64 69 6e 67 |iminant |building|
|000050d0| 20 62 6c 6f 63 6b 2e 0d | 0a 0d 0a 20 20 20 46 6f | block..|... Fo|
|000050e0| 72 20 65 78 61 6d 70 6c | 65 2c 20 66 6f 72 20 6d |r exampl|e, for m|
|000050f0| 69 78 69 6e 73 2c 20 65 | 61 63 68 20 6d 69 78 69 |ixins, e|ach mixi|
|00005100| 6e 20 22 66 6c 61 76 6f | 72 22 20 77 6f 75 6c 64 |n "flavo|r" would|
|00005110| 20 68 61 76 65 20 61 6e | 20 61 63 63 65 73 73 0d | have an| access.|
|00005120| 0a 20 20 20 64 69 73 63 | 72 69 6d 69 6e 61 6e 74 |. disc|riminant|
|00005130| 20 61 6c 72 65 61 64 79 | 3a 0d 0a 0d 0a 20 20 20 | already|:.... |
|00005140| 20 20 74 79 70 65 20 57 | 69 6e 64 6f 77 20 69 73 | type W|indow is|
|00005150| 20 2e 2e 2e 20 20 2d 2d | 20 54 68 65 20 62 61 73 | ... --| The bas|
|00005160| 69 63 20 22 76 61 6e 69 | 6c 6c 61 22 20 77 69 6e |ic "vani|lla" win|
|00005170| 64 6f 77 0d 0a 0d 0a 20 | 20 20 20 20 2d 2d 20 56 |dow.... | -- V|
|00005180| 61 72 69 6f 75 73 20 6d | 69 78 69 6e 73 0d 0a 20 |arious m|ixins.. |
|00005190| 20 20 20 20 74 79 70 65 | 20 57 69 6e 5f 4d 69 78 | type| Win_Mix|
|000051a0| 69 6e 5f 31 20 28 57 20 | 3a 20 61 63 63 65 73 73 |in_1 (W |: access|
|000051b0| 20 57 69 6e 64 6f 77 27 | 43 6c 61 73 73 29 20 69 | Window'|Class) i|
|000051c0| 73 20 2e 2e 2e 0d 0a 0d | 0a 20 20 20 20 20 74 79 |s ......|. ty|
|000051d0| 70 65 20 57 69 6e 5f 4d | 69 78 69 6e 5f 32 20 28 |pe Win_M|ixin_2 (|
|000051e0| 57 20 3a 20 61 63 63 65 | 73 73 20 57 69 6e 64 6f |W : acce|ss Windo|
|000051f0| 77 27 43 6c 61 73 73 29 | 20 69 73 20 2e 2e 2e 0d |w'Class)| is ....|
|00005200| 0a 0d 0a 20 20 20 20 20 | 74 79 70 65 20 57 69 6e |... |type Win|
|00005210| 5f 4d 69 78 69 6e 5f 33 | 20 28 57 20 3a 20 61 63 |_Mixin_3| (W : ac|
|00005220| 63 65 73 73 20 57 69 6e | 64 6f 77 27 43 6c 61 73 |cess Win|dow'Clas|
|00005230| 73 29 20 69 73 20 2e 2e | 2e 0d 0a 0d 0a 0d 0a 20 |s) is ..|....... |
|00005240| 20 20 47 69 76 65 6e 20 | 74 68 65 20 61 62 6f 76 | Given |the abov|
|00005250| 65 20 76 61 6e 69 6c 6c | 61 20 77 69 6e 64 6f 77 |e vanill|a window|
|00005260| 2c 20 70 6c 75 73 20 61 | 6e 79 20 6e 75 6d 62 65 |, plus a|ny numbe|
|00005270| 72 20 6f 66 20 77 69 6e | 64 6f 77 20 6d 69 78 69 |r of win|dow mixi|
|00005280| 6e 73 2c 20 6f 6e 65 0d | 0a 20 20 20 63 61 6e 20 |ns, one.|. can |
|00005290| 63 6f 6e 73 74 72 75 63 | 74 20 61 20 64 65 73 69 |construc|t a desi|
|000052a0| 72 65 64 20 77 69 6e 64 | 6f 77 20 62 79 20 69 6e |red wind|ow by in|
|000052b0| 63 6c 75 64 69 6e 67 20 | 61 73 20 6d 61 6e 79 20 |cluding |as many |
|000052c0| 6d 69 78 69 6e 73 20 61 | 73 20 77 61 6e 74 65 64 |mixins a|s wanted|
|000052d0| 3a 0d 0a 0d 0a 20 20 20 | 20 20 74 79 70 65 20 4d |:.... | type M|
|000052e0| 79 5f 57 69 6e 64 6f 77 | 20 69 73 0d 0a 20 20 20 |y_Window| is.. |
|000052f0| 20 20 20 20 6e 65 77 20 | 57 69 6e 64 6f 77 0d 0a | new |Window..|
|00005300| 20 20 20 20 20 20 20 77 | 69 74 68 20 72 65 63 6f | w|ith reco|
|00005310| 72 64 0d 0a 20 20 20 20 | 20 20 20 20 20 4d 31 20 |rd.. | M1 |
|00005320| 3a 20 57 69 6e 5f 4d 69 | 78 69 6e 5f 31 20 28 4d |: Win_Mi|xin_1 (M|
|00005330| 79 5f 57 69 6e 64 6f 77 | 27 61 63 63 65 73 73 29 |y_Window|'access)|
|00005340| 3b 0d 0a 20 20 20 20 20 | 20 20 20 20 4d 33 20 3a |;.. | M3 :|
|00005350| 20 57 69 6e 5f 4d 69 78 | 69 6e 5f 33 20 28 4d 79 | Win_Mix|in_3 (My|
|00005360| 5f 57 69 6e 64 6f 77 27 | 61 63 63 65 73 73 29 3b |_Window'|access);|
|00005370| 0d 0a 20 20 20 20 20 20 | 20 20 20 4d 31 31 20 3a |.. | M11 :|
|00005380| 20 57 69 6e 5f 4d 69 78 | 69 6e 5f 31 28 4d 79 5f | Win_Mix|in_1(My_|
|00005390| 57 69 6e 64 6f 77 27 61 | 63 63 65 73 73 29 3b 0d |Window'a|ccess);.|
|000053a0| 0a 20 20 20 20 20 20 20 | 20 20 2e 2e 2e 20 2d 2d |. | ... --|
|000053b0| 20 70 6c 75 73 20 61 64 | 64 69 74 69 6f 6e 61 6c | plus ad|ditional|
|000053c0| 20 73 74 75 66 66 2c 20 | 61 73 20 64 65 73 69 72 | stuff, |as desir|
|000053d0| 65 64 2e 0d 0a 20 20 20 | 20 20 20 20 65 6e 64 20 |ed... | end |
|000053e0| 72 65 63 6f 72 64 3b 0d | 0a 0d 0a 0d 0a 20 20 20 |record;.|..... |
|000053f0| 41 73 20 69 6c 6c 75 73 | 74 72 61 74 65 64 20 61 |As illus|trated a|
|00005400| 62 6f 76 65 2c 20 79 6f | 75 20 63 61 6e 20 69 6e |bove, yo|u can in|
|00005410| 63 6f 72 70 6f 72 61 74 | 65 20 74 68 65 20 73 61 |corporat|e the sa|
|00005420| 6d 65 20 22 6d 69 78 69 | 6e 22 20 6d 75 6c 74 69 |me "mixi|n" multi|
|00005430| 70 6c 65 0d 0a 20 20 20 | 74 69 6d 65 73 2c 20 77 |ple.. |times, w|
|00005440| 69 74 68 20 6e 6f 20 6e | 61 6d 69 6e 67 20 63 6f |ith no n|aming co|
|00005450| 6e 66 6c 69 63 74 73 2e | 20 45 76 65 72 79 20 6d |nflicts.| Every m|
|00005460| 69 78 69 6e 20 63 61 6e | 20 67 65 74 20 61 63 63 |ixin can| get acc|
|00005470| 65 73 73 20 74 6f 20 74 | 68 65 0d 0a 20 20 20 65 |ess to t|he.. e|
|00005480| 6e 63 6c 6f 73 69 6e 67 | 20 6f 62 6a 65 63 74 2e |nclosing| object.|
|00005490| 20 4f 70 65 72 61 74 69 | 6f 6e 73 20 6f 66 20 69 | Operati|ons of i|
|000054a0| 6e 64 69 76 69 64 75 61 | 6c 20 6d 69 78 69 6e 73 |ndividua|l mixins|
|000054b0| 20 63 61 6e 20 62 65 20 | 6f 76 65 72 72 69 64 64 | can be |overridd|
|000054c0| 65 6e 20 62 79 0d 0a 20 | 20 20 63 72 65 61 74 69 |en by.. | creati|
|000054d0| 6e 67 20 61 6e 20 65 78 | 74 65 6e 73 69 6f 6e 20 |ng an ex|tension |
|000054e0| 6f 66 20 74 68 65 20 6d | 69 78 69 6e 20 66 69 72 |of the m|ixin fir|
|000054f0| 73 74 2c 20 6f 76 65 72 | 72 69 64 69 6e 67 20 74 |st, over|riding t|
|00005500| 68 65 20 6f 70 65 72 61 | 74 69 6f 6e 20 69 6e 0d |he opera|tion in.|
|00005510| 0a 20 20 20 74 68 61 74 | 2c 20 61 6e 64 20 74 68 |. that|, and th|
|00005520| 65 6e 20 69 6e 63 6f 72 | 70 6f 72 61 74 69 6e 67 |en incor|porating|
|00005530| 20 74 68 61 74 20 74 77 | 65 61 6b 65 64 20 6d 69 | that tw|eaked mi|
|00005540| 78 69 6e 20 69 6e 74 6f | 20 74 68 65 20 75 6c 74 |xin into| the ult|
|00005550| 69 6d 61 74 65 0d 0a 20 | 20 20 77 69 6e 64 6f 77 |imate.. | window|
|00005560| 2e 0d 0a 0d 0a 20 20 20 | 49 20 68 6f 70 65 20 74 |..... |I hope t|
|00005570| 68 65 20 61 62 6f 76 65 | 20 68 65 6c 70 73 20 62 |he above| helps b|
|00005580| 65 74 74 65 72 20 69 6c | 6c 75 73 74 72 61 74 65 |etter il|lustrate|
|00005590| 20 74 68 65 20 75 73 65 | 20 61 6e 64 20 66 6c 65 | the use| and fle|
|000055a0| 78 69 62 69 6c 69 74 79 | 20 6f 66 0d 0a 20 20 20 |xibility| of.. |
|000055b0| 74 68 65 20 41 64 61 20 | 39 58 20 74 79 70 65 20 |the Ada |9X type |
|000055c0| 63 6f 6d 70 6f 73 69 74 | 69 6f 6e 20 62 75 69 6c |composit|ion buil|
|000055d0| 64 69 6e 67 20 62 6c 6f | 63 6b 73 2e 0d 0a 0d 0a |ding blo|cks.....|
|000055e0| 0d 0a 35 2e 38 3a 20 48 | 6f 77 20 64 6f 65 73 20 |..5.8: H|ow does |
|000055f0| 41 64 61 20 64 6f 20 22 | 6e 61 72 72 6f 77 69 6e |Ada do "|narrowin|
|00005600| 67 22 3f 0d 0a 0d 0a 20 | 20 20 44 61 76 65 20 47 |g"?.... | Dave G|
|00005610| 72 69 66 66 69 74 68 20 | 73 61 69 64 0d 0a 0d 0a |riffith |said....|
|00005620| 20 20 20 20 20 2e 20 2e | 20 2e 20 4e 6f 6e 65 74 | . .| . Nonet|
|00005630| 68 65 6c 65 73 73 2c 20 | 54 68 65 20 41 64 61 39 |heless, |The Ada9|
|00005640| 78 20 63 6f 6d 6d 69 74 | 74 65 65 20 63 68 6f 73 |x commit|tee chos|
|00005650| 65 20 61 20 73 74 72 75 | 63 74 75 72 65 2d 62 61 |e a stru|cture-ba|
|00005660| 73 65 64 0d 0a 20 20 20 | 20 20 73 75 62 74 79 70 |sed.. | subtyp|
|00005670| 69 6e 67 2c 20 77 69 74 | 68 20 61 6c 6c 20 6f 66 |ing, wit|h all of|
|00005680| 20 74 68 65 20 70 72 6f | 62 6c 65 6d 73 20 74 68 | the pro|blems th|
|00005690| 61 74 20 74 68 61 74 20 | 69 73 20 6b 6e 6f 77 6e |at that |is known|
|000056a0| 20 74 6f 20 63 61 75 73 | 65 2e 20 41 73 0d 0a 20 | to caus|e. As.. |
|000056b0| 20 20 20 20 74 68 65 20 | 70 72 6f 62 6c 65 6d 73 | the |problems|
|000056c0| 20 6f 66 20 73 74 72 75 | 63 74 75 72 65 20 62 61 | of stru|cture ba|
|000056d0| 73 65 64 20 73 75 62 74 | 79 70 69 6e 67 20 75 73 |sed subt|yping us|
|000056e0| 75 61 6c 6c 79 20 6d 61 | 6e 69 66 65 73 74 20 6f |ually ma|nifest o|
|000056f0| 6e 6c 79 20 69 6e 0d 0a | 20 20 20 20 20 6c 61 72 |nly in..| lar|
|00005700| 67 65 20 70 72 6f 6a 65 | 63 74 73 20 6d 61 69 6e |ge proje|cts main|
|00005710| 74 61 69 6e 65 64 20 62 | 79 20 6c 61 72 67 65 20 |tained b|y large |
|00005720| 67 72 6f 75 70 73 2c 20 | 74 68 69 73 20 69 73 20 |groups, |this is |
|00005730| 5f 70 72 65 63 69 73 65 | 6c 79 5f 20 74 68 65 0d |_precise|ly_ the.|
|00005740| 0a 20 20 20 20 20 73 75 | 62 74 79 70 65 20 70 61 |. su|btype pa|
|00005750| 72 61 64 69 67 6d 20 74 | 68 61 74 20 41 64 61 39 |radigm t|hat Ada9|
|00005760| 78 20 73 68 6f 75 6c 64 | 20 68 61 76 65 20 61 76 |x should| have av|
|00005770| 6f 69 64 65 64 2e 20 41 | 64 61 39 78 27 73 20 6d |oided. A|da9x's m|
|00005780| 6f 64 65 6c 20 69 73 2c | 0d 0a 20 20 20 20 20 61 |odel is,|.. a|
|00005790| 73 20 54 75 63 6b 65 72 | 20 54 61 66 74 20 70 6f |s Tucker| Taft po|
|000057a0| 69 6e 74 65 64 20 6f 75 | 74 2c 20 71 75 69 74 65 |inted ou|t, quite|
|000057b0| 20 65 61 73 79 20 74 6f | 20 75 73 65 20 66 6f 72 | easy to| use for|
|000057c0| 20 73 69 6d 70 6c 65 20 | 4f 4f 0d 0a 20 20 20 20 | simple |OO.. |
|000057d0| 20 70 72 6f 67 72 61 6d | 6d 69 6e 67 2e 20 54 68 | program|ming. Th|
|000057e0| 65 72 65 20 69 73 2c 20 | 68 6f 77 65 76 65 72 2c |ere is, |however,|
|000057f0| 20 6e 6f 20 67 6f 6f 64 | 20 72 65 61 73 6f 6e 20 | no good| reason |
|00005800| 74 6f 20 5f 64 6f 5f 20 | 73 69 6d 70 6c 65 20 4f |to _do_ |simple O|
|00005810| 4f 0d 0a 20 20 20 20 20 | 70 72 6f 67 72 61 6d 6d |O.. |programm|
|00005820| 69 6e 67 2e 20 4f 4f 20 | 70 72 6f 67 72 61 6d 6d |ing. OO |programm|
|00005830| 69 6e 67 73 20 67 61 69 | 6e 73 20 63 6c 69 63 6b |ings gai|ns click|
|00005840| 20 69 6e 20 73 6f 6d 65 | 77 68 65 72 65 20 61 72 | in some|where ar|
|00005850| 6f 75 6e 64 20 31 30 2c | 30 30 30 0d 0a 20 20 20 |ound 10,|000.. |
|00005860| 20 20 4c 4f 43 2c 20 77 | 69 74 68 20 67 72 65 61 | LOC, w|ith grea|
|00005870| 74 65 73 74 20 67 61 69 | 6e 73 20 61 74 20 6f 76 |test gai|ns at ov|
|00005880| 65 72 20 31 30 30 2c 30 | 30 30 2e 20 41 74 20 74 |er 100,0|00. At t|
|00005890| 68 65 73 65 20 73 69 7a | 65 73 2c 20 22 6a 75 73 |hese siz|es, "jus|
|000058a0| 74 0d 0a 20 20 20 20 20 | 64 65 63 6c 61 72 65 20 |t.. |declare |
|000058b0| 69 74 20 74 61 67 67 65 | 64 22 20 77 69 6c 6c 20 |it tagge|d" will |
|000058c0| 72 65 73 75 6c 74 20 69 | 6e 20 75 6e 6d 61 69 6e |result i|n unmain|
|000058d0| 74 61 69 6e 61 62 6c 65 | 20 6d 65 73 73 65 73 2e |tainable| messes.|
|000058e0| 20 4f 4f 0d 0a 20 20 20 | 20 20 70 72 6f 67 72 61 | OO.. | progra|
|000058f0| 6d 6d 69 6e 67 20 69 6e | 20 74 68 65 20 6c 61 72 |mming in| the lar|
|00005900| 67 65 20 72 61 70 69 64 | 6c 79 20 67 65 74 73 20 |ge rapid|ly gets |
|00005910| 64 69 66 66 69 63 75 6c | 74 20 77 69 74 68 20 73 |difficul|t with s|
|00005920| 74 72 75 63 74 75 72 65 | 20 62 61 73 65 64 0d 0a |tructure| based..|
|00005930| 20 20 20 20 20 73 75 62 | 74 79 70 69 6e 67 2e 20 | sub|typing. |
|00005940| 41 6c 6c 6f 77 69 6e 67 | 20 62 79 2d 76 61 6c 75 |Allowing| by-valu|
|00005950| 65 20 73 65 6d 61 6e 74 | 69 63 73 20 66 6f 72 20 |e semant|ics for |
|00005960| 6f 62 6a 65 63 74 73 20 | 63 6f 6d 70 6f 75 6e 64 |objects |compound|
|00005970| 73 20 74 68 65 73 65 0d | 0a 20 20 20 20 20 70 72 |s these.|. pr|
|00005980| 6f 62 6c 65 6d 73 2e 20 | 41 6c 6c 20 6f 66 20 74 |oblems. |All of t|
|00005990| 68 69 73 20 69 73 20 6b | 6e 6f 77 6e 2e 20 41 6c |his is k|nown. Al|
|000059a0| 6c 20 6f 66 20 74 68 69 | 73 20 77 61 73 2c 20 73 |l of thi|s was, s|
|000059b0| 65 65 6d 69 6e 67 6c 79 | 2c 20 69 67 6e 6f 72 65 |eemingly|, ignore|
|000059c0| 64 0d 0a 20 20 20 20 20 | 62 79 20 41 64 61 39 78 |d.. |by Ada9x|
|000059d0| 2e 0d 0a 0d 0a 0d 0a 20 | 20 20 28 54 75 63 6b 65 |....... | (Tucke|
|000059e0| 72 20 54 61 66 74 20 61 | 6e 73 77 65 72 73 29 0d |r Taft a|nswers).|
|000059f0| 0a 0d 0a 20 20 20 41 73 | 20 65 78 70 6c 61 69 6e |... As| explain|
|00005a00| 65 64 20 69 6e 20 61 20 | 70 72 65 76 69 6f 75 73 |ed in a |previous|
|00005a10| 20 6e 6f 74 65 2c 20 41 | 64 61 20 39 58 20 73 75 | note, A|da 9X su|
|00005a20| 70 70 6f 72 74 73 20 74 | 68 65 20 61 62 69 6c 69 |pports t|he abili|
|00005a30| 74 79 20 74 6f 20 68 69 | 64 65 0d 0a 20 20 20 74 |ty to hi|de.. t|
|00005a40| 68 65 20 69 6d 70 6c 65 | 6d 65 6e 74 61 74 69 6f |he imple|mentatio|
|00005a50| 6e 20 68 65 72 69 74 61 | 67 65 20 6f 66 20 61 20 |n herita|ge of a |
|00005a60| 74 79 70 65 2c 20 61 6e | 64 20 6f 6e 6c 79 20 65 |type, an|d only e|
|00005a70| 78 70 6f 73 65 20 74 68 | 65 20 64 65 73 69 72 65 |xpose th|e desire|
|00005a80| 64 0d 0a 20 20 20 69 6e | 74 65 72 66 61 63 65 20 |d.. in|terface |
|00005a90| 68 65 72 69 74 61 67 65 | 2e 20 53 6f 20 77 65 20 |heritage|. So we |
|00005aa0| 61 72 65 20 6e 6f 74 20 | 73 74 75 63 6b 20 77 69 |are not |stuck wi|
|00005ab0| 74 68 20 73 74 72 69 63 | 74 6c 79 20 22 73 74 72 |th stric|tly "str|
|00005ac0| 75 63 74 75 72 65 2d 62 | 61 73 65 64 0d 0a 20 20 |ucture-b|ased.. |
|00005ad0| 20 73 75 62 74 79 70 69 | 6e 67 2e 22 20 53 65 63 | subtypi|ng." Sec|
|00005ae0| 6f 6e 64 6c 79 2c 20 62 | 79 2d 72 65 66 65 72 65 |ondly, b|y-refere|
|00005af0| 6e 63 65 20 73 65 6d 61 | 6e 74 69 63 73 20 68 61 |nce sema|ntics ha|
|00005b00| 76 65 20 6d 61 6e 79 20 | 22 77 65 6c 6c 20 6b 6e |ve many |"well kn|
|00005b10| 6f 77 6e 22 0d 0a 20 20 | 20 70 72 6f 62 6c 65 6d |own".. | problem|
|00005b20| 73 20 61 73 20 77 65 6c | 6c 2c 20 61 6e 64 20 74 |s as wel|l, and t|
|00005b30| 68 65 20 64 65 73 69 67 | 6e 65 72 73 20 6f 66 20 |he desig|ners of |
|00005b40| 4d 6f 64 75 6c 61 2d 33 | 20 63 68 6f 73 65 20 74 |Modula-3| chose t|
|00005b50| 6f 2c 20 73 65 65 6d 69 | 6e 67 6c 79 2c 0d 0a 20 |o, seemi|ngly,.. |
|00005b60| 20 20 69 67 6e 6f 72 65 | 20 74 68 6f 73 65 20 3b | ignore| those ;|
|00005b70| 2d 29 20 3b 2d 29 2e 20 | 4f 66 20 63 6f 75 72 73 |-) ;-). |Of cours|
|00005b80| 65 2c 20 69 6e 20 72 65 | 61 6c 69 74 79 2c 20 6e |e, in re|ality, n|
|00005b90| 65 69 74 68 65 72 20 73 | 65 74 20 6f 66 20 6c 61 |either s|et of la|
|00005ba0| 6e 67 75 61 67 65 0d 0a | 20 20 20 64 65 73 69 67 |nguage..| desig|
|00005bb0| 6e 65 72 73 20 69 67 6e | 6f 72 65 64 20 65 69 74 |ners ign|ored eit|
|00005bc0| 68 65 72 20 6f 66 20 74 | 68 65 73 65 20 69 73 73 |her of t|hese iss|
|00005bd0| 75 65 73 2e 20 4c 61 6e | 67 75 61 67 65 20 64 65 |ues. Lan|guage de|
|00005be0| 73 69 67 6e 20 69 6e 76 | 6f 6c 76 65 73 0d 0a 20 |sign inv|olves.. |
|00005bf0| 20 20 74 72 61 64 65 6f | 66 66 73 2e 20 59 6f 75 | tradeo|ffs. You|
|00005c00| 20 63 61 6e 20 63 6f 6d | 70 6c 61 69 6e 20 77 65 | can com|plain we|
|00005c10| 20 6d 61 64 65 20 74 68 | 65 20 77 72 6f 6e 67 20 | made th|e wrong |
|00005c20| 74 72 61 64 65 6f 66 66 | 2c 20 62 75 74 20 74 6f |tradeoff|, but to|
|00005c30| 0d 0a 20 20 20 63 6f 6e | 74 69 6e 75 65 20 74 6f |.. con|tinue to|
|00005c40| 20 68 61 72 70 20 6f 6e | 20 74 68 65 20 63 6c 61 | harp on| the cla|
|00005c50| 69 6d 20 74 68 61 74 20 | 77 65 20 22 69 67 6e 6f |im that |we "igno|
|00005c60| 72 65 64 22 20 74 68 69 | 6e 67 73 20 69 73 20 73 |red" thi|ngs is s|
|00005c70| 69 6c 6c 79 2e 20 57 65 | 0d 0a 20 20 20 73 74 75 |illy. We|.. stu|
|00005c80| 64 69 65 64 20 65 76 65 | 72 79 20 4f 4f 50 20 6c |died eve|ry OOP l|
|00005c90| 61 6e 67 75 61 67 65 20 | 75 6e 64 65 72 20 74 68 |anguage |under th|
|00005ca0| 65 20 73 75 6e 20 6f 6e | 20 77 68 69 63 68 20 77 |e sun on| which w|
|00005cb0| 65 20 63 6f 75 6c 64 20 | 66 69 6e 64 20 61 6e 79 |e could |find any|
|00005cc0| 0d 0a 20 20 20 77 72 69 | 74 74 65 6e 20 6f 72 20 |.. wri|tten or |
|00005cd0| 65 6c 65 63 74 72 6f 6e | 69 63 20 6d 61 74 65 72 |electron|ic mater|
|00005ce0| 69 61 6c 2e 20 57 65 20 | 63 68 6f 73 65 20 76 61 |ial. We |chose va|
|00005cf0| 6c 75 65 2d 62 61 73 65 | 64 20 73 65 6d 61 6e 74 |lue-base|d semant|
|00005d00| 69 63 73 20 66 6f 72 0d | 0a 20 20 20 77 68 61 74 |ics for.|. what|
|00005d10| 20 77 65 20 62 65 6c 69 | 65 76 65 20 61 72 65 20 | we beli|eve are |
|00005d20| 67 6f 6f 64 20 72 65 61 | 73 6f 6e 73 2c 20 62 61 |good rea|sons, ba|
|00005d30| 73 65 64 20 6f 6e 20 72 | 65 61 73 6f 6e 61 62 6c |sed on r|easonabl|
|00005d40| 65 20 74 72 61 64 65 6f | 66 66 73 2e 0d 0a 0d 0a |e tradeo|ffs.....|
|00005d50| 20 20 20 46 69 72 73 74 | 20 6f 66 20 61 6c 6c 2c | First| of all,|
|00005d60| 20 69 6e 20 74 68 65 20 | 61 62 73 65 6e 63 65 20 | in the |absence |
|00005d70| 6f 66 20 61 6e 20 69 6e | 74 65 67 72 61 74 65 64 |of an in|tegrated|
|00005d80| 20 67 61 72 62 61 67 65 | 20 63 6f 6c 6c 65 63 74 | garbage| collect|
|00005d90| 6f 72 2c 0d 0a 20 20 20 | 62 79 2d 72 65 66 65 72 |or,.. |by-refer|
|00005da0| 65 6e 63 65 20 73 65 6d | 61 6e 74 69 63 73 20 64 |ence sem|antics d|
|00005db0| 6f 65 73 6e 27 74 20 6d | 61 6b 65 20 6d 75 63 68 |oesn't m|ake much|
|00005dc0| 20 73 65 6e 73 65 2e 20 | 42 61 73 65 64 20 6f 6e | sense. |Based on|
|00005dd0| 20 76 61 72 69 6f 75 73 | 0d 0a 20 20 20 74 72 61 | various|.. tra|
|00005de0| 64 65 6f 66 66 73 2c 20 | 77 65 20 64 65 63 69 64 |deoffs, |we decid|
|00005df0| 65 64 20 61 67 61 69 6e | 73 74 20 72 65 71 75 69 |ed again|st requi|
|00005e00| 72 69 6e 67 20 61 6e 20 | 69 6e 74 65 67 72 61 74 |ring an |integrat|
|00005e10| 65 64 20 67 61 72 62 61 | 67 65 0d 0a 20 20 20 63 |ed garba|ge.. c|
|00005e20| 6f 6c 6c 65 63 74 6f 72 | 20 66 6f 72 20 41 64 61 |ollector| for Ada|
|00005e30| 20 39 58 2e 0d 0a 0d 0a | 20 20 20 53 65 63 6f 6e | 9X.....| Secon|
|00005e40| 64 6c 79 2c 20 6d 61 6e | 79 20 6f 66 20 74 68 65 |dly, man|y of the|
|00005e50| 20 22 6b 6e 6f 77 6e 22 | 20 70 72 6f 62 6c 65 6d | "known"| problem|
|00005e60| 73 20 77 69 74 68 20 62 | 79 2d 76 61 6c 75 65 20 |s with b|y-value |
|00005e70| 73 65 6d 61 6e 74 69 63 | 73 20 77 65 0d 0a 20 20 |semantic|s we.. |
|00005e80| 20 61 76 6f 69 64 65 64 | 2c 20 62 79 20 65 6c 69 | avoided|, by eli|
|00005e90| 6d 69 6e 61 74 69 6e 67 | 20 65 73 73 65 6e 74 69 |minating| essenti|
|00005ea0| 61 6c 6c 79 20 61 6c 6c | 20 63 61 73 65 73 20 6f |ally all| cases o|
|00005eb0| 66 20 22 69 6d 70 6c 69 | 63 69 74 0d 0a 20 20 20 |f "impli|cit.. |
|00005ec0| 74 72 75 6e 63 61 74 69 | 6f 6e 2e 22 20 4f 6e 65 |truncati|on." One|
|00005ed0| 20 6f 66 20 74 68 65 20 | 70 72 6f 62 6c 65 6d 73 | of the |problems|
|00005ee0| 20 77 69 74 68 20 74 68 | 65 20 43 2b 2b 20 76 65 | with th|e C++ ve|
|00005ef0| 72 73 69 6f 6e 20 6f 66 | 20 22 76 61 6c 75 65 0d |rsion of| "value.|
|00005f00| 0a 20 20 20 73 65 6d 61 | 6e 74 69 63 73 22 20 69 |. sema|ntics" i|
|00005f10| 73 20 74 68 61 74 20 6f | 6e 20 61 73 73 69 67 6e |s that o|n assign|
|00005f20| 6d 65 6e 74 20 61 6e 64 | 20 70 61 72 61 6d 65 74 |ment and| paramet|
|00005f30| 65 72 20 70 61 73 73 69 | 6e 67 2c 20 69 6d 70 6c |er passi|ng, impl|
|00005f40| 69 63 69 74 0d 0a 20 20 | 20 74 72 75 6e 63 61 74 |icit.. | truncat|
|00005f50| 69 6f 6e 20 63 61 6e 20 | 74 61 6b 65 20 70 6c 61 |ion can |take pla|
|00005f60| 63 65 20 6d 79 73 74 65 | 72 69 6f 75 73 6c 79 2c |ce myste|riously,|
|00005f70| 20 6d 65 61 6e 69 6e 67 | 20 74 68 61 74 20 61 20 | meaning| that a |
|00005f80| 76 61 6c 75 65 20 74 68 | 61 74 0d 0a 20 20 20 73 |value th|at.. s|
|00005f90| 74 61 72 74 65 64 20 69 | 74 73 20 6c 69 66 65 20 |tarted i|ts life |
|00005fa0| 72 65 70 72 65 73 65 6e | 74 69 6e 67 20 6f 6e 65 |represen|ting one|
|00005fb0| 20 6b 69 6e 64 20 6f 66 | 20 74 68 69 6e 67 20 67 | kind of| thing g|
|00005fc0| 65 74 73 20 74 72 75 6e | 63 61 74 65 64 0d 0a 20 |ets trun|cated.. |
|00005fd0| 20 20 75 6e 69 6e 74 65 | 6e 74 69 6f 6e 61 6c 6c | uninte|ntionall|
|00005fe0| 79 20 73 6f 20 74 68 61 | 74 20 69 74 20 6c 6f 6f |y so tha|t it loo|
|00005ff0| 6b 73 20 6c 69 6b 65 20 | 61 20 76 61 6c 75 65 20 |ks like |a value |
|00006000| 6f 66 20 73 6f 6d 65 20 | 61 6e 63 65 73 74 6f 72 |of some |ancestor|
|00006010| 20 74 79 70 65 2e 0d 0a | 20 20 20 54 68 69 73 20 | type...| This |
|00006020| 69 73 20 6c 61 72 67 65 | 6c 79 20 62 65 63 61 75 |is large|ly becau|
|00006030| 73 65 20 74 68 65 20 6e | 61 6d 65 20 6f 66 20 61 |se the n|ame of a|
|00006040| 20 43 2b 2b 20 63 6c 61 | 73 73 20 6d 65 61 6e 73 | C++ cla|ss means|
|00006050| 20 64 69 66 66 65 72 6e | 74 20 74 68 69 6e 67 73 | differn|t things|
|00006060| 0d 0a 20 20 20 64 65 70 | 65 6e 64 69 6e 67 20 6f |.. dep|ending o|
|00006070| 6e 20 74 68 65 20 63 6f | 6e 74 65 78 74 2e 20 57 |n the co|ntext. W|
|00006080| 68 65 6e 20 79 6f 75 20 | 64 65 63 6c 61 72 65 20 |hen you |declare |
|00006090| 61 6e 20 6f 62 6a 65 63 | 74 2c 20 74 68 65 20 6e |an objec|t, the n|
|000060a0| 61 6d 65 20 6f 66 20 74 | 68 65 0d 0a 20 20 20 63 |ame of t|he.. c|
|000060b0| 6c 61 73 73 20 64 65 74 | 65 72 6d 69 6e 65 73 20 |lass det|ermines |
|000060c0| 74 68 65 20 22 65 78 61 | 63 74 20 63 6c 61 73 73 |the "exa|ct class|
|000060d0| 22 20 6f 66 20 74 68 65 | 20 6f 62 6a 65 63 74 2e |" of the| object.|
|000060e0| 20 54 68 65 20 73 61 6d | 65 20 74 68 69 6e 67 0d | The sam|e thing.|
|000060f0| 0a 20 20 20 61 70 70 6c | 69 65 73 20 74 6f 20 61 |. appl|ies to a|
|00006100| 20 62 79 2d 76 61 6c 75 | 65 20 70 61 72 61 6d 65 | by-valu|e parame|
|00006110| 74 65 72 2e 20 48 6f 77 | 65 76 65 72 2c 20 66 6f |ter. How|ever, fo|
|00006120| 72 20 72 65 66 65 72 65 | 6e 63 65 73 20 61 6e 64 |r refere|nces and|
|00006130| 20 70 6f 69 6e 74 65 72 | 73 2c 0d 0a 20 20 20 74 | pointer|s,.. t|
|00006140| 68 65 20 6e 61 6d 65 20 | 6f 66 20 61 20 63 6c 61 |he name |of a cla|
|00006150| 73 73 20 73 74 61 6e 64 | 73 20 66 6f 72 20 74 68 |ss stand|s for th|
|00006160| 61 74 20 63 6c 61 73 73 | 20 61 6e 64 20 61 6c 6c |at class| and all|
|00006170| 20 6f 66 20 69 74 73 20 | 64 65 72 69 76 61 74 69 | of its |derivati|
|00006180| 76 65 73 2e 0d 0a 20 20 | 20 42 75 74 20 73 69 6e |ves... | But sin|
|00006190| 63 65 2c 20 69 6e 20 43 | 2b 2b 2c 20 61 20 76 61 |ce, in C|++, a va|
|000061a0| 6c 75 65 20 6f 66 20 61 | 20 73 75 62 63 6c 61 73 |lue of a| subclas|
|000061b0| 73 20 69 73 20 61 6c 77 | 61 79 73 20 61 63 63 65 |s is alw|ays acce|
|000061c0| 70 74 61 62 6c 65 20 77 | 68 65 72 65 20 61 0d 0a |ptable w|here a..|
|000061d0| 20 20 20 76 61 6c 75 65 | 20 6f 66 20 61 20 67 69 | value| of a gi|
|000061e0| 76 65 6e 20 63 6c 61 73 | 73 20 69 73 20 65 78 70 |ven clas|s is exp|
|000061f0| 65 63 74 65 64 2c 20 79 | 6f 75 20 63 61 6e 20 67 |ected, y|ou can g|
|00006200| 65 74 20 69 6d 70 6c 69 | 63 69 74 20 74 72 75 6e |et impli|cit trun|
|00006210| 63 61 74 69 6f 6e 20 61 | 73 0d 0a 20 20 20 70 61 |cation a|s.. pa|
|00006220| 72 74 20 6f 66 20 61 73 | 73 69 67 6e 6d 65 6e 74 |rt of as|signment|
|00006230| 20 61 6e 64 20 62 79 2d | 76 61 6c 75 65 20 70 61 | and by-|value pa|
|00006240| 72 61 6d 65 74 65 72 20 | 70 61 73 73 69 6e 67 2e |rameter |passing.|
|00006250| 20 49 6e 20 41 64 61 20 | 39 58 2c 20 77 65 20 61 | In Ada |9X, we a|
|00006260| 76 6f 69 64 0d 0a 20 20 | 20 74 68 65 20 69 6d 70 |void.. | the imp|
|00006270| 6c 69 63 69 74 20 74 72 | 75 6e 63 61 74 69 6f 6e |licit tr|uncation|
|00006280| 20 62 65 63 61 75 73 65 | 20 77 65 20 73 75 70 70 | because| we supp|
|00006290| 6f 72 74 20 61 73 73 69 | 67 6e 6d 65 6e 74 20 66 |ort assi|gnment f|
|000062a0| 6f 72 20 22 63 6c 61 73 | 73 2d 77 69 64 65 22 0d |or "clas|s-wide".|
|000062b0| 0a 20 20 20 74 79 70 65 | 73 2c 20 77 68 69 63 68 |. type|s, which|
|000062c0| 20 6e 65 76 65 72 20 69 | 6d 70 6c 69 63 69 74 6c | never i|mplicitl|
|000062d0| 79 20 74 72 75 6e 63 61 | 74 65 73 2c 20 61 6e 64 |y trunca|tes, and|
|000062e0| 20 6f 6e 65 20 6d 75 73 | 74 20 64 6f 20 61 6e 20 | one mus|t do an |
|000062f0| 65 78 70 6c 69 63 69 74 | 0d 0a 20 20 20 63 6f 6e |explicit|.. con|
|00006300| 76 65 72 73 69 6f 6e 20 | 74 6f 20 64 6f 20 61 6e |version |to do an|
|00006310| 20 61 73 73 69 67 6e 6d | 65 6e 74 20 74 68 61 74 | assignm|ent that|
|00006320| 20 74 72 75 6e 63 61 74 | 65 73 2e 20 50 61 72 61 | truncat|es. Para|
|00006330| 6d 65 74 65 72 20 70 61 | 73 73 69 6e 67 20 6e 65 |meter pa|ssing ne|
|00006340| 76 65 72 0d 0a 20 20 20 | 69 6d 70 6c 69 63 69 74 |ver.. |implicit|
|00006350| 6c 79 20 74 72 75 6e 63 | 61 74 65 73 2c 20 65 76 |ly trunc|ates, ev|
|00006360| 65 6e 20 69 66 20 61 6e | 20 69 6d 70 6c 69 63 69 |en if an| implici|
|00006370| 74 20 63 6f 6e 76 65 72 | 73 69 6f 6e 20 69 73 20 |t conver|sion is |
|00006380| 70 65 72 66 6f 72 6d 65 | 64 20 61 73 0d 0a 20 20 |performe|d as.. |
|00006390| 20 70 61 72 74 20 6f 66 | 20 63 61 6c 6c 69 6e 67 | part of| calling|
|000063a0| 20 61 6e 20 69 6e 68 65 | 72 69 74 65 64 20 73 75 | an inhe|rited su|
|000063b0| 62 70 72 6f 67 72 61 6d | 2e 0d 0a 0d 0a 0d 0a 35 |bprogram|.......5|
|000063c0| 2e 39 3a 20 57 68 61 74 | 20 69 73 20 74 68 65 20 |.9: What| is the |
|000063d0| 64 69 66 66 65 72 65 6e | 63 65 20 62 65 74 77 65 |differen|ce betwe|
|000063e0| 65 6e 20 61 20 63 6c 61 | 73 73 2d 77 69 64 65 20 |en a cla|ss-wide |
|000063f0| 61 63 63 65 73 73 20 74 | 79 70 65 20 61 6e 64 20 |access t|ype and |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.