in reply to Re^2: On Wormholes, Time-Travel and Closures
in thread On Wormholes, Time-Travel and Closures

qbxk,
No offense, but this likely has to do with your lack of exposure to pure functional languages. In some languages, variables can't change value so it is moot. It does kind of make you wonder why they still call them variables. In other languages, you need to desginate this behavior (default being eager) which is a visual indicator like tie.

We are of course talking about Perl, not other languages, so your point is well taken. Re: Evaluating variables when called is an example of such a desire. I am kind of interested in where Perl 6 will go with this.

Cheers - L~R

  • Comment on Re^3: On Wormholes, Time-Travel and Closures

Replies are listed 'Best First'.
Re^4: On Wormholes, Time-Travel and Closures
by Jenda (Abbot) on Dec 11, 2006 at 22:47 UTC

    Well, if you say, in math, that function f() is defined by equation f(x) = 2*x + 1 + sin(x) what would you call the "x"? A variable. And does it change within evaluation of the 2*x + 1 + sin(x)? The sentence that variables can't change value is not really correct actually. Next time you evaluate a function the x defined as its parameter or as an internal variable may have a totally different value. It's just that instead of "hey, I want to have a blackboard on which I'll write numbers and I'll call it X. Write 5 there now! OK and now clean it and write 10 there!" you just say "the value of something I wish to call X depends on the parameters of the function like this". And it's just the habits from imperative language that force you to look for ways to overwrite the X later instead of using a different name for the result of a different computation.