named-parameters

Optional Specification of some C# Optional Parameters

Suppose you have a method with the following signature: public void SomeMethod(bool foo = false, bool bar = true) { /* ... */ } When calling this method, is there a way to specify a value for bar and not foo? It would look something like... SomeMethod(_, false); ... which would translate to... SometMethod(false, false); ... at ...

Is there a programming language that performs currying when named parameters are omitted?

Many functional programming languages have support for curried parameters. To support currying functions the parameters to the function are essentially a tuple where the last parameter can be omitted making a new function requiring a smaller tuple. I'm thinking of designing a language that always uses records (aka named parameters) for ...

Complicated .NET factory design

Hello SO; I'm planning to ask a fairly elaborate question that is also something of a musing here, so bear with me... I'm trying to design a factory implementation for a simulation application. The simulation will consist of different sorts of entities i.e. it is not a homogenous simulation in any respect. As a result, there will be nu...

Named keywords in decorators?

I've been playing around in depth with attempting to write my own version of a memoizing decorator before I go looking at other people's code. It's more of an exercise in fun, honestly. However, in the course of playing around I've found I can't do something I want with decorators. def addValue( func, val ): def add( x ): ...

What does ‘?’ stand for in SQL?

I have this SQL by a programmer: $sql = " INSERT INTO `{$database}`.`table` ( `my_id`, `xType`, `subType`, `recordID`, `textarea` ) VALUES ( {$my_id}, ?xType, ?subType, {$recordID}, ?areaText ) "; My question is why is he using ? before v...

Simulate named parameters in Java

I write a little web API which should it make easy to create URIs. Each resource class should contain a method createURI which takes the needed parameters. This method should use a helper method, populateUriTemplate, in the background to create an URI string. populateUriTemplate needs key value pairs to populate an URI template. In anoth...

Is it possible for an optional argument value to depend on another argument in Scala

Does anyone know if something like this is possible in Scala: case class Thing(property:String) def f(thing:Thing, prop:String = thing.property) = println(prop) The above code doesn't compile; giving the error error: not found: value thing at thing.property The following shows the expected behaviour: f(Thing("abc"), "123") // print...

Using named arguments with variable length un-named arguments in Python

I apologize if this question has already been asked/answered, I would have expected that to be the case but was unable to find any related questions... I'd like to create a python function that takes two mandatory arguments, one named argument, and some unknown number of other, non-named arguments as so: def my_function(arg1, arg2, arg...

Can I use Named and Optional Arguments in ironpython

I hope to load .net dll in ironpython. But one of static functions in .net dll, has some Named and Optional Arguments. like, Draw(weight:w,height:h, Area=1) Only can I use full arguments? ...

HQL Query with multiple Criteria

I am trying to write a HQL Query which selectes rows from a table based on multiple criteria. firstName,lastName the catch is that the query should be flexible to ignore any empty or null values so select t from table t where (:firstname = '' or t.firstName = :firstName) AND (:lastName = '' OR t.lastName = :lastName) I would have ...

Using switches inside batch file

I have a batch file and I need to invoke it like this "mybatch.bat -r c:\mydir", and the batch file loops through the directory and writes file names to the output. The problem I'm facing is that I cannot read parameter "-r". Here's what it looks like: @echo off echo [%date% %time%] VERBOSE START for %%X in (%1\*.xml) do echo [%dat...

How to use named parameters in Python methods that are defaulting to a class level value?

Usage scenario: # case #1 - for classes a = MyClass() # default logger is None a = MyClass(logger="a") # set the default logger to be "a" a.test(logger="b") # this means that logger will be "b" only inside this method a.test(logger=None) # this means that logger will be None but only inside this method a.test() # here logger should defa...

Java named parameter's name (for Oracle JDBC function result)

I'm going to call a function, and set some parameters by name, example: Connection c = null; ResultSet rs = null; String query; PreparedStatement ps; CallableStatement cs = null; try { c = DbUtils.getConnection(); cs = c.prepareCall("{? = call get_proc_name(?, ?) }"); cs.registerOutParamet...

How to set named argument for string.Format ?

I have C# error when calling: string.Format(format:"abbccc", 1,22); The error is "Named argument specifications must appear after all fixed arguments have been specified" How can I fix this? [Edit] I prefer to use named parameters. ...