return is an array access operator, so we can use it to pass anything from a function to an array as an argument.
This is a simple example of why returning an array from a function is not a good thing. This method doesn’t return an array, but rather a pointer to the array. So it wouldn’t be so bad if it were possible to return an array from the function, but it’s not possible. The reason for this is because the compiler doesn’t know what type the function parameters are. It assumes that the function was called with a function parameter of type void.
I believe this behavior is a part of the new rules. Back in C, if you want to pass anything from a function to an array as an argument, you would instead do so as a pointer.
The compiler supports it by default, but this is a little confusing since it’s probably not a good idea to do this.
Why would you pass a value to a function that you dont know what is its type/function parameters and just pass the void? It would be much better to return an array.
But if you want to pass an array of values to a function that you do know what is its type, which is a better practice, return it. Of course, this would return a pointer, so you would have to cast it back to a function pointer to return a value. But if you do not want a pointer, return an array.
I’m sure there are a million reasons why this is a bad idea. The main reason is that such a cast (if you can call it that) is undefined behavior, which is something we should always avoid, because it can lead to crashes, hangs, and runtime errors. The reason you can’t pass a value directly to a function is because the function expects a pointer to a given object. This is why you would normally not pass a value directly to a function.
You would usually expect a function to return a pointer to a function. Im not talking about performance, I’m talking about the fact that you don’t always get all the time you need to do your work. The reason you can get to a function by calling it, in part, is because you are passing a pointer. Sometimes you can get to a function by calling it, but sometimes you can not get to a function at all.
This is why you do not pass a pointer directly to a function. This is why you can pass a pointer to a function, as long as what you pass is not something that will change the function’s return type or how it returns a value.