Why doesn’t Java varargs support collections?

The reason is simple: a variable arity parameter is simply an old-school array paramater with some additional metadata that tells the compiler to provide some syntactic sugar (namely, it allows implicit array creation). So from the perspective of the JVM Object… is pretty much the same as Object[]. Allowing collections as well would require a … Read more

Equivalent of Class Loaders in .NET

The answer is yes, but the solution is a little tricky. The System.Reflection.Emit namespace defines types that allows assemblies to be generated dynamically. They also allow the generated assemblies to be defined incrementally. In other words it is possible to add types to the dynamic assembly, execute the generated code, and then latter add more … Read more

Why do enums have computed properties but not stored properties in Swift?

enums do have stored type properties – i.e., static properties. They don’t have stored instance properties. I don’t know if there is a technical reason why stored instance properties are not available for enums. You may have to ask your question on the dev forum if you want a technical answer for “why”. In your … Read more

What is a maximum number of arguments in a Python function?

In Python 3.7 and newer, there is no limit. This is the result of work done in issue #27213 and issue #12844; #27213 reworked the CALL_FUNCTION* family of opcodes for performance and simplicity (part of 3.6), freeing up the opcode argument to only encode a single argument count, and #12844 removed the compile-time check that … Read more

What is the purpose of long, double, byte, char in Java?

[*] With the possible exception of “short”, which arguably is a bit of a waste of space– sometimes literally, they’re all horses for courses: Use an int when you don’t need fractional numbers and you’ve no reason to use anything else; on most processors/OS configurations, this is the size of number that the machine can … Read more

Why isn’t there an endianness modifier in C++ like there is for signedness?

What the standard says [intro.abstract]/1: The semantic descriptions in this document define a parameterized nondeterministic abstract machine. This document places no requirement on the structure of conforming implementations. In particular, they need not copy or emulate the structure of the abstract machine. Rather, conforming implementations are required to emulate (only) the observable behavior of the … Read more

Problem understanding C# type inference as described in the language specification

UPDATE: My initial investigation on the bus this morning was incomplete and wrong. The text of the first phase specification is correct. The implementation is correct. The spec is wrong in that it gets the order of events wrong in the second phase. We should be specifying that we make output type inferences before we … Read more