Hi zinga,
Well I noticed in some of your plugins that you "bypass" the private keyword such as in the parse options.
What's the purpose of private/protected/etc if it still can be bypassed?
Or am I missing something?
I haven't tried it myself since I always respect if the property/method is private, protected or public but since you use it, it should work.
Yes, it's a hack, and something you probably generally "shouldn't" be doing. It only really works because of how PHP works - well, PHP itself is bit of a quirky language which seems to borrow ideas from languages like C++ in which it shouldn't be, as a scripting language.
I do a number of other hacks as well, such as gaining control of objects etc. Whilst I do try to avoid these types of hacks, sometimes it's impossible or very difficult to achieve something without them, or if you don't want people to have to perform a lot of code edits.
I honestly don't really know why MyBB wants to make use of private/protected variables - they don't really have a true separation of objects, which is what this is really useful for, and it makes plugins more difficult to write.
One example which comes to mind is string concatenation with the DB class - there really should be a $db->concat_string type function, rather than check the DB type every time a concatenation is needed.
Also, a scripting language doesn't quite fit too well with casual paradigms in compiled languages, for example, the getter/setter idea that a number of classes have:
PHP Code:
class A {
private $var;
public function setVar($val) { return $this->var = $val; }
public function &getVar() { return $this->var; }
}
|
Whilst the above may have certain uses in C++/Java etc, in PHP, most of the time, it just adds a lot of overhead without actually improving anything.
In general, I don't think being pedantic about scope is really my way of doing things.
Okay thanks for the explanation
(07-30-2010 07:30 AM)Technoman Wrote: [ -> ]Just remember I know nothing about coding
No offense, but perhaps you should think twice about commenting on something you don't understand then.
(07-30-2010 07:30 AM)Technoman Wrote: [ -> ]Zinga
I read your last post and what you mentioned about php & c++ is true http://cboard.cprogramming.com/cplusplus...http://cboard.cprogramming.com/cplusplus-programming/118653-can-cplusplus-replace-php.html#
It could be easier to write a system using both languages...
Just remember I know nothing about coding but in real life you can have a word in different languages that are similar meaning, BUT in some languages there are certain words that do have a more powerful meaning of expression then others.
PHP is a scripting language. C++ is a programming language that must be compiled before you can run anything you code with it. They're completely different things (even though PHP was coded with C++), you can't just use both languages in the same code. Unless your C++ program also comes with a PHP parser, etc..
You could use them together in a few ways (PHP extension, exec, etc), but that's not that important anyway...