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
229
votes
4 answers

Default value in Go's method

Is there a way to specify default value in Go's function? I am trying to find this in the documentation but I can't find anything that specifies that this is even possible. func SaySomething(i string = "Hello")(string){ ... }
denniss
  • 17,229
  • 26
  • 92
  • 141
177
votes
3 answers

Converting list to *args when calling function

In Python, how do I convert a list to *args? I need to know because the function scikits.timeseries.lib.reportlib.Report.__init__(*args) wants several time_series objects passed as *args, whereas I have a list of timeseries objects.
andreas-h
  • 10,679
  • 18
  • 60
  • 78
93
votes
6 answers

How to call a function, PostgreSQL

I'm trying to use a function with PostgreSQL to save some data. Here is the create script: -- Function: "saveUser"(integer, character varying, character varying, character varying, character varying, character varying) -- DROP FUNCTION…
Erkan Haspulat
  • 12,032
  • 6
  • 39
  • 45
91
votes
1 answer

What is the difference between parent.frame() and parent.env() in R; how do they differ in call by reference?

It would be helpful if someone can illustrate this with a simple example? Also, where would it be useful to use parent.frame() instead of parent.env() and vice versa.
suncoolsu
  • 1,414
  • 1
  • 11
  • 12
74
votes
9 answers

Why does "noreturn" function return?

I read this question about noreturn attribute, which is used for functions that don't return to the caller. Then I have made a program in C. #include #include noreturn void func() { printf("noreturn…
msc
  • 33,420
  • 29
  • 119
  • 214
72
votes
3 answers

Does the order of functions in a Python script matter?

Let's say I have two functions in my script: sum_numbers and print_sum. Their implementation is like this: def sum_numbers(a, b): return a + b def print_sum(a, b): print(sum_numbers(a, b)) So my question is: does the order in which the…
flpn
  • 1,868
  • 2
  • 19
  • 31
66
votes
6 answers

What registers to save in the ARM C calling convention?

It's been a while since I last coded arm assembler and I'm a little rusty on the details. If I call a C function from arm, I only have to worry about saving r0-r3 and lr, right? If the C function uses any other registers, is it responsible for…
richq
  • 55,548
  • 20
  • 150
  • 144
57
votes
3 answers

Using print() (the function version) in Python2.x

I understand the difference between a statement and an expression, and I understand that Python3 turned print() into a function. However I ran a print() statement surrounded with parenthesis on various Python2.x interpreters and it ran flawlessly, I…
rahmu
  • 5,708
  • 9
  • 39
  • 57
51
votes
3 answers

Call external javascript functions from java code

By using Java Scripting API, I am able to execute JavaScript within Java. However, can someone please explain what I would need to add to this code in order to be able to call on functions that are in C:/Scripts/Jsfunctions.js import…
MRK187
  • 1,545
  • 2
  • 13
  • 20
44
votes
3 answers

How to get (sub)class name from a static method in Python?

If I define: class Bar(object): @staticmethod def bar(): # code pass class Foo(Bar): # code pass Is it possible for a function call Foo.bar() to determine the class name Foo?
Jean-Pierre Chauvel
  • 946
  • 2
  • 9
  • 21
43
votes
16 answers

Why is inlining considered faster than a function call?

Now, I know it's because there's not the overhead of calling a function, but is the overhead of calling a function really that heavy (and worth the bloat of having it inlined) ? From what I can remember, when a function is called, say f(x,y), x and…
kodai
  • 3,080
  • 5
  • 32
  • 34
40
votes
3 answers

Can memcpy or memmove return a different pointer than dest?

The function memmove is defined like this: void *memmove(void *dest, const void *src, size_t n); In the Linux manual page, it says: RETURN VALUE The memmove() function returns a pointer to dest. Why isn't the function just defined as void…
Martin Ueding
  • 8,245
  • 6
  • 46
  • 92
38
votes
1 answer

Is it possible to explicitly call a name mangled function?

Suppose I have something along the lines of struct Foo { void goo() {printf("Test");} } external void _ZN3Foo3gooEv(Foo *f); int main() { Foo f; _ZN3Foo3gooEv(&f); } Is it possible to call Foo::goo() through the name mangled…
Henry
  • 495
  • 3
  • 11
37
votes
4 answers

What's the use of multiple asterisks in the function call?

I can't think of any practical use of multiple asterisks in the function call: void foo(int a, char b) { } int main(void) { (**************foo)(45, 'c'); //or with pointer to function: void (*ptr)(int, char) = foo; (******ptr)(32,…
Quentin
  • 1,090
  • 13
  • 24
34
votes
6 answers

Calling a function through its address in memory in c / c++

Given knowledge of the prototype of a function and its address in memory, is it possible to call this function from another process or some piece of code that knows nothing but the prototype and memory address? If possible, how can a returned type…
dtech
  • 47,916
  • 17
  • 112
  • 190
1
2 3
50 51