Hi,
I wonder if there's a way to hide a class so only another object/class from the same module can instatiate new objects of the program.
I tried to declare the class as `static', which hides it, well enough. But given a instance of this class makes it possible to get around the lock by doing:
program p = object_program( my_obj ); object new_obj = p( args ... );
Any way to prevent this? Not a big deal, really, just a thought.
//Andreas
You might want to try private. Private is probably better than static. (IMHO, static should even be changed to do what static does in C++.)
/ Marcus Agehall (nu med semester)
Previous text:
2004-07-20 13:12: Subject: Access control
Hi,
I wonder if there's a way to hide a class so only another object/class from the same module can instatiate new objects of the program.
I tried to declare the class as `static', which hides it, well enough. But given a instance of this class makes it possible to get around the lock by doing:
program p = object_program( my_obj ); object new_obj = p( args ... );
Any way to prevent this? Not a big deal, really, just a thought.
//Andreas
/ Kaos
private is almost never right, since you can inherit and modify then.
/ Martin Nilsson (DivX Networks)
Previous text:
2004-07-20 16:10: Subject: Access control
You might want to try private. Private is probably better than static. (IMHO, static should even be changed to do what static does in C++.)
/ Marcus Agehall (nu med semester)
I dont think so. Pike is a very public language; if a programmer wants to shoot himself in the feet multiple times, Pike wont stop him...
If you want real security, however, there are other ways to solve that. You could for instance remove object_program from the namespace, or use the more advanced and versatile security system. (Someone else has to point you how to use that though, I never tried.)
/ Mirar
Previous text:
2004-07-20 13:12: Subject: Access control
Hi,
I wonder if there's a way to hide a class so only another object/class from the same module can instatiate new objects of the program.
I tried to declare the class as `static', which hides it, well enough. But given a instance of this class makes it possible to get around the lock by doing:
program p = object_program( my_obj ); object new_obj = p( args ... );
Any way to prevent this? Not a big deal, really, just a thought.
//Andreas
/ Kaos
pike-devel@lists.lysator.liu.se