- Problem with pointer semantics

From: CFB Software <"CFB>
Date: Tue, 20 Jun 2006 17:27:02 +0930

----boundary-LibPST-iamunique-1891777678_-_-
Content-type: text/plain

> -----Original Message-----
> From: blackbox{([at]})nowhere.xy
> Behalf Of Rex Couture
> Sent: Tuesday, 20 June 2006 4:18 PM
> To: BlackBox Mailing List
> Subject: [BlackBox] - Problem with pointer semantics
>
>
> Yes, the type declaration will help you if you don't
> make a mistake.
> Compilers are supposed to be good at catching that kind of
> mistake, but in this case they don't.

That it is because it is not necessarily a mistake. The compiler can only
check what you have done not what you intended to do.

>
> After thinking about it some more, if I were
> designing a language, I think I might forbid assigning a
> pointer except with a predefined procedure.
> For example:
>
> ASSIGN (b, a); (* allowed *)
>

Does that mean b := a or a := b? What if you make a mistake and get the
wrong way around - is the compiler going to be able to tell you?

  b := ALIAS(a) might be less ambiguous.

However I don't have a problem with being able to assign pointers myself. If
I was programming a linked list and implementing the related traversal
routines, for example, it would be very cumbersome to have to use a
pseudo-function for pointer assignment.

The general rule is to use pointers only when you absolutely have to.


> I was hoping someone had some sort of magic. Since
> they don't, I'm sticking to old-fashioned Hungarian notation.
>

To me that is like using a sledgehammer to crack a walnut. Hungarian
notation is more useful when using languages like C as the language itself
does not protect you from making silly type-compatibility errors. Including
clues as to the type of the variable in the name of the variable helps to
highlight these sorts of mistakes. In the case of Pascal and its
derivatives, type compatibility is rigidly enforced by the compiler - it
will let you know at compile time if you do something stupid.

I don't like Hungarian notation because I like to be able to *read* code,
like reading phrases. I find it impossible to pronounce words like 'lpszHDC'
for instance.

Regards,

Chris Burrows
CFB Software
http://www.cfbsoftware.com
 

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-1891777678_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwX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XHBhcg0KXHBhcg0KSSBkb24ndCBsaWtlIEh1bmdhcmlhbiBub3RhdGlvbiBiZWNh
dXNlIEkgbGlrZSB0byBiZSBhYmxlIHRvICpyZWFkKiBjb2RlLFxwYXINCmxpa2UgcmVhZGluZyBw
aHJhc2VzLiBJIGZpbmQgaXQgaW1wb3NzaWJsZSB0byBwcm9ub3VuY2Ugd29yZHMgbGlrZSAnbHBz
ekhEQydccGFyDQpmb3IgaW5zdGFuY2UuIFxwYXINClxwYXINClJlZ2FyZHMsXHBhcg0KXHBhcg0K
Q2hyaXMgQnVycm93c1xwYXINCkNGQiBTb2Z0d2FyZVxwYXINCmh0dHA6Ly93d3cuY2Zic29mdHdh
cmUuY29tXHBhcg0KIFxwYXINClxwYXINCi0tLSBCbGFja0JveFxwYXINCi0tLSBzZW5kIHN1Ympl
Y3QgSEVMUCBvciBVTlNVQlNDUklCRSB0byBibGFja2JveEBvYmVyb24uY2h9fQAAFOMTYWjCUgBY



----boundary-LibPST-iamunique-1891777678_-_---
Received on Tue Jun 20 2006 - 09:57:02 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:50 UTC