What is the difference between a class and a type in Scala (and Java)?

When you say “type” I’m going to assume you mean static type mostly. But I’ll talk about dynamic types shortly. A static type is a property of a portion of a program that can be statically proven (static means “without running it”). In a statically typed language, every expression has a type whether you write … Read more

Could a final variable be reassigned in catch, even if assignment is last operation in try?

JLS hunting: It is a compile-time error if a final variable is assigned to unless it is definitely unassigned (§16) immediately prior to the assignment. Quoth chapter 16: V is definitely unassigned before a catch block iff all of the following conditions hold: V is definitely unassigned after the try block. V is definitely unassigned … Read more

Why aren’t C# static class extension methods supported?

the C# team could have implemented this kind of functionality. Is there some philosophical reason why it isn’t supported? There’s no technical reason, and no philosophical reason. However, as I often point out, I don’t have to provide a justification for not doing a feature. Features aren’t cheap; they are extremely expensive and they must … Read more

Why can’t C# member names be the same as the enclosing type name?

Strictly speaking, this is a limitation imposed by C#, most likely for convenience of syntax. A constructor has a method body, but its member entry in IL is denoted as “.ctor” and it has slightly different metadata than a normal method (In the Reflection classes, ConstructorInfo derives from MethodBase, not MethodInfo.) I don’t believe there’s … Read more

Why is Clojure dynamically typed?

If a program is compiled you can’t change it anymore. This is wrong. In image-based systems, like Lisp (Clojure can be seen as a Lisp dialect) and Smalltalk, you can change the compiled environment. Development in such a language typically means working on a running system, adding and changing function definitions, macro definitions, parameters etc. … Read more

Why does the TypeScript compiler compile its optional chaining and null-coalescing operators with two checks?

You can find an authoritative answer in microsoft/TypeScript#16 (wow, an old one); it is specifically explained in this comment: That’s because of document.all […], a quirk that gets special treatment in the language for backwards compatibility. document.all == null // true document.all === null || document.all === undefined // false In the optional chaining proposal … Read more

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