4 ms·
> - useless dinsctintion between procedures and functions? Uh? care to elaborate?
by flykespice 4y ago
> - useless dinsctintion between procedures and functions?
Uh? care to elaborate?
- illiarian 4y agoA proc is a function with no return. A function is a function that returns something. Oberon+ keeps it's predecessors' idiotic distinction, but takes it one step further: both functions and procedures are decalred with `proc` or `procedure`, functions are `proc`s that have a return type. And yet: - procedure calls don't have to specify parameters apparently, but function calls must specify all parameters - functions cannot be used in Oberon+'s weird exception handling. [1] You do a call with `PCALL(res, P, args)` where res is a variable that will hold the result of the exception if it happened, and P is the procedure. You cannot pass functions (aka procedures which have a return type) As the spec so wonderfully says [2], --- start quote --- There are two kinds of procedures: proper procedures and function procedures. The latter are activated by a function designator as a constituent of an expression and yield a result that is an operand of the expression. Proper procedures are activated by a procedure call. A procedure is a function procedure if its formal parameters specify a result type. Each control path of a function procedure must return a value. --- end quote --- [1] https://github.com/oberon-lang/specification/blob/master/The_Programming_Language_Oberon%2B.adoc#exception-handling https://github.com/oberon-lang/specification/blob/master/The... [2] https://github.com/oberon-lang/specification/blob/master/The_Programming_Language_Oberon%2B.adoc#exception-handling https://github.com/oberon-lang/specification/blob/master/The...