Questions tagged [function-call]

A function call is a line of code that executes a specific block of code defined as a function, that is, self-contained code that may optionally take arguments, defined for the purpose of code reuse.

A function call is a line of code that executes a specific block of code defined as a function, that is, self-contained code that may optionally take arguments, defined for the purpose of code reuse.

760 questions
33
votes
12 answers

How to do "call by reference" in Java?

How to do "call by reference" in Java? (Assume that we are using that term in the same way that it has been used in peer-reviewed CS literature since the 1960's; see this Wikipedia page for a simple explanation.) Since Java doesn't support…
Shashi Bhushan
  • 1,481
  • 3
  • 16
  • 20
30
votes
3 answers

Why is a function/method call in python expensive?

In this post, Guido van Rossum says that a function call may be expensive, but I do not understand why nor how much expensive can be. How much delay adds to your code a simple function call and why?
VGonPa
  • 443
  • 1
  • 7
  • 12
29
votes
1 answer

Why is 'X x; x();' allowed, when 'X' defines a conversion to function pointer, but not, when it defines a conversion to a functor?

void f(int){} typedef void (*f_ptr)(int); struct Functor{ void operator()(int){} }; struct X{ operator f_ptr(){ return f; } }; struct Y{ operator Functor(){ return Functor(); } }; int main(){ X x; Y y; x(5); // works ?! y(5); //…
Xeo
  • 129,499
  • 52
  • 291
  • 397
23
votes
3 answers

What do double parentheses mean in a function call? e.g. func(foo)(bar)

I use this idiom all the time to print a bunch of content to standard out in utf-8 in Python 2: sys.stdout = codecs.getwriter('utf-8')(sys.stdout) But to be honest, I have no idea what the (sys.stdout) is doing. It sort of reminds me of a…
user18015
19
votes
5 answers

Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node

When i load another groovy file in Jenkinsfile it show me following error. "Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node" I made a groovy file which contains…
manish soni
  • 515
  • 1
  • 7
  • 19
19
votes
2 answers

How do I call a method on my ServiceWorker from within my page?

I have a ServiceWorker registered on my page and want to pass some data to it so it can be stored in an IndexedDB and used later for network requests (it's an access token). Is the correct thing just to use network requests and catch them on the SW…
owencm
  • 8,384
  • 6
  • 38
  • 54
19
votes
3 answers

How does a C parser distinguish between a type cast and a function call in general?

I'm trying to write a C parser, for my own education. I know that I could use tools like YACC to simplify the process, but I want to learn as much as possible from the experience, so I'm starting from scratch. My question is how I should handle a…
Ord
  • 5,693
  • 5
  • 28
  • 42
17
votes
4 answers

f-string: unmatched '(' in line with function call

I'm trying to use f-strings in python to substitute some variables into a string that I'm printing, and I'm getting a syntax error. Here's my code: print(f"{index+1}. {value[-1].replace("[Gmail]/", '')}") I only started having the problem after I…
Cameron Delong
  • 454
  • 1
  • 6
  • 12
16
votes
4 answers

Direct C function call using GCC's inline assembly

If you want to call a C/C++ function from inline assembly, you can do something like this: void callee() {} void caller() { asm("call *%0" : : "r"(callee)); } GCC will then emit code which looks like this: movl $callee, %eax call *%eax This…
mtvec
  • 17,846
  • 5
  • 52
  • 83
14
votes
2 answers

Ambiguity between function and function in namespace with same argument

Can anybody explain why there is an ambiguity between A::f(const B& b) and f(const A::B& b). I consider the code to be quite explicit about the intention. #include namespace A { class B { protected: double value_; public: …
14
votes
6 answers

How to call a PHP function in JavaScript?

I have index.php