Questions tagged [function-declaration]

A function declaration is the process of describing only the return type, argument types, and name of a function. This is required in some programming languages to use functions that were defined at a later point in the code or in another file. Use this tag for questions that pertain to or problems caused by forward declaring functions in languages that support or require doing so.

549 questions
0
votes
1 answer

Default Parameters in Function Expressions

Default parameters in javscript function declerations can be achieved with a simple assignment as follows: function foo(arg1 = 'default1', arg2 = 'default2') { ... } But how can I have default parameters for function expressions, as the following…
Grateful
  • 9,685
  • 10
  • 45
  • 77
0
votes
2 answers

c++ program is working even without function declaration before using the function

I have just started learning c++ and i came across this concept of function declaration. It says "a function must be declared before use" but i have written a program where i have commented the function declaration and used the function. My program…
Asim
  • 413
  • 1
  • 4
  • 13
0
votes
1 answer

Use of function declaration in xQuery

I'm trying to pass to a function a list of element and from that element I want to extract only a part (depending on the number of calories). Here you can see my code: declare function local:calories($val as element(), $max as xs:integer) as…
Timmy
  • 693
  • 2
  • 8
  • 26
0
votes
1 answer

scala function declaration - Inferencer?

I am a scala noob, learning through functional programming in scala book. i was doing some exercises, and this thing really startled me: def plusone[Int](l: List[Int]): List[Int] = foldRight(l, Nil:List[Int])((x,xs)=>Cons(x+1,xs)) This is a…
ybyungjoon
  • 11
  • 3
0
votes
2 answers

JavaScript function declaration scope in my createMinHeightBST function

Running into some weird JavaScript issues regarding the scope of my function declaration. In my BST function I'm able to call the function node without issues. But in my createMinimalHeightBST function I get an error when I try to call the BST…
Daniel Kobe
  • 9,376
  • 15
  • 62
  • 109
0
votes
1 answer

Simple trick to turn function declaration into variable definition

I know that the following statement is interpreted as a function declaration instead of a variable definition boost::system::system_error sys_err(boost::system::error_code()); Is there any simple trick to turn it into a one-liner variable…
Lingxi
  • 14,579
  • 2
  • 37
  • 93
0
votes
0 answers

Parameter in function declaration having 2D array

For functions: void fn1(int M[size][size],int n,int m){ ....... } OR void fn1(int M[][size],int n,int m){ ....... } is the declaration of function What should be the function declaration at the beginning? The declaration : void…
sb15
  • 313
  • 5
  • 18
0
votes
1 answer

JS Function declarations should not be placed in block

I have wrapped 95% of the 'parentCtrl' (Controller) within an 'IF' statement, this prevents any functions from triggering if the user isn't signed in and authorized. Since doing this I keep getting the following JSHint error! Error JSHint 104:5…
user4495161
0
votes
2 answers

Meteor JS global function

using Meteor.js I want to use a global function which contains other functions : BIG = function (){ this.init = function () { //do something } this.addSomething = function (param1, param2) { //do something…
0
votes
3 answers

How to reference not-yet-declared functions in a global variable in Python?

I need to have a global dict with string as keys and function references as values. I don't want to write something similar to a switch, because I need to be able to fetch the keys list from another script. I tried to write a script looking like…
0
votes
1 answer

Explicitly define the possibility of multiple unknown arguments in PHP

I want to create a function that may require multiple unknown arguments. I am currently not defining the argument list. The function definition looks like this public static function SafeJoin() and then I use $arguments_list = func_get_args();…
Gaurav Joseph
  • 927
  • 14
  • 25
0
votes
2 answers

Function returning a variable without declared it

I recently search in the code of the library of knockout to find how observables are able to create dependencies with computed functions when we call it. In the source code, I found the function linked to observables creation: ko.observable =…
Samuel
  • 12,073
  • 5
  • 49
  • 71
0
votes
4 answers

Function declaration vs function definition

If I have this prototype: int bar(int); for the compiler I'm declaring the identifier bar. If I have this definition: int bar(int a) {}; for the compiler I'm defining the identifier bar. Generally speaking a definition make a storage allocation…
xdevel2000
  • 20,780
  • 41
  • 129
  • 196
0
votes
1 answer

calling functions from a different c file

actually I was compiling with multiple files. Following are the files: file main.c --> #include void foo3(void) { printf("INSIDE foo3 function\n"); } int main() { foo1(); foo2(); foo3(); } file 1.c…
Akhil
  • 105
  • 1
  • 8
0
votes
3 answers

C++ - declaring a function 'static' versus the form 'const int function_name() const'

My eyes were recently opened to the uses of the static keyword in regards class 'helper functions'. It is my understanding now that you declare a member function static IF it does not interact with any data members but instead works only on the…
user3259248