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

Ah, Pascal differentiates between procedures and functions, but not in the procedural vs functional way. Pascal functions may have side effects, there is nothing in the language forbidding that.

Regarding the SQL extensions, well, the distinction between functions and procedures is not so clear. The main difference seems to be as in the Pascal case: if there is a return value or not. But then, function calls are allowed embedded inside SQL statements and that opens the door to lots of other considerations, more related to database implementation and internal matters than to anything else.

I think it's actually a little unlucky that C books speak about "void functions" rather than "procedures".

Just returning a value doesn't make a function a function in the functional programming sense (deterministic, no side effects). In C (at least) that is exacerbated by the fact that return values are commonly used to report errors.

So, it's true that C functions returning void are procedures, but then, most C functions returning values are also procedures. The distinction doesn't lie there.

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

Replies are listed 'Best First'.
Re^6: How do I go from procedural to object oriented programming?
by Jenda (Abbot) on Apr 21, 2015 at 13:25 UTC

    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.

      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.