Why can’t I use a Javascript function before its definition inside a try block?

Firefox interprets function statements differently and apparently they broke declaration hoisting for the function declaration. ( A good read about named functions / declaration vs expression ) Why does Firefox interpret statements differently is because of the following code: if ( true ) { function test(){alert(“YAY”);} } else { function test(){alert(“FAIL”);} } test(); // should … Read more

Pointer to array of unspecified size “(*p)[]” illegal in C++ but legal in C

Dan Saks wrote about this in 1995, during the lead up to C++ standardisation: The committees decided that functions such as this, that accept a pointer or reference to an array with unknown bound, complicate declaration matching and overload resolution rules in C++. The committees agreed that, since such functions have little utility and are … Read more

Why is Function[-A1,…,+B] not about allowing any supertypes as parameters?

Covariance and contravariance are qualities of the class not qualities of the parameters. (They are qualities that depend on the parameters, but they make statements about the class.) So, Function1[-A,+B] means that a function that takes superclasses of A can be viewed as a subclass of the original function. Let’s see this in practice: class … Read more

Use php namespace inside function

From Scoping rules for importing The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations. This is because the importing is done at compile time and not runtime, so it cannot be block scoped So you should put like this, use should specified at the … Read more

Differences of using “const cv::Mat &”, “cv::Mat &”, “cv::Mat” or “const cv::Mat” as function parameters?

It’s all because OpenCV uses Automatic Memory Management. OpenCV handles all the memory automatically. First of all, std::vector, Mat, and other data structures used by the functions and methods have destructors that deallocate the underlying memory buffers when needed. This means that the destructors do not always deallocate the buffers as in case of Mat. … Read more