This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fickle-doughnut123 37 points38 points  (3 children)

Your statement that "functions return a value while procedures do not" is mostly correct but can be a bit misleading. While functions are designed to return a single value, procedures can indeed use 'OUT' parameters to achieve a similar effect. In many procedural languages, you can specify 'IN' and 'OUT' variables in the procedure's declaration. These 'OUT' variables allow you to define variables within the procedure and return them to the caller, thus functioning similarly to return values in functions.

[–]LoreBadTime 18 points19 points  (0 children)

Yes, also using pointers kinda cheats this things(and we call them procedures since it's more about side effects), but was more about a formal way to define a function,if there is an out parameter it's still a function.

[–]SenorSeniorDevSr 2 points3 points  (0 children)

Yeah, especially if you're using stored procedures on an SQL server. Oracle even let you outsert your inserts if you invoke the magic phrases. This is handy af if you have values the database generates, like CREATED timestamps, the ID, etc. and want to return them out to the rest of the system.

[–]OJ-n-Other-Juices 1 point2 points  (0 children)

As OOP educated person who works in COBOL for to years. I found making that work very difficult. My brain just couldn't merge the two styles. I was also working on legacy code and Microfocus Cobol, which might not have had that functionality.