I need the most basic, "for dummies" explanation of what a wrapper is. I posted this in "For Beginners" because I am sure someone will just starting out will have the same question.
So far my definition is:
A function that calls or returns another function
Wikipedia makes this so difficult and annoying to comprehend:
A wrapper function is a subroutine in a software library or a computer program whose main purpose is to call a second subroutine[1] or a system call with little or no additional computation.
Isn't a subroutine a function?
Wikipedia says:
In computer programming, a subroutine is a sequence of program instructions that perform a specific task, packaged as a unit.
Do I have this idea right:
Sometimes I don't like the name of a function included in a library, so I put that function in a function of my own, and pass stuff into it, or return stuff from it.
But then, what is a decorator?
I am using Python, but this paradigm shows up in several languages.
Edit:
Found another quote from (http://www.programiz.com/python-programming/decorator):
Basically, a decorator takes in a function, adds some functionality and returns it.
Edit: Found another explanation (http://thecodeship.com/patterns/guide-to-python-function-decorators/)
In other words, functions generating other functions
There is a neat shortcut for that, which is to mention the name of the decorating function before the function to be decorated. The name of the decorator should be perpended with an @ symbol.
The examples in this post are pretty simple relative to how much you can do with decorators. They can give so much power and elegance to your program. In general, decorators are ideal for extending the behavior of functions that we don't want to modify.