Reputation
16,586
Top tag
Next privilege 20,000 Rep.
Access 'trusted user' tools
Badges
1 42 66
Newest
 Good Answer
Impact
~234k people reached

Aug
26
comment Why do arrays in .Net have Length but other collection types have Count?
A T[] with a length of N always stores exactly N values of type T. Semantically, not all of those values may be meaningful (they might be null for example), but they exist. This is different from the usual meaning of capacity (as used by List<T> for example). You're right that Count can change while Length can't. Then again, nothing mandates that Count will, in fact, change. It is also used for immutable collections.
Aug
20
comment Why does Python's math.ceil return a float?
Actually in Python 3 it does return an integer.
Aug
19
comment Checking array size in C/C++ to avoid segmentation faults
The word statically is key: The reduction to the halting problem only works if we want to rule out all programs that go out of bounds, but no more, and without running the program. If run-time checks are permitted, the problem is almost trivial, it just has runtime overhead (and a quite large one, for a naive solution). Likewise, it is easy to reject all programs that go out of bounds as well as some that don't (the hard part is not rejecting practically useful ones).
Aug
18
comment Mutable AST vs. different immutable ASTs
@DeadMG The easiest example to defend would be if the semantic analysis is split in multiple passes (e.g., name resolution, then type inference). And it's pointless to argue whether this is a "semantic tree" or a "syntax tree". It contains all the original structure and nodes of the AST, though augmented with additional data, that's good enough for me.
Aug
18
comment Mutable AST vs. different immutable ASTs
@DeadMG Because some semantic analyses need to annotate basically every part of the program (with a type, for example) and preserve the syntactic structure for later passes? This is standard practice in compiler construction as far as I know.
Aug
16
comment Open Source License that prohibits verbatim resale?
If the trademark is something visible like the user name or the logo, then I don't think it will help with your intent. Yes, now these people need to change the name/logo/etc., but that is hardly any better than re-selling verbatim. So if they do that and release the result without any further changes, the situation is worse, because it's not obvious any more (to the casual observer) that this is exactly the same app.
Aug
16
awarded  Good Answer
Aug
14
comment Can higher order functions ever be pure?
@Giorgio I know all that. It's a cool idea that makes Haskell arguable the world's finest imperative programming language. It just doesn't matter here: We're talking about distinguishing pure computation from impure actions, and the IO monad does exactly that.
Aug
14
comment Can higher order functions ever be pure?
@Giorgio You could say that, but functions of type a -> IO b are the moral equivalent of impure functions, so in the context of this question I don't feel that is a useful position.
Aug
14
answered Can higher order functions ever be pure?
Aug
14
comment Why don't “multi-infinite” list comprehensions work with lazy evaluation?
For example, with most bijections the code in your questions would not find the first N Pythagorean triples, just some triples in an order that is meaningless unless you keep the exact bijection in mind. And none of this even begins to address the question of how you would decide when to apply this tranformation.
Aug
14
comment Why don't “multi-infinite” list comprehensions work with lazy evaluation?
All countable types can be represented by (non-negative) integers in some way. That is what it means to be countable. And all types expressible in Haskell (and indeed the set of all possible values in any computational process) are countable. The question is whether the compiler can infer an appropriate bijection, respecting the numerous invariants that most types have (e.g. rationals usually want to be irreducible, floating point-esque numbers want to be normalized, etc.) and whether the order is both (1) understandable and (2) the order the programmer wants.
Aug
14
comment Why don't “multi-infinite” list comprehensions work with lazy evaluation?
@TheEnvironmentalist There's more to infinite lists than infinite lists of integers, though. Why are those special? (Hint: They aren't.)
Aug
13
comment Can all code be represented as a series of Map / Filter / Reduce operations?
Idle thought: Even if we allow nonsense like my_list.map(_ignored => a copy of my_list), it seems like the space use of such a program is bounded by some polynomial (depending on the program length). Then such a language certainly couldn't compute problems that are not in PSPACE. However, as many problems in PSPACE are considered intractible, to say nothing of larger classes, this may not be a very serious restriction.
Aug
13
revised Why don't “multi-infinite” list comprehensions work with lazy evaluation?
added 418 characters in body
Aug
13
awarded  Nice Answer
Aug
13
answered Why don't “multi-infinite” list comprehensions work with lazy evaluation?
Aug
13
comment What prevents others from commerciallly redistributing open source software as-is?
There's a conflict between "allow commercial use" and "don't sell as-is". It is hard to define "as-is" in a satisfactory way: It can't simply mean bit-identical because it is easy to change some really minor aspect without meeting your intent, but to define "sufficently substantial" changes in a way that will hold up in court will at least require consultation with a lawyer, if possible at all.
Aug
13
awarded  Nice Answer
Aug
12
revised Is there any practical way for a linked node structure to be immutable?
added 83 characters in body