How data is shared by function in proceduce oriented program?
Answers
Answered by
1
You talk of functions in a procedure-oriented language, and then the question is: what do you mean? To me, a function in a procedural setting is a procedure that returns something. A procedure that is not a function is only called for its effect: it may write something to disc, or put something on the screen, or have a side-effect on a global variable. In certain languages, information can also be passed back in by-reference arguments. This brings us to the first way of sharing data between procedures/functions: argument passing. Some arguments are simply references to data, so you can in fact “pass in” a lot of data in this way.
Another way of sharing data is by means of global variables that most procedural languages support (global variables are tricky, in some functional languages like Haskell, but easy enough in functional languages that support assignments).
If you have a whole lot of data to share, you can always write things to disc and read them in somewhere else, but this is clumsy and plenty of room for error and mishap. In that setting it is also possible to communicate via sockets, for example. Typically you do these things between different applications.
Another way of sharing data is by means of global variables that most procedural languages support (global variables are tricky, in some functional languages like Haskell, but easy enough in functional languages that support assignments).
If you have a whole lot of data to share, you can always write things to disc and read them in somewhere else, but this is clumsy and plenty of room for error and mishap. In that setting it is also possible to communicate via sockets, for example. Typically you do these things between different applications.
Similar questions