New answers tagged

16

It's called "loop fusion". It's often more efficient, in the sense of doing more work per loop iteration and sometimes (as you say) other advantages. On the other hand, the fused loop in your example may also put more pressure on the CPU's cache prefetch system. So do test it before declaring it more efficient.


0

Sorry, in complete generality this is an undecidable problem. Pick your favorite undecidable problem $P$ and an instance $a$, and write e.g.: def value(a): if P(a): 1 else: "Hello, world!" print(41 + value(a)) Under the (conservative!) assumption that all execution paths are possible, you see that the above is badly ...


1

Terms such as "syntax", "semantics", and "pragmatics" were borrowed from linguistics. Linguists are trying to understand a natural phenomenon: human language. Theories about grammar and denotation are models of that natural phenomenon. Computer scientists are not so constrained, in that their job (in this context) is to define ...


2

If the language allows that the same variable x could have different types on different executions of a procedure, that doesn't mean the programmer actually wants to use this feature, or does use the feature. Typically you have three cases: 1. x has always the same type (but without proof). 2. x has the same type in 99.99% of all cases. 3. It happens quite ...


6

I think your friend somewhat presents a false dichotomy. I will just give one example: when it first came out, the Self VM was one of the fastest dynamic language implementations. In fact, the Smalltalk VM written in Self that shipped as part of the Self system was one of the fastest Smalltalk VMs of its time, despite being written in a dynamic language (...


0

The first assembly language compilers ("assemblers") were written in raw machine code. Once you got the program "breathing" enough to process statements, you could build a small piece of it using V1 of the assembler. Once the assembler accepted enough of the language to be useful, you used it to build V2 to add more features, and then V3, ...


Top 50 recent answers are included