Reputation
12,405
Top tag
Next privilege 15,000 Rep.
Protect questions
Badges
2 37 80
Newest
 Disciplined
Impact
~260k people reached

May
11
comment Structuring Procedural vs OO code
OP asked about using C++ to write procedural code. I’ve removed the example because it has been misunderstood too much.
May
11
revised Structuring Procedural vs OO code
Removed example.
Apr
29
comment Structuring Procedural vs OO code
@Dunk: Datatypes with member functions are dual to functions with closures. You interpret “pass this function and this value” as “pass this object”. You could also interpret it as “pass this activation”. They’re identical in this case, with only 1 function in the vtable or 1 value in the closure. In OOP you can’t change the vtable because the object decides its own behaviour, while in FP you can’t change the closure because the function is a black box. But in procedural programming, data and behaviours are not generally coupled at all, which I was trying to illustrate.
Apr
29
comment Structuring Procedural vs OO code
@Dunk: I did exactly the opposite, per the original question. If you think that avoiding objects, member functions, and virtual dispatch still constitutes using a language in an OO way, then I cannot hope to convince you of anything.
Apr
29
answered Structuring Procedural vs OO code
Mar
23
comment Is higher-rank parametric polymorphism useful?
@GregRos: It’s also handy with existentials. In Haxl, we had an existential like data Fetch d = forall a. Fetch (d a) (MVar a), which is a pair of a request to a data source d and a slot in which to store the result. The result and slot must have matching types, but that type is hidden, so you can have a heterogeneous list of requests to the same data source. Now you can use higher-rank polymorphism to write a function that fetches all requests, given a function that fetches one: fetch :: (forall a. d a -> IO a) -> [Fetch d] -> IO ().
Mar
23
answered Is higher-rank parametric polymorphism useful?
Mar
7
answered Confusion regarding def function within Python
Feb
27
awarded  Disciplined
Feb
12
comment When would dynamic scoping be useful?
@JerryCoffin: Notable exceptions include Perl and Emacs Lisp—both used dynamic scoping originally, and now (Perl 5, Emacs 24) have support for both dynamic and lexical scoping. It’s nice to be able to choose.
Feb
5
comment What's the tradeoff for type inference?
It’s worthwhile to draw a distinction between type deduction (monodirectional, like C# var and C++ auto) and type inference (bidirectional, like Haskell let). In the former case, the type of a name may be inferred from its initialiser only—its uses must follow the type of the name. In the latter case, the type of a name may be inferred from its uses also—which is useful in that you can write simply [] for an empty sequence, regardless of the element type, or newEmptyMVar for a new null mutable reference, regardless of the referent type.
Feb
2
awarded  Popular Question
Jan
4
awarded  Guru
Jan
4
awarded  Enlightened
Jan
3
awarded  Good Answer
Jan
3
awarded  Nice Answer
Jan
3
answered Why might it be difficult to make a 64 bit version of a program?
Dec
24
awarded  Nice Answer
Dec
11
answered Why do objects created with no assignment not generate a syntax error in Python?
Nov
22
comment Why squash git commits for pull requests?
Strictly speaking, Git doesn’t allow you to change history. Commit objects are immutable. It’s only branch pointers that are mutable, and only then with a “forced update”, which is generally considered something you only do for development purposes, not on the master branch. You can always get back to a previous state using the reflog, unless git gc has been run to discard unreferenced objects.