What are “sums-and-products” data structures?

What are the traditional sums-and-products data structures he is referring to? In type theory, regular data structures can be described in terms of sums, products and recursive types. This leads to an algebra for describing data structures (and so-called algebraic data types). Such data types are common in statically typed functional languages, such as ML … Read more

New language on top of PHP?

The idea is definitely not stupid, especially if executed well. I like coffeescript a lot, but it has it’s approach has downsides as well. Debugging a coffeescript script still requires you read the generated Javascript code, which can be tedious, since you haven’t written it actually yourself. I’ve understood that Jeremy Ashkenas, the creator of … Read more

What is the difference between def foo = {} and def foo() = {} in Scala?

If you include the parentheses in the definition you can optionally omit them when you call the method. If you omit them in the definition you can’t use them when you call the method. scala> def foo() {} foo: ()Unit scala> def bar {} bar: Unit scala> foo scala> bar() <console>:12: error: Unit does not … Read more

What is the difference between “keyword” and “reserved word”?

Keywords have a special meaning in a language, and are part of the syntax. Reserved words are words that cannot be used as identifiers (variables, functions, etc.), because they are reserved by the language. In practice most keywords are reserved words and vice versa. But because they’re two different things it may happen that a … Read more

Can you monkey patch methods on core types in Python?

No, you cannot. In Python, all data (classes, methods, functions, etc) defined in C extension modules (including builtins) are immutable. This is because C modules are shared between multiple interpreters in the same process, so monkeypatching them would also affect unrelated interpreters in the same process. (Multiple interpreters in the same process are possible through … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)