"function ... is not callable using argument types"

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 1 04:15:24 PST 2015


  I need to pass some config to ddbc driver. When I use static 
const all work ok.
static const string PGSQL_UNITTEST_HOST = "localhost";
static const int    PGSQL_UNITTEST_PORT = 5432;
static const string PGSQL_UNITTEST_USER = "postgres";
static const string PGSQL_UNITTEST_PASSWORD = "Infinity8";
static const string PGSQL_UNITTEST_DB = "test2";

But using static const mean that settings will be hardcoded. But 
I need to read it from config file.

So I need so simply declared it as:

this(parseConfig parseconfig)
{

string PGSQL_UNITTEST_HOST = parseconfig.dbhost; 	
int    PGSQL_UNITTEST_PORT = parseconfig.dbport; 	 	
string PGSQL_UNITTEST_USER = parseconfig.dbuser;
string PGSQL_UNITTEST_PASSWORD = parseconfig.dbpass;
string PGSQL_UNITTEST_DB = parseconfig.dbname;
...
}

But when I do it like above code stop compile and I am getting 
error:

source\app.d(218): Error: function 
ddbc.drivers.pgsqlddbc.PGSQLDriver.generateUrl (string host, 
ushort port, string dbname) is not callable using argument types  
(string, int, string)

I looked at driver source code and have found next code:

     class PGSQLDriver : Driver {
     	// helper function
     	public static string generateUrl(string host, ushort port, 
string dbname) {
     		return "postgresql://" ~ host ~ ":" ~ to!string(port) ~ "/" 
~ dbname;
     	}
     	public static string[string] setUserAndPassword(string 
username, string password) {
     		string[string] params;
     		params["user"] = username;
     		params["password"] = password;
     		params["ssl"] = "true";
     		return params;
     	}
		
So it's look like that it can accept strings and ints without 
problem.

And I really can't understand why it's accept only "static const 
string" constructions...
		


More information about the Digitalmars-d-learn mailing list