Questions tagged [function-parameter]

The function parameters are the variable names, listed in the definition of the function.

In many programming languages, parameters are the essence of the functions. The function parameters define the variable names, listed in the definition of the function. They are often confused with (and referred to as) function arguments, which actually are the real values that are passed to and received by the function when it is being called.

314 questions
7
votes
2 answers

How to pass empty variables to a function in Lua

I've tried to pass empty values to a function but failed. Here is my setup; function gameBonus.new( x, y, kind, howFast ) -- constructor local newgameBonus = { x = x or 0, y = y or 0, kind = kind or "no kind", …
cbt
  • 1,271
  • 1
  • 11
  • 20
6
votes
2 answers

Which approach is better for supplying compile time constants to a function ? Function argument vs. Template parameter

I have logging function being called at several places throughout the code. To every log, I have to supply 2 compile time constants. There are 2 approaches to accomplish: (1) Function argument: template void log (const T &obj, const int…
iammilind
  • 68,093
  • 33
  • 169
  • 336
6
votes
2 answers

Contravariance on abstract classes

I would like to create a nice interface on C++ on which each implementation needs to have the addition defined, on itself. I would like to do something like this : class A{ ... virtual A& operator+(const A& other) =0; …
6
votes
1 answer

PostgreSQL function with duplicate parameters

I stumbled upon a curious function signature in pg_catalog.pg_stat_get_activity: CREATE OR REPLACE FUNCTION pg_stat_get_activity( IN pid integer, OUT datid oid, OUT pid integer, -- more parameters...) RETURNS SETOF record AS…
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
6
votes
3 answers

What's the meaning of the `...` parameter in a C function parameter list

Possible Duplicate: C/C++: Passing variable number of arguments around According to the function declaration manner return-type function-name(parameter-list, ...) {body ...} Is the following code a kind of overloading? (in A_FILE.h) typedef VOID…
Charles
  • 93
  • 11
6
votes
1 answer

MATLAB: Is there a method to better organize functions for experiments?

I will run a set of experiments. The main method evaluated has the following signature: [Model threshold] = detect(... TrainNeg, TrainPos, nf, nT, factors, ... removeEachStage, applyEstEachStage, removeFeatures); where removeEachStage,…
Yamaneko
  • 3,433
  • 2
  • 38
  • 57
5
votes
3 answers

How to pass a Composable to another Composable as its parameter and display/run it in Jetpack Compose

I have this drawer I learned to make on youtube https://www.youtube.com/watch?v=JLICaBEiJS0&list=PLQkwcJG4YTCSpJ2NLhDTHhi6XBNfk9WiC&index=31 Philipp Lackner I want to add the drawer to my app which has multiple screens and some of them don't need…
5
votes
2 answers

Working Around a Visual Studio Internal Compiler Error With Nested Templated Variables

I'm trying to write code that will let me index into the parameter types of a function: template R function_return(R(*)(ARGS...)); template std::tuple
5
votes
3 answers

Why can arrays be assigned directly?

Consider this code snippet: void foo(int a[], int b[]){ static_assert(sizeof(a) == sizeof(int*)); static_assert(sizeof(b) == sizeof(int*)); b = a; printf("%d", b[1]); assert(a == b); // This also works! } int a[3] = {[1] = 2},…
iBug
  • 35,554
  • 7
  • 89
  • 134
5
votes
1 answer

Swift function parameters

I've a singleton APIService like below import Foundation import Alamofire import SwiftyJSON typealias Success = JSON -> Void typealias Failure = NSError? -> Void class APIService { private let BaseURL =…
xmkevinchen
  • 1,506
  • 1
  • 14
  • 17
5
votes
3 answers

Where does "request" and "response" come from, and how could I have found out?

I've decided to learn node, an so I'm following, to begin with, The Node Beginner Book. As in I guess a lot of other resources, there is the "simple HTTP server", first step, something like: var http =…
ferhtgoldaraz
  • 1,693
  • 3
  • 15
  • 20
5
votes
2 answers

Scala - parameter of type T or => T

Is there any difference between the following def foo(s: String) = { ... } and def foo(s: => String) { ... } both these definitions accept "sss" as parameter.
Bober02
  • 15,034
  • 31
  • 92
  • 178
5
votes
2 answers

How to receive unnamed structures as function parameters in C?

Yesterday while going through this question, I found a curious case of passing and receiving unnamed structures as function parameters. For example, if I have a structure like this, int main () { struct { int a; } var; …
Pavan Manjunath
  • 27,404
  • 12
  • 99
  • 125
4
votes
4 answers

Declaring parameter of a function as final: why and when is it needed?

Going through a tutorial for android (related to multithreading, loopers and handlers), i came across this: public synchronized void enqueueDownload(final DownloadTask task) My questions are: When and why is it needed to declare a parameter of a…
SpeedBirdNine
  • 4,610
  • 11
  • 49
  • 67
4
votes
1 answer

PHP: Restrict class type in function parameter

I have inherited some code like this public static function instanciateRepository( $repositoryClass, ... ) { ... new $repositoryClass( ... ); } Where $repositoryClass is a class type that needs to be instanciated. I want to add a…
Anton Duzenko
  • 2,366
  • 1
  • 21
  • 26