> You have to instantiate another object to inspect the first one! Here's Python, just as an example. (Most languages would be simpler. As with most things, it would be difficult to find a language where reflection was more clunky than in PHP.)
I was about to agree with you then I remembered the work put into the Newspeak language (which I was once hopeful would replace Smalltalk as my favorite).
In Newspeak, reflection is always indirect because of security reasons.
You ask the system to give you a Mirror, and that mirror can reflect against an object you have access to. Security name-spacing and authorization is encapsulated into the mirror, so you can say:
- Give unauthorized users access to your VM with live objects, but they can't change anything because their Mirrors only allow for inspection.
- Make changes to a live object indirect. So if you add an attribute to object live object X, the system will go out of band---say to the database or announce to remote systems---that the change occurred and further action may be needed. That's great for access audits.
In that respect, PHPs reflection class isn't too bad. Though I think its a bit underpowered.
Comments
> You have to instantiate another object to inspect the first one! Here's Python, just as an example. (Most languages would be simpler. As with most things, it would be difficult to find a language where reflection was more clunky than in PHP.)
I was about to agree with you then I remembered the work put into the Newspeak language (which I was once hopeful would replace Smalltalk as my favorite).
In Newspeak, reflection is always indirect because of security reasons.
You ask the system to give you a Mirror, and that mirror can reflect against an object you have access to. Security name-spacing and authorization is encapsulated into the mirror, so you can say:
- Give unauthorized users access to your VM with live objects, but they can't change anything because their Mirrors only allow for inspection.
- Make changes to a live object indirect. So if you add an attribute to object live object X, the system will go out of band---say to the database or announce to remote systems---that the change occurred and further action may be needed. That's great for access audits.
In that respect, PHPs reflection class isn't too bad. Though I think its a bit underpowered.