I learned to program using Turbo Pascal, a language which preserved the distinction, and it wasn’t as nice as you might think.
A function was just a procedure which returns a value. You could pass by pointer and mutate stuff in a function just as easily as a proc, the difference was quite minor and I think we’re better off just having a void
type rather than two names for essentially the same thing.
Whether that name is function
or procedure
is just stylistic: Odin abbreviates proc
and Zig abbreviates fn
but they end up being the same thing.
You could get a “real” function by declaring all parameters Const
, but of course this is possible in Zig also.
Then you have languages in the ML family which have actual functions in the mathematical sense. But those don’t have procedures.
If there was a language which had procedures which can mutate state and functions which can’t, I never saw it. Could be pretty nice! But that would be a new thing.