in reply to How realistic is separation of computation from it's display?

Modularity usually does not cooperate very well with attempting to break encapsulation. That is usually a Good Thing. (And most of the time when people want to break encapsulation, that is a Bad Thing.)

For instance take your example above. You have a nicely encapsulated function to produce Fibonacci numbers. Perhaps it looks like this:

sub fib { my $n = shift; if ($n == 0 or $n == 1) { return 1; } else { return fib($n-1) + fib($n-2); } }
So you want to break the encapsulation to show how the computation works. Well what happens if someone wants to later on Memoize the function so that it will calculate answers at a reasonable rate? There is no good way to show the logic and also short-circuit uselessly repeated logic. So you are now stuck with an exponentially bad algorithm to calculate this function because someone might want to display it...

OK, this is a toy example, and with excess work you can work around it. But the principle still holds. When you break the encapsulation, you cause extra work and limit your ability to optimize under the hood. And this is a bad thing. By contrast if you separate display and implementation, then you don't needlessly complicate your life later. Sure it makes some things harder now, but if you can hold that line it will make a lot of them easier later.

  • Comment on Re (tilly) 1: How realistic is separation of computation from it's display?
  • Download Code