Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

General Encapsulation vs Class Encapsulation

Name: Anonymous 2007-12-16 22:08

In general, what I am talking about is a general purpose alternative to private, that being hidden. This is a general purpose encapsulation that can be used anywhere, and it can't be accessed or redefined in sub-blocks. Consider what's below:

Global Scope
hidden int _hidden_static;
_hidden_static=0; //Fine
void some_func() {_hidden_static=0;} //Illegal


Local Scope
void some_func() {
    hidden int _hidden_local;

    _hidden_local=0;   //Fine
    {_hidden_local=0;} //Illegal
}


Class Scope
It is the same as private except that the members cannot be redefined in any scope, including the class methods. Any polymorphic method would of course have to be able to make an exception to the redefinition rule.

What do you think of this?

Name: Anonymous 2007-12-16 22:16

What would be the point?

Name: Anonymous 2007-12-16 22:47

>>1
That is the worst idea I've ever heard of in my life.

Name: Anonymous 2007-12-16 23:02

>>2
Serious question, by the way. I'm having trouble envisioning a situation in which this would be as useful.

Name: Anonymous 2007-12-16 23:08

>>2
Consider:
hidden unsigned int y = +constant;
leaf for (hidden unsigned int x = 0; x < y; ++x) { ... }

Incremental loops like the above are guaranteed to terminate.

There are other benefits, but I'll leave you to think about them.

Name: Anonymous 2007-12-16 23:27

>>5
I don't see that as a benefit. You're not writing an interface that many types of code could appear inside, you're writing the body of a loop. You *know* which variables are in use because the body of code in question is less than a screen long. You would have to be an idiot to start using y for something in your loop body without declaring it, and if you declare it twice the compiler will catch it.

It could potentially be useful when writing code-generating code. I might use this when writing a macro in Common Lisp, for example, if there weren't other easy mechanisms for avoiding variable capture and if adding this feature wouldn't break the semantics of the language.

This seems like its solving a problem that doesn't occur. Don't leave me to think about some nebulous "other benefits". If they exist, out with them!

Name: Anonymous 2007-12-16 23:44

>>2,4
Agreed.

>>5
I still don't see the point. It seems like a pretty useless feature to me.
Sure, it could be useful for an absolute retard programmer, but I don't see enough benefit to include it in any language, though including it adds more confusion to what the code does, rather than simplifying it or making it more readable.

Name: Anonymous 2007-12-17 3:58

private/public is already to OOP/ENTERPRISE to me.

Name: Anonymous 2007-12-17 4:07

>>8
go away now. the real programmers are talking.

Name: Anonymous 2007-12-17 4:37

You probably should have started with a problem and worked out a solution for it, rather than the other way around.

Name: Anonymous 2007-12-17 12:14

IT'S CALLED CONST YOU NIMWIT

Name: novice programmer 2007-12-17 12:29

>>1

The reason there are public and private declarations is so that clients cannot violate the WALL OF ADT OPERATIONS.

Hidden only has relevance inside that one class.  Since you control everything about the class you write, if you don't want a variable to be accessed in a sub-block, don't write it there.

Name: Anonymous 2007-12-17 15:05

>>11
is even dumber than OP.

Name: Anonymous 2007-12-17 15:14

>>1
Create a generic factory factory that encapsulates factories for general encapsulation factory interface generators.

Name: Anonymous 2007-12-17 23:43

>>14
Why don't you write up a factory interface generator for that, then we can dialogue about costflow production protocols and reducing TCO for our OH MY GOD THERE'S A HUGE FUCKING COCK IN MY ASS OH FUCK GET IT OUT GETITOUTGETITOUTGETITOUTGETITOUT

Name: Anonymous 2007-12-18 0:36

ENTERPRISE BUSINESS RULES ENGINE

Name: Anonymous 2009-03-06 12:51

Get used to the halting problem properties.

Don't change these.
Name: Email:
Entire Thread Thread List