| bio | website | |
|---|---|---|
| location | ||
| age | 23 | |
| visits | member for | 2 years, 1 month |
| seen | 9 hours ago | |
| stats | profile views | 52 |
|
Jul 2 |
comment |
Is this a decent use-case for goto in C? This also works in Javascript. I guess there is one thing where it is similar to Java after all. |
|
Jun 23 |
comment |
Why are effect-less functions executed? @JonStrayer: OK, its my turn tu be pedantic now :) What about for(n=4; is_sum_of_two_primes(n); n+=2){} printf("the goldbach conjecture is false!");? The loop is fully effectless and side-effect free but you don't want to optimize it out and falsely break the news that you found a counterexample to a liong standing conjecture! And just in case you want to say that my point is moot because a sensible person would put the "n" in the printf then I'm not listening :P |
|
Jun 22 |
comment |
Why are effect-less functions executed? @NickC: The hard part is the "provably" bit. While some sorts of effectless while loops are straightfoward to optimize (and many compilers will do so), its easy to get in a slippery slope of properties that get harder and harder to prove and everyone gives up at some point. |
|
Jun 22 |
comment |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? @Paul: Handling state is a pure FP language is something completely orthogonal that people do all the time. The two main ways to deal with it would a) use datastructure sharing to still be able to use immutable state or b) Use magic monads and the like. The code using state is sequenced and checked by the compiler and under the hood things are just as efficient. |
|
Jun 21 |
comment |
Why are effect-less functions executed? @JonStrayer: You can't optimize away an infinite loop without changing the meaning of the program. What if I had a "fireTheMissiles()" call after the infinite loop? |
|
Jun 21 |
revised |
Why are effect-less functions executed? added 118 characters in body |
|
Jun 21 |
awarded | Nice Answer |
|
Jun 20 |
accepted | Is it OK to use dynamic typing to reduce the amount of variables in scope? |
|
Jun 20 |
comment |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? I think I was originally thinking of something simpler problem then the one you are worrying about. Say I give you a module with 10+ functions, how can you determine at a glance if those functions are only sub parts of a main function or if those functions actually implement a clever state machine with 10+ states? |
|
Jun 20 |
revised |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? added 769 characters in body |
|
Jun 20 |
comment |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? We all know that short composable functions are a good goal but we still need to be able to deal with what to do when we have a long list of business logic to follow or a complex algorithm to implement. |
|
Jun 20 |
comment |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? I don't think this is too different from the version using blocks to separate the subparts (as far as scoping is concerned at least). You gain the advantage I mentioned of passing arguments to the subparts and you avoid the rest of the code from seeing the subparts but there is still the complexity of the subparts being able to call each other that is not present in the undecomposed version. |
|
Jun 20 |
comment |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? Well, even though global state would make things more complicated this problem also applies to functional languages if you have to do a lot of stuff. I guess going with Haskell style "where" clauses is the way to go. |
|
Jun 20 |
comment |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? @Ken: Its not always possible to do that though - how do I decompose functions in the general case? |
|
Jun 20 |
comment |
When decomposing a large function, how can I avoid the complexity from the extra subfunctions? @gnat: I think I am dealing with a much more specific issue here though |
|
Jun 20 |
answered | Why are effect-less functions executed? |
|
Jun 20 |
asked | When decomposing a large function, how can I avoid the complexity from the extra subfunctions? |
|
Jun 19 |
comment |
Why are so many languages passed by value? It could be worse. Some old languages also allowed for call by name |
|
Jun 6 |
comment |
If immutable objects are good, why do people keep creating mutable objects? BTW - even if we ignore the whole mutability vs immutability issue, public getters and setters are a well known source of pain in OO design, since they tend to break encapsulation and invariants. |
|
May 22 |
comment |
The “blub paradox” and c++ A note on pattern matching: I wouldnt say its easier to write in general, but after you read a bit on the expression problem it becomes clear that things like if and switch statements, enums and the observer pattern are all inferior implementations of Algebraic Data Types + Pattern Matching. (And lets not even get started on how Maybe makes null pointer exceptions obsolete) |