home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.pascal:6680 comp.object:4256
- Path: sparky!uunet!olivea!charnel!rat!usc!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!news.ccs.queensu.ca!mast.queensu.ca!dmurdoch
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Newsgroups: comp.lang.pascal,comp.object
- Subject: Re: BP/TP OOP is missing something...
- Message-ID: <dmurdoch.284.722095796@mast.queensu.ca>
- Date: 18 Nov 92 14:09:56 GMT
- References: <dmurdoch.282.722020256@mast.queensu.ca> <10773@vice.ICO.TEK.COM> <dmurdoch.171.722054313@mast.queensu.ca> <1992Nov18.104536.9985@jyu.fi>
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- Lines: 44
-
- In article <1992Nov18.104536.9985@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes:
- >There is at least one spot in standard Pascal where automatic initialisation
- >happens: file variables (admittedly a murky part of Pascal semantics).
- >After _only_ declaring a file variable, it is also initialised to
- >a well-defined state such that you cannot do any other operations
- >before calling 'reset' or 'rewrite'.
-
- That's another difference between TP and standard Pascal then: in TP, file
- variables remain undefined until you do an Assign (a TP procedure) to set
- their state.
-
- >I would guess that good Pascal implementation may also initialise
- >pointer variables to NIL so that using them before assignment
- >will not cause catastrophic effects.
-
- On a PC in "real" mode, NIL is likely the most catastrophic value to
- initialize a pointer to :-). TP doesn't initialize pointers, but at
- least one TP clone (Pascal+ from Stony Brook) does.
-
- >The idea is that all other uses of an object happen between its
- >initialisation and the finalisation; of course you cannot change
- >an object after it has been destroyed. Your matrix example would
- >be much easier to do in Simula or C++ than Pascal, because they allow
- >variables to be declared even within blocks (not only in function and
- >procedure headers), and they allow also initialisation parameters.
-
- I agree that Pascal doesn't handle my matrix example well, even with
- conformant arrays. However, it's really not a problem at all in TP: just
- declare a matrix object, but don't assign a size to it until you know what
- the size will be.
-
- >In any flavour of OO Pascal without such parameters, the constructor
- >of a general matrix class (i.e. without fixed dimensions) would most
- >naturally create only a "handle" for an actual matrix.
-
- This doesn't seem like a very clean solution. Does it mean that I'd have
- an array without a size after the automatic initialization? Then I'd have
- to send a size message to it before I could use it? It sounds to me as
- though the size message is the real initialization; automatic initialization
- doesn't work here, because it doesn't produce a usable object (i.e.
- establish the invariants of the class, as you said).
-
- Duncan Murdoch
- dmurdoch@mast.queensu.ca
-