Argument-passing may refer to two different things: (1) the process of providing a program being started with some initial pieces of information (the arguments) on its command line; (2) the process of providing the initial values (the arguments) for the parameters of a function when it is called.
Questions tagged [argument-passing]
777 questions
15
votes
3 answers
x86 calling convention: should arguments passed by stack be read-only?
It seems state-of-art compilers treat arguments passed by stack as read-only. Note that in the x86 calling convention, the caller pushes arguments onto the stack and the callee uses the arguments in the stack. For example, the following C…

Jeehoon Kang
- 311
- 1
- 13
15
votes
3 answers
Command line passing quotes within quotes
I've been searching for a solution to this but couldn't find one. Not sure if its possible.
Can I pass into command-line execution that passes a in a bat file which has an input file as its arguments?
So from the command-line it'll look like…

user2617566
- 201
- 1
- 2
- 7
15
votes
4 answers
C function call with too few arguments
I am working on some legacy C code. The original code was written in the mid-90s, targeting Solaris and Sun's C compiler of that era. The current version compiles under GCC 4 (albeit with many warnings), and it seems to work, but I'm trying to…

John Bollinger
- 160,171
- 8
- 81
- 157
14
votes
2 answers
batch script subroutine: Passing arguments
My understanding is that in order to get the date from a file passed into a subroutine as an argument, you must re-set that argument as a variable within the subroutine. Is this correct? This doesn't make since to me, so I am wondering if I do not…

Fractal
- 1,748
- 5
- 26
- 46
13
votes
2 answers
conditional inclusion of arguments in a function call
I want to call a function but depending on the situation I might call it with extra arguments or not. Here is a simple example:
FUN <- function(arg1 = "default1", arg2 = "default2", arg3 = "default3")
print(list(arg1, arg2, arg3))
x1 <-…

flodel
- 87,577
- 21
- 185
- 223
12
votes
4 answers
How do I create a function that accepts multiple argument types from pipeline and command line?
I'm trying to write a function that takes multiple arguments, which can come either from the command line, or from the pipeline. The arguments can be strings or directory objects. The idea is that any of the following invocations should…

Paul Moore
- 6,569
- 6
- 40
- 47
12
votes
3 answers
How can I pass to IRB if I don't specify ?
Since:
irb --help
Usage: irb.rb [options] [programfile] [arguments]
I know I can pass arguments to ARGV if I include a programfile
eg:
irb test.rb A B C
where test.irb is simply "p ARGV"
produces:
["a", "b", "c"]
Making programfile be con in…

DMisener
- 891
- 1
- 8
- 15
12
votes
3 answers
Passing a class as an argument to a method in java
I am writing a method were I would like to pass a class to a method, where a part of the code includes checking if the object is of a certain type. This is what I want (but which obviously doesn't work):
private static class MyClass1 { /***/…

tor
- 636
- 3
- 7
- 18
11
votes
2 answers
Clojure Keyword and Optional Argument Problem
I want to create a function that takes in a required argument x, and either a optional argument opt1 OR a keyword argument opt2.
Right now I have
(defn foo x & [opt1 {:keys [opt2]}]
...
But the above signature only lets me pass in keyword…

unj2
- 52,135
- 87
- 247
- 375
11
votes
4 answers
How many ways are there to pass char array to function in C?
foo(char *s)
foo(char *s[ ])
foo(char s[ ])
What is the difference in all these ?
Is there any way in which I will be able to modify the elements of the array which is passed as argument, just as we pass int or float using & and value of actual…

mightyWOZ
- 7,946
- 3
- 29
- 46
11
votes
2 answers
Passing an empty IEnumerable argument to a method
I have this method (simplified):
void DoSomething(IEnumerable numbers);
And I invoke it like this:
DoSomething(condition==true?results:new List());
The variable results is formed with a LINQ select condition (IEnumerable).
I was…

avance70
- 787
- 1
- 11
- 22
11
votes
1 answer
Generalizing `...` (three dots) argument dispatch: S4 methods for argument set including `...`
Actual question
Is it possible to define methods for a set of signature arguments that includes ... (as opposed to exclusively for ...)? It's not possible "out-of-the-box", but would it theoretically be possible at all (involving some tweaks) or is…

Rappster
- 12,762
- 7
- 71
- 120
11
votes
2 answers
Passing implementations by ref: cannot convert from 'Foo' to 'ref IFoo'
Can someone explain to me why this is incorrect in C#:
namespace NamespaceA
{
public class ClassA
{
public interface IInterfaceA
{
String Property
{
set;
}
}
…

JHowIX
- 1,683
- 1
- 20
- 38
10
votes
1 answer
How to pass arguments (not command line arguments) to functions within batch scripts
I'm writing a batch file for automating the creation of typical folder structures for products that we sell. I would like to be able to call my batch file with 2 optional arguments; the name of the supplier and a file for creating lots of folders at…

punkrockbuddyholly
- 9,675
- 7
- 36
- 69
10
votes
2 answers
Lazy Evaluation: Why can't I use plot(..., xlim = c(0,1), ylim = xlim)?
One of R's greatest feature is lazy evaluation. This leads to the often encountered style that one can use an arguments as the value of another arguments. For example, in Hadley's great book on Advanced R you see this example:
g <- function(a = 1, b…

Henrik
- 14,202
- 10
- 68
- 91