M
M
Maxim Siomin2021-05-04 16:08:15
IT terminology
Maxim Siomin, 2021-05-04 16:08:15

Is the concept of "procedure" relevant in modern languages?

I'm sitting writing a program, there was a code like this:

def getInfo(num):
    #около 100 строк кода
    return result

The teacher comes up and asks: "Is getInfo a function or a procedure?" I did not really understand what he was talking about and said that this is a function. Googled at home that a procedure is a function that does not return a value. That is, in c++, the procedure looks like this
void smth() {

}

But python is a dynamically typed language. There cannot be procedures and functions. There might even be code like this:
def f(a):
    if a == 1: 
        return 0
    elif a == 2: 
        return True
     elif a == 3:
         return 'smth'
     elif a == 4:
         return 20.1
     else:
          return None

So here already in theory there can be no procedures. In Kotlin, a function is declared with the word fun(ction):
fun smth() {

}
So the procedure is declared with the word fun.
As a result: is it worth using the word "procedure" at all?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GavriKos, 2021-05-04
@MaxSiominDev

And what does dynamic typing have to do with whether a value is returned or not? The main thing is that it returns)
But the concept of "procedure" is already an anachronism. Right now it's more fashionable to divide into "methods" and "functions")))

A
Armenian Radio, 2021-05-04
@gbg

The legs of the question grow out of Pascal, which had two whole separate keywords - procedure and function . Actually, they are applicable mainly to Pascal, C, C ++ - languages ​​with strong typing.

V
Vasily Bannikov, 2021-05-04
@vabka

So the procedure is declared with the word fun.

No, it's also a function, because it actually returns Unit, which is a type with a single possible value, as opposed to void, which has no values.
As a result: is it worth using the word "procedure" at all?

IMHO - it's worth it, because it allows you to convey more meaning in one word.
Well, modern languages ​​\u200b\u200bare not limited to one python

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question