![]() That's good because it can save us a lot of typing and, more importantly, makes our programs easier to understand because we can forget about some of the details after we create the function that hides them. So far we have seen how to create our own functions and call these from other parts of our program. We'll look at the object approach in the OOP topic a little later but for now let's see how we go about creating our own modules. ![]() ![]() One way to get round this limitation of not changing built in behaviour but still using a meaningful name for our functions is to put the functions inside either an object or a module which provides its own local context. Thus it is good practice not to change the basic behaviour of built in functions. By changing the behaviour of a standard language function your code can become very difficult for other people (or even you later on) to read, since they expect the function to do one thing but you have redefined it to do another. Functions are very powerful because they allow us to extend the language, they also give us the power to change the language buy defining a new meaning for an existing function (some languages don't allow you to do this), but this is usually a bad idea unless carefully controlled (we'll see a way to control it in a minute).
0 Comments
Leave a Reply. |