![]() |
Higher Order PHP: Map and Functional Extension Helper - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Higher Order PHP: Map and Functional Extension Helper (/showthread.php?tid=11461) Pages:
1
2
|
Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Jamongkad[/eluser] [quote author="Colin Williams" date="1221049209"]Think of it as a way to really, really screw with your coworkers and others maintaining your code ![]() Excuse me sir but are you implying by doing things in a functional programming style "screws" with people? Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]xwero[/eluser] I can understand you want to create an environment you are comfortable with but for most php developers it adds another layer of complexity. In the 7 to 100 example in python it starts from a number not from an array so maybe that is something you need to make possible? I see the example but i can't connect it to a real world use. Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Jamongkad[/eluser] Yes I agree with you, perhaps this library is too specialize for what it can do? I'll try to post more examples of it's use. Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Jamongkad[/eluser] I used an array because originally the library takes a list structure, I mean an array, and applies the functions to that list structure. Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Colin Williams[/eluser] Quote:...adds another layer of complexity Thus, potentially screwing other developers. And I'm not saying that because the concept is hard to perceive, but the implementation, the syntax, is weak. It's verbose. Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Mark van der Walle[/eluser] The library also blurs the line between controller and view, where the view is responsible for showing data and how something is showed and the controller which should gather and process data and pass them between different parts of the application. Also the example used a <br /> tag in the function (if im not mistaken). What if my output can change from html to xml, plain text or some other format. With "normal" Controller/View seperation my controller can just load a different view and presto! i have a different format. CodeIgniter allows the blur between seperate parts of the application. Hell I can even do: Code: class Example extends Controller The separation of the different parts allows for better isolation of problems, responsibilities, code reuse, adding extra features and much much more that does not currently come to mind. Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]xwero[/eluser] I think you are staring too much at the first example, we established it's a bad one. But if you look at the second one if you would do that in plain php if would be something like Code: $array = array(7); Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Jamongkad[/eluser] Thank you for the input! Colin, I'm the first to tell you that the library is still undergoing changes even as we speak. I know my first example is a bit premature, my inspiration for the library comes from this link Higher Order Javascript. Although I'm the first to admit my implementation is weak compared to the examples given. THe reason the syntax may look (weird|unintuitive) is because I'm experimenting with array_map as an alternative means of iteration as opposed to Foreach. I think I should have made my point a bit more clearer when I first posted this library. Truth be known I'm ready to release a new version of the library that concentrates on recursion in place of array_map. Xwero, yes it's more of an enchantment at this point. But please do take in mind how the library structures complexity for you. Code: $this->map->proc('function') <------the function you want to work on Let's not stop there...you can even apply functions as arguments to the target function you chose to work on. Anonymous functions at that! Code: $this->map->proc(lam('$x,$y,$z','$z($x(y)) * $z($x(y))') Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Jamongkad[/eluser] [quote author="Mark van der Walle" date="1221073187"] The separation of the different parts allows for better isolation of problems, responsibilities, code reuse, adding extra features and much much more that does not currently come to mind.[/quote] [/quote] Yes! we are in agreement and I'm all for the aforemention, thus creation of this library. It encourages one to think in using abstractions to better produce more structured programs. Granted it's implementation is premature but I believe it's a step in the right direction. PHP has been getting a lot of flack amongst my colleagues in the Scheme community(which by the way is a very fragmented community) if for anything else this library is a means to try to attempt to make PHP into something more than just a scripting language for simple tasks. Higher Order PHP: Map and Functional Extension Helper - El Forum - 09-10-2008 [eluser]Jamongkad[/eluser] [quote author="Colin Williams" date="1221058614"] Quote:...adds another layer of complexity Thus, potentially screwing other developers. And I'm not saying that because the concept is hard to perceive, but the implementation, the syntax, is weak. It's verbose.[/quote] It's a work in progress as with all things. But I wish there was a means in PHP to allow for prototypal inheritance much like in Javascript.One can simply extend the default array methods and create their own. But my question is if you think the syntax is weak and verbose what syntax would you accept as natural and intuitive? I want to make this library easy to use. So you input would be greatly appreciated. |