[PHP-DEV] RE: [Zend Engine 2] Re: [PHP-DEV] API Thoughts?
uups, i wanted to post this to the dev-list. -Original Message- From: Harald Radi [mailto:[EMAIL PROTECTED]] Sent: Monday, August 27, 2001 11:33 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [Zend Engine 2] Re: [PHP-DEV] API Thoughts? I'd prefer to code the OO wrapper in PHP -- it stops me from having to be aware of changes to the Zend OO model and writing code that works with both the functional interface and the OO interface (some form of automatic handling of this would be a very cool/useful feature for Zend, imho). writing an oo wrapper for your functional interface in c won't be a big deal and other extensions would benefit from it as they could return adt-types in a oo way which they can't with your attempt. they would have to create a PEAR wrapper around the existing resource they get, which looks quite messy. if the only reason against this is, that you don't wan't to deal with zends oo api, i'd write a lean wrapper for your functions as it is really no work. harald. ps.: this would be another reason for your first suggestion, as only tree_insert(), tree_remove(), .. need to be wrapped and not all those avl_*(), rb_*(), .. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
On Mon, 27 Aug 2001 00:29:26 -0400 (EDT), Sterling Hughes wrote: The current way I have it organized is as follows: php4/pear/ADT.php php4/pear/ADT/LList.php php4/pear/ADT/Stack.php php4/pear/ADT/Queue.php php4/pear/ADT/AVLtree.php php4/pear/ADT/BTree.php php4/pear/ADT/RBTree.php php4/pear/ADT/Heap.php php4/pear/ADT/Set.php Just a sidenote: All new contributions to PEAR have to be commited to /pear, not to /php4/pear (this directory is only there until the PEAR infrastructure is running). - Martin -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
Alright. I think I've stated this before, but, just so everyone knows: I'm gonna kick and scream whenever I think something is being done for expediency and it's the wrong thing to do from a design/engineering perspective. You're probably all gonna hate me, but someone has to do it. Quoting Sterling Hughes [EMAIL PROTECTED]: The above are imho pretty ugly, and this is meant as more of a language level feature, I'm thinking of using PEAR as more of a method of distribution than a mindset. They are only ugly because we don't have namespaces in PHP. If we had namespaces, then your code example (which I'll comment on below) would be fine. But as is, the way you are organizing the code causes namespace pollution. This isn't something that we can stop end-user developers from doing, but if we don't strictly adhere to namespace standards in the code in PEAR, _no one_ will do it, and we will have a mess on our hands. Some standards are only worth having if you enforce them. I think class naming is one of them. The current way I have it organized is as follows: php4/pear/ADT.php php4/pear/ADT/LList.php php4/pear/ADT/Stack.php php4/pear/ADT/Queue.php php4/pear/ADT/AVLtree.php php4/pear/ADT/BTree.php php4/pear/ADT/RBTree.php php4/pear/ADT/Heap.php php4/pear/ADT/Set.php If you want the tree classes to share the same API - or even a subset of it, they _really_ should be subclasses of an ADT_Tree class. then you could do something like: ?php require_once('ADT/Queue.php'); $sounds = new Queue; [snip] If you make that $sounds = new ADT_Queue(); ... then I'm happy. (pet peeve: require_once and friends are statements. You don't need the parentheses.) -chuck -- Charles Hagenbuch, [EMAIL PROTECTED] Some fallen angels have their good reasons. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
[Sterling Hughes [EMAIL PROTECTED]] On Sun, 26 Aug 2001, Chuck Hagenbuch wrote: Quoting Sterling Hughes [EMAIL PROTECTED]: Jep -- I'm writing PEAR OO wrappers for every ADT that I implement in a functional manner. I'm think for the OO wrappers, seperate class names wouldn't be horrible, something like: $tree = new AVLTree; Please stick to the naming conventions, which would make this: $tree = new ADT_Tree_AVL(); ... or something similar. Also, you could easily have a factory method: $tree = ADT::factory('tree_avl'); or: $tree = ADT_Tree::factory('avl'); The above are imho pretty ugly, and this is meant as more of a language level feature, I'm thinking of using PEAR as more of a method of distribution than a mindset. I'd prefer to code the OO wrapper in PHP -- it stops me from having to be aware of changes to the Zend OO model and writing code that works with both the functional interface and the OO interface (some form of automatic handling of this would be a very cool/useful feature for Zend, imho). The current way I have it organized is as follows: php4/pear/ADT.php php4/pear/ADT/LList.php php4/pear/ADT/Stack.php php4/pear/ADT/Queue.php php4/pear/ADT/AVLtree.php php4/pear/ADT/BTree.php php4/pear/ADT/RBTree.php php4/pear/ADT/Heap.php php4/pear/ADT/Set.php then you could do something like: ?php require_once('ADT/Queue.php'); $sounds = new Queue; $sounds-push(Bing); $sounds-push(Bamm); $sounds-push(Booom); while ($sounds-count() 0) { echo $sounds-shift(); } ? Which I think works quite nicely :) PEAR's naming conventions applies to classes written in C too. :-) The way you have your files organized above, the classes should be named ADT_Queue and so on. - Stig -- Stig Sæther Bakken [EMAIL PROTECTED] Fast Search Transfer ASA, Trondheim, Norway -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
On Sun, Aug 26, 2001 at 07:29:59PM -0400, Sterling Hughes wrote : Currently working on the Binary Tree implementations for the ADT extension and was wondering what people thought as more intuitive, something like: $tree = tree_new(AVL_TREE); tree_insert($tree, $element, compare_func); // ... Or: $tree = avl_tree_new(); avl_tree_insert($tree, $element, compare_func); Basically the difference between a generalized tree api, where you pass a constant to the constructor (if you allow me to use that term :), or where every form of the tree has a different set of functions (currently planned are Red-black tree's, AVL tree's, Simple Binary Search Tree's and Btree's). Thoughts? I'm currently leaning towards the first one... +1 -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
On Sun, Aug 26, 2001 at 07:29:59PM -0400, Sterling Hughes wrote: Hey, extension and was wondering what people thought as more intuitive, something like: $tree = tree_new(AVL_TREE); tree_insert($tree, $element, compare_func); // ... I prefer this notation. There's more room for future expansion without encroaching on namespace. I think it would be neat to be able to do this, though: $tree = new Tree(AVL_TREE); $tree-insert($element, 'compare_func'); But such a wrapper shouldn't be too difficult to write. -- Jon Parise ([EMAIL PROTECTED]) . Rochester Inst. of Technology http://www.csh.rit.edu/~jon/ : Computer Science House Member -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
On Sun, 26 Aug 2001, Jon Parise wrote: On Sun, Aug 26, 2001 at 07:29:59PM -0400, Sterling Hughes wrote: Hey, extension and was wondering what people thought as more intuitive, something like: $tree = tree_new(AVL_TREE); tree_insert($tree, $element, compare_func); // ... I prefer this notation. There's more room for future expansion without encroaching on namespace. I think it would be neat to be able to do this, though: $tree = new Tree(AVL_TREE); $tree-insert($element, 'compare_func'); But such a wrapper shouldn't be too difficult to write. Jep -- I'm writing PEAR OO wrappers for every ADT that I implement in a functional manner. I'm think for the OO wrappers, seperate class names wouldn't be horrible, something like: $tree = new AVLTree; -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
At 07:29 PM 8/26/01 -0400, Sterling Hughes wrote: Hey, Currently working on the Binary Tree implementations for the ADT extension and was wondering what people thought as more intuitive, something like: $tree = tree_new(AVL_TREE); tree_insert($tree, $element, compare_func); // ... I like this better, but please prefix constants with ADT. -Andrei -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
Quoting Sterling Hughes [EMAIL PROTECTED]: Jep -- I'm writing PEAR OO wrappers for every ADT that I implement in a functional manner. I'm think for the OO wrappers, seperate class names wouldn't be horrible, something like: $tree = new AVLTree; Please stick to the naming conventions, which would make this: $tree = new ADT_Tree_AVL(); ... or something similar. Also, you could easily have a factory method: $tree = ADT::factory('tree_avl'); or: $tree = ADT_Tree::factory('avl'); -chuck -- Charles Hagenbuch, [EMAIL PROTECTED] Some fallen angels have their good reasons. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] API Thoughts?
On Sun, 26 Aug 2001, Chuck Hagenbuch wrote: Quoting Sterling Hughes [EMAIL PROTECTED]: Jep -- I'm writing PEAR OO wrappers for every ADT that I implement in a functional manner. I'm think for the OO wrappers, seperate class names wouldn't be horrible, something like: $tree = new AVLTree; Please stick to the naming conventions, which would make this: $tree = new ADT_Tree_AVL(); ... or something similar. Also, you could easily have a factory method: $tree = ADT::factory('tree_avl'); or: $tree = ADT_Tree::factory('avl'); The above are imho pretty ugly, and this is meant as more of a language level feature, I'm thinking of using PEAR as more of a method of distribution than a mindset. I'd prefer to code the OO wrapper in PHP -- it stops me from having to be aware of changes to the Zend OO model and writing code that works with both the functional interface and the OO interface (some form of automatic handling of this would be a very cool/useful feature for Zend, imho). The current way I have it organized is as follows: php4/pear/ADT.php php4/pear/ADT/LList.php php4/pear/ADT/Stack.php php4/pear/ADT/Queue.php php4/pear/ADT/AVLtree.php php4/pear/ADT/BTree.php php4/pear/ADT/RBTree.php php4/pear/ADT/Heap.php php4/pear/ADT/Set.php then you could do something like: ?php require_once('ADT/Queue.php'); $sounds = new Queue; $sounds-push(Bing); $sounds-push(Bamm); $sounds-push(Booom); while ($sounds-count() 0) { echo $sounds-shift(); } ? Which I think works quite nicely :) -Sterling -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]