Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
39
Task/Function-prototype/COBOL/function-prototype.cobol
Normal file
39
Task/Function-prototype/COBOL/function-prototype.cobol
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
*> A subprogram taking no arguments and returning nothing.
|
||||
PROGRAM-ID. no-args PROTOTYPE.
|
||||
END PROGRAM no-args.
|
||||
|
||||
*> A subprogram taking two 8-digit numbers as arguments (passed by
|
||||
*> value), and returning an 8-digit number.
|
||||
PROGRAM-ID. two-args PROTOTYPE.
|
||||
DATA DIVISION.
|
||||
LINKAGE SECTION.
|
||||
01 arg-1 PIC 9(8).
|
||||
01 arg-2 PIC 9(8).
|
||||
01 ret PIC 9(8).
|
||||
PROCEDURE DIVISION USING BY VALUE arg-1, arg-2 RETURNING ret.
|
||||
END PROGRAM two-args.
|
||||
|
||||
*> A subprogram taking two optional arguments which are 8-digit
|
||||
*> numbers (passed by reference (the default and compulsory for
|
||||
*> optional arguments)).
|
||||
PROGRAM-ID. optional-args PROTOTYPE.
|
||||
DATA DIVISION.
|
||||
LINKAGE SECTION.
|
||||
01 arg-1 PIC 9(8).
|
||||
01 arg-2 PIC 9(8).
|
||||
PROCEDURE DIVISION USING OPTIONAL arg-1, OPTIONAL arg-2.
|
||||
END PROGRAM optional-args.
|
||||
|
||||
*> Standard COBOL does not support varargs or named parameters.
|
||||
|
||||
*> A function from another language, taking a 32-bit integer by
|
||||
*> value and returning a 32-bit integer (in Visual COBOL).
|
||||
PROGRAM-ID. foreign-func PROTOTYPE.
|
||||
OPTIONS.
|
||||
ENTRY-CONVENTION some-langauge.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 arg PIC S9(9) USAGE COMP-5.
|
||||
01 ret PIC S9(9) USAGE COMP-5.
|
||||
PROCEDURE DIVISION USING arg RETURNING ret.
|
||||
END PROGRAM foreign-func.
|
||||
3
Task/Function-prototype/Go/function-prototype.go
Normal file
3
Task/Function-prototype/Go/function-prototype.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
func a() // function with no arguments
|
||||
func b(x, y int) // function with two arguments
|
||||
func c(...int) // varargs are called "variadic parameters" in Go.
|
||||
4
Task/Function-prototype/JavaScript/function-prototype.js
Normal file
4
Task/Function-prototype/JavaScript/function-prototype.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var randomFunction=function(a){this.someNumber=a;}; //Doesn't matter when the function uses parameters, named arguments, no arguments, or if it doesn't return nothing at all.
|
||||
randomFunction.prototype.getSomeNumber=function(){return this.someNumber;}
|
||||
randomFunction.prototype.setSomeNumber=function(a){return this.someNumber=a;}//editing prototype explicitly
|
||||
(new randomFunction(7)).getSomeNumber();//7
|
||||
Loading…
Add table
Add a link
Reference in a new issue