Re: Why less emphasis on private data?
- From: Jussi Salmela <tiedon_jano@xxxxxxxxxxx>
- Date: Mon, 08 Jan 2007 17:37:25 GMT
Neil Cerutti kirjoitti:
On 2007-01-08, hg <hg@xxxxxxxxxx> wrote:sturlamolden wrote:
The designers of Java, C++, C#, Ada95, Delphi, etc. seem to think that
if an object's 'internal' variables or states cannot be kept private,
programmers get an irresistible temptation to mess with them in
malicious ways. But if you are that stupid, should you be programming
in any language? The most widely used language is still C, and there is
no concept of private data in C either, nor is it needed.
void test(void)
{
static int i;
}
Do you agree that i is "private" to test ?
In C one uses the pointer to opaque struct idiom to hide data.
For example, the standard FILE pointer.
To surlamolden: I don't know how you define private, but if one defines in C an external static variable i.e. a variable outside any functions, on the file level, the scope of the variable is that file only.
To hg: One does not need in C the static keyword to make a variable defined inside a function i.e. a so called 'automatic variable' private to that test. Automatic variables are private to their function by definition. The static keyword makes the variable permanent i.e. it keeps its value between calls but it is of course private also.
To Neil Cerutti: If a programmer in C has got a pointer to some piece of memory, that piece is at the mercy of the programmer. There's no data hiding at all in this case.
To whom it may concern: please stop comparing C and Python with regard to privacy and safety. They are two different worlds altogether. Believe me: I've been in this world for 2.5 years now after spending 19 years in the C world.
Cheers,
Jussi
.
- Follow-Ups:
- Re: Why less emphasis on private data?
- From: sturlamolden
- Re: Why less emphasis on private data?
- From: Neil Cerutti
- Re: Why less emphasis on private data?
- From: Chris Mellon
- Re: Why less emphasis on private data?
- References:
- Why less emphasis on private data?
- From: time.swift@xxxxxxxxx
- Re: Why less emphasis on private data?
- From: sturlamolden
- Re: Why less emphasis on private data?
- From: hg
- Re: Why less emphasis on private data?
- From: Neil Cerutti
- Why less emphasis on private data?
- Prev by Date: Re: Walking The Right Path
- Next by Date: Re: where is python on linux?
- Previous by thread: Re: Why less emphasis on private data?
- Next by thread: Re: Why less emphasis on private data?
- Index(es):
Relevant Pages
|