- Problem with pointer semantics

From: Marco Ciot <"Marco>
Date: Tue, 20 Jun 2006 13:04:57 +0200

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

My point of view is that Hungarian notation is quite useless and
contraproductive!!!
I cannot understand how anybody could invent such a thing!
Instead of type prefix, file prefixes add MUCH more value to any C-code!!!

Regarding the subject of pointer assignments I see the problem more on the
side of record or array assignments.

I don't see much use in assigning an entire array to another as easily as "a
:= b".
In Oberon you had to use "COPY(b, a)".
However array assignment make a lot of sense in case of strings which really
deserve special treatment. (But so do ARRAYs of BYTE!)
Same thing with record assignments. I very often would like to easily assign
extenstions to static base records, which is not possible even if the
dynamic type is the same.

The solution might really a special copy procedure for records and arrays.

At the same time such a thing can easily be implemented in a SYSTEM module
"Blocks".

Ceterum Censeo: Writing Readable Code is still the responsibility of the
programmer!

Regards
Marco


-----Original Message-----
From: blackbox{([at]})nowhere.xy
Software
Sent: Tuesday, June 20, 2006 09:57
To: BlackBox Mailing List
Subject: [BlackBox] - Problem with pointer semantics


> -----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

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



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

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIE15IHBvaW50IG9mIHZpZXcgaXMgdGhhdCBIdW5n
YXJpYW4gbm90YXRpb24gaXMgcXVpdGUgdXNlbGVzcyBhbmRccGFyDQpjb250cmFwcm9kdWN0aXZl
ISEhXHBhcg0KSSBjYW5ub3QgdW5kZXJzdGFuZCBob3cgYW55Ym9keSBjb3VsZCBpbnZlbnQgc3Vj
aCBhIHRoaW5nIVxwYXINCkluc3RlYWQgb2YgdHlwZSBwcmVmaXgsIGZpbGUgcHJlZml4ZXMgYWRk
IE1VQ0ggb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dmFy
aWFibGUgaGVscHMgdG9ccGFyDQpoaWdobGlnaHQgdGhlc2Ugc29ydHMgb2YgbWlzdGFrZXMuIElu
IHRoZSBjYXNlIG9mIFBhc2NhbCBhbmQgaXRzXHBhcg0KZGVyaXZhdGl2ZXMsIHR5cGUgY29tcGF0
aWJpbGl0eSBpcyByaWdpZGx5IGVuZm9yY2VkIGJ5IHRoZSBjb21waWxlciAtIGl0XHBhcg0Kd2ls
bCBsZXQgeW91IGtub3cgYXQgY29tcGlsZSB0aW1lIGlmIHlvdSBkbyBzb21ldGhpbmcgc3R1cGlk
LlxwYXINClxwYXINCkkgZG9uJ3QgbGlrZSBIdW5nYXJpYW4gbm90YXRpb24gYmVjYXVzZSBJIGxp
a2UgdG8gYmUgYWJsZSB0byAqcmVhZCogY29kZSxccGFyDQpsaWtlIHJlYWRpbmcgcGhyYXNlcy4g
SSBmaW5kIGl0IGltcG9zc2libGUgdG8gcHJvbm91bmNlIHdvcmRzIGxpa2UgJ2xwc3pIREMnXHBh
cg0KZm9yIGluc3RhbmNlLlxwYXINClxwYXINClJlZ2FyZHMsXHBhcg0KXHBhcg0KQ2hyaXMgQnVy
cm93c1xwYXINCkNGQiBTb2Z0d2FyZVxwYXINCmh0dHA6Ly93d3cuY2Zic29mdHdhcmUuY29tXHBh
cg0KXHBhcg0KXHBhcg0KLS0tIEJsYWNrQm94XHBhcg0KLS0tIHNlbmQgc3ViamVjdCBIRUxQIG9y
IFVOU1VCU0NSSUJFIHRvIGJsYWNrYm94QG9iZXJvbi5jaFxwYXINClxwYXINCi0tLSBCbGFja0Jv
eFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklCRSB0byBibGFja2JveEBv
YmVyb24uY2hccGFyDQpccGFyDQp9


----boundary-LibPST-iamunique-2011243547_-_---
Received on Tue Jun 20 2006 - 13:04:57 UTC

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