Task

Demonstrate the different syntax and semantics provided for calling a function.



This may include:

   Calling a function that requires no arguments
   Calling a function with a fixed number of arguments
   Calling a function with optional arguments
   Calling a function with a variable number of arguments
   Calling a function with named arguments
   Using a function in statement context
   Using a function in first-class context within an expression
   Obtaining the return value of a function
   Distinguishing built-in functions and user-defined functions
   Distinguishing subroutines and functions
   Stating whether arguments are passed by value or by reference
   Is partial application possible and how


This task is not about defining functions.




//The type of the function argument determines whether or not the value is passed by reference or not.
//Eg. numbers are passed by value and lists/arrays are passed by reference.
 
software {
	print() 					//Calling a function with no arguments.
	print("Input a number!")	//Calling a function with fixed arguments.
	print(1,2,3,4,5,6,7,8,9,0) 	//Calling a function with variable arguments.
	input = read() 				//Obtaining the return value of a function.
	myprint = print
	myprint("It was: ", input)	//Calling first class functions, the same as calling ordinary functions.
 
	//The only distinction that can be made between two functions is if they are 'real' or not.
	if type(myprint) = concept
		print("myprint is a not a real function")
	else if type(myprint) = function
		print("myprint is a real function")
	end
 
	//Partial functions can be created with static parts.
	DebugPrint = print["[DEBUG] ", text]
	DebugPrint("partial function!")		//This would output '[DEBUG] partial function!'
 
	if type(DebugPrint) = concept
		print("DebugPrint is a not a real function")
	else if type(DebugPrint) = function
		print("DebugPrint is a real function")
	end
} 
 