Questions tagged [argument-passing]

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.

777 questions
5
votes
3 answers

OOP: Passing an object vs. passing attributes into a method

In terms of a clean design, which is preferable? 1) Passing an object, say yourself, to another class method which will manipulate the attributes of the passed object directly. Inside Class A... B.doStuff(this); 2) Pass the object's attributes…
Aram Kocharyan
  • 20,165
  • 11
  • 81
  • 96
5
votes
4 answers

How can I pass command-line arguments via file association in Vista 64?

How can one pass command line arguments via file association in Vista 64? I recently built a PC running Vista Ultimate 64-bit. I noticed several of the Perl scripts I transferred failed due to command-line arguments not being passed. As a simple…
vlee
  • 1,369
  • 3
  • 14
  • 23
5
votes
1 answer

User-Function, formals object defined but not found by code

The business I work for does ELISA analysis all the time (the immune assay), and so I am programming a function that takes a csv format version of the machine readout for the optical densities and runs a statistical regression called a 4PL analysis.…
Eich
  • 93
  • 5
5
votes
9 answers

Best practices for number of arguments for subroutines in C

I've recently started working on developing APIs written in C. I see some subroutines which expect 8(Eight) parameters and to me it looks ugly and cumbersome passing 8 parameters while calling that particular subroutine. I was wondering if something…
Amit
  • 327
  • 1
  • 4
  • 12
5
votes
1 answer

Keyword argument in unpacking argument list/dict cases in Python

For python, I could use unpacking arguments as follows. def hello(x, *y, **z): print 'x', x print 'y', y print 'z', z hello(1, *[1,2,3], a=1,b=2,c=3) hello(1, *(1,2,3), **{'a':1,'b':2,'c':3}) x = 1 y = (1, 2, 3) z = {'a': 1, 'c':…
prosseek
  • 182,215
  • 215
  • 566
  • 871
5
votes
2 answers

splat over JavaScript object (with new)?

How do I splat across objects without using ECMA6 features? Attempt function can(arg0, arg1) { return arg0 + arg1; } function foo(bar, haz) { this.bar = bar; this.haz = haz; } myArgs = [1,2]; With can I can just do: can.apply(this,…
A T
  • 13,008
  • 21
  • 97
  • 158
5
votes
2 answers

Can this Ruby method call be made without **{} at the end?

I have a method defined like this: def woot(a = nil, b: nil) ... end What is the least ugly way to pass a Hash instance to a when b is omitted? I tried woot(x: 1) woot({x: 1}) h = {x: 1} woot(h) but they all raise ArgumentError: unknown keyword:…
jedediah
  • 1,179
  • 9
  • 20
5
votes
3 answers

Passing increment/decrement operator to a function

I have the same function with the only difference that it will either increment or decrement. I would like to generalize from that. template void f(int& i, O op){ op(i); } int main() { int i; f(i,operator++); f(i,operator--); …
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
5
votes
4 answers

Process.Start - Pass html code to exe as argument

I am using the code below to start a executable file from a windows service and I need to pass html code (stored in a variable) as an argument. I am escaping with double quotes but this is not working. What do I need to do in order to pass this…
user1017477
  • 864
  • 1
  • 12
  • 20
5
votes
3 answers

Cost of using repeated parameters

I consider refactoring few method signatures that currently take parameter of type List or Set of concrete classes --List[Foo]-- to use repeated parameters instead: Foo*. Update: Following reasoning is flawed, move along... This would allow me…
Palimondo
  • 7,281
  • 4
  • 39
  • 58
5
votes
1 answer

Pointer argument to boost python

What's the best way to make a function that has pointer as argument work with boost python? I see there are many possibilities for return values in the docs, but I don't know how to do it with arguments. void Tesuto::testp(std::string* s) { if…
piotr
  • 5,657
  • 1
  • 35
  • 60
5
votes
3 answers

Pass multiple files / folders from windows explorer to external application

Hi does anyone know how to get windows explorer to pass multiple files / folders through to an external app (c#) referenced in the registry? I am current able to act upon a single file / folder using the %1 syntax but not sure how to get explorer to…
Grant
  • 11,138
  • 32
  • 94
  • 140
5
votes
2 answers

Trying to pass CGrect to performSelector withObject

I'm trying to pass a CGRect: SEL frameSel = NSSelectorFromString(@"setFrame:"); CGRect rect = CGRectMake(10, 10, 200, 100); [object performSelector:frameSel withObject:rect ]; But this does not compile I also tried: SEL frameSel =…
Fabrizio Farinelli
  • 241
  • 1
  • 4
  • 8
5
votes
1 answer

Different behaviour for generic method return value to method and to assignment

I faced with code, which compilation result was surprised for me. public class Test3{ public static Map map(){return new HashMap();} } class A{ static void f(Map bcMap){} public static void…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
5
votes
2 answers

variadic template arguments: can I pick reference vs value depending on type?

edit This is not a duplicate of Undefined reference to static class member. That question explored the cause of the problem (which I explain below). Here, I'm looking for a different solution from those proposed in the answers to that questions…
Walter
  • 44,150
  • 20
  • 113
  • 196