Are anonymous functions are OO?

Hello guys!

I actually don’t have any problems with PHP, however, I want to talk a little bit about procedural and OO concepts.

Is everyone know about Closure and anonymous functions in PHP5.3? Ok, so according to documentation anonymous function is represented by class Closure, so it’s mean that anonymous functions are OO. Or not, because they’re called functions?

Also, do you know any good procedural framework?

Thank you for attention.

Lambdas (anonymous functions) are used primarily in OO applications; but they are just functions – can be used procedurally as well (although I can’t imagine many cases where they would be needed in a procedural script).

What do you mean by “procedural framework”? If you mean a framework like CodeIgniter or Yii, then you likely won’t find any good frameworks that are created procedurally ( kind of an oxymoron )

Well, thanks for reply, arout77.

That’s explains why I can’t find in google any frameworks written in procedural style.
Just wondered.

I guess it’s a challenge to create my own :smiley:

Haha, well good luck with that!

Seriously though, a procedural framework…doesn’t seem like it would make a lot of sense. Sounds like it would be a pain in the butt to use (and maintain).
If you’re not familiar with OOP, I strongly recommend looking into it…the first few days, it may seem a bit pointless (“hey, I can do the exact same thing in procedural code too!”), but once you understand what’s really going on, you’ll see what all the fuss is about…it’s definitely one of those “milestones” in your programming career

I’m familiar with OOP style, all these namespaces, encapsulation, polymorphism, etc.
Just wanted to try something new to me. Therefore never seen good procedural code written in PHP. So it’s just my experiment.

P.S.: I already wrote procedural framework, but I want to get inspiration and see how things are actually implemented in the right way. To improve my framework.

I think that’s going to be the catch though; off-hand, I really can’t see how you’ll create a solid and reliable framework without going into OOP.

My first thought was putting all of your modules ( I assume you have a bunch of functions that do things like formatting, validation, etc ) into a directory, and then using namespaces & Composer to autoload everything. That way you avoid a ton of include_once calls as well as namespace collisions. Then you can just call your functions.

Other than that, maybe create a router if you are looking for SEO friendly URLs; you can use Composer to autoload that too.

But this is going to get REAL bad (a procedural framework) down the road and you want to add more complex things.

No way, it was pretty fun. However, I want to improve my framework and rewrite it from scratch. My blog is written on procedural framework, and yet is fast, faster than CI in 2-5 times. If you want to check it out (framework or blog), you can PM me, because this post is for discussion, not for promotion :slight_smile:

Could definitely provide better answers if I saw the framework and what you need it to do.

Out of curiosity, what is the motivation for emphasizing it to be procedural only?

Anonymous function?
If I’m not mistaken they borrowed it from JavaScript.

Anonymous functions are also called lambdas, and exist in different languages, such as Python, Lisp, etc.

So JavaScript and Python borrowed it from Lisp.

Anyway, in PHP anonymous functions represented by a class called Closure,
for more information visit

The answer is already above:

Framework is located on github, however if you’re not scared of Russian comments: