in reply to Re^5: How do I go from procedural to object oriented programming?
in thread How do I go from procedural to object oriented programming?

Don't confuse "any function" with "referentially transparent function". A function in the mathematical sense is something a little different than a function in the programming sense.

Jenda
Enoch was right!
Enjoy the last years of Rome.

  • Comment on Re^6: How do I go from procedural to object oriented programming?

Replies are listed 'Best First'.
Re^7: How do I go from procedural to object oriented programming?
by salva (Canon) on Apr 21, 2015 at 14:19 UTC
    A function in the mathematical sense is something a little different than a function in the programming sense.

    No, it depends on the context:

    Under the imperative programming paradigm, "function" can refer to anything: subroutines with and without return values; deterministic and non-deterministic; and with and without side effects.

    Under the functional programming paradigm, "function" nowadays usually has the mathematical meaning... well, at least in hardcore functional-programming circles (i.e. between Haskell programmers).

    The differentiation between function and procedure a-la Pascal is, frankly, uninteresting and mostly useless.

      There is a lot of non-pure functional languages that NEED to be able to distinguish between referentially transparent functions and other functions and they are not going to refer to the later in the artist-formerly-known-as-prince way. Sure, there are languages in which all functions are referentially transparent, but that's a different thing. The pascal style distinction is common and well respected.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        I think the problem is that the mathematical definition of a function (for every x in a domain, there is exactly one value of f(x)) and the ordinary definition (the function of a lawn mower is that it cuts grass). But you are right that functional programming is limited to the former definition. That doesn't mean that function might have a different meaning in an imperative context.
        There is a lot of non-pure functional languages that NEED to be able to distinguish between referentially transparent functions and other functions and they are not going to refer to the later in the artist-formerly-known-as-prince way

        That makes sense.

        The pascal style distinction is common and well respected.

        Really? that's not my experience, but well, it may depend on where you move.