Is there anything deterministic about what Sql.Sql->create() throws? I just added this to AIDOs startup to autocreate a database, and I'm not overly pleased with it:
mixed err = catch { sql = objectp(url)?url:Sql.Sql( url ); };
//FIXME: Very crude, but works for the normal sqlurl case. if(err && !objectp(url)) { string baseurl = reverse(reverse(url/"/")[1..])*"/"; string dbname = (url/"/")[-1]; werror( "NOTE: Trying to create database %O\n", dbname ); Sql.Sql( baseurl ) ->query( "CREATE DATABASE IF NOT EXISTS "+ dbname ); } else if(err) { werror("FATAL: Could not connect to local media database!\n"); //FIXME: Just letting this through results in a unfriendly backtrace. }
sql = objectp(url)?url:Sql.Sql( url );
To keep things on topic: What was the result of the latest discusion about how to write ranges ending before the last index? [..-1]...
I know that I favor [:-1], i.e. letting [x..y] work as before and having [x:y] do the sizeof(a)-y-1 for you. There were probably some good arguments against this, but I can't remember them.
/ Martin Nilsson (saturator)
Previous text:
2004-01-21 02:00: Subject: Sql interface
Is there anything deterministic about what Sql.Sql->create() throws? I just added this to AIDOs startup to autocreate a database, and I'm not overly pleased with it:
mixed err = catch { sql = objectp(url)?url:Sql.Sql( url ); };
//FIXME: Very crude, but works for the normal sqlurl case. if(err && !objectp(url)) { string baseurl = reverse(reverse(url/"/")[1..])*"/"; string dbname = (url/"/")[-1]; werror( "NOTE: Trying to create database %O\n", dbname ); Sql.Sql( baseurl ) ->query( "CREATE DATABASE IF NOT EXISTS "+ dbname ); } else if(err) { werror("FATAL: Could not connect to local media database!\n"); //FIXME: Just letting this through results in a unfriendly backtrace. }
sql = objectp(url)?url:Sql.Sql( url );
To keep things on topic: What was the result of the latest discusion about how to write ranges ending before the last index? [..-1]...
/ Peter Bortas
On Wed, Jan 21, 2004 at 02:10:02AM +0100, Martin Nilsson (saturator) @ Pike (-) developers forum wrote:
I know that I favor [:-1], i.e. letting [x..y] work as before and having [x:y] do the sizeof(a)-y-1 for you. There were probably some good arguments against this, but I can't remember them.
I don't remember how it was, but it seems logical (to me) that a[x..y] where x and y are negative should be interpreted as sizeof(a)+x and sizeof(a)+y. In fact, it is like this but only for indexes, not ranges.
Regards, /Al
One such argument is that it doesn't extend to indexing single elements.
/ Martin Stjernholm, Roxen IS
Previous text:
2004-01-21 02:05: Subject: Sql interface
I know that I favor [:-1], i.e. letting [x..y] work as before and having [x:y] do the sizeof(a)-y-1 for you. There were probably some good arguments against this, but I can't remember them.
/ Martin Nilsson (saturator)
The best proposal I've seen so far is to import the LPC syntax, e.g. foo[..<2].
/ Martin Stjernholm, Roxen IS
Previous text:
2004-01-21 02:00: Subject: Sql interface
Is there anything deterministic about what Sql.Sql->create() throws? I just added this to AIDOs startup to autocreate a database, and I'm not overly pleased with it:
mixed err = catch { sql = objectp(url)?url:Sql.Sql( url ); };
//FIXME: Very crude, but works for the normal sqlurl case. if(err && !objectp(url)) { string baseurl = reverse(reverse(url/"/")[1..])*"/"; string dbname = (url/"/")[-1]; werror( "NOTE: Trying to create database %O\n", dbname ); Sql.Sql( baseurl ) ->query( "CREATE DATABASE IF NOT EXISTS "+ dbname ); } else if(err) { werror("FATAL: Could not connect to local media database!\n"); //FIXME: Just letting this through results in a unfriendly backtrace. }
sql = objectp(url)?url:Sql.Sql( url );
To keep things on topic: What was the result of the latest discusion about how to write ranges ending before the last index? [..-1]...
/ Peter Bortas
But the <2 syntax wasn't invented when Pike was split off from LPC. Plus, if all mud parsers jumped off a cliff, should Pike follow? :)
Apart from all that, I would like both having x[a:b] and the <2 syntax :)
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2004-01-23 00:33: Subject: Re: Sql interface
and it has historic precedence. pike is based on lpc after all.
/ Brevbäraren
Wasn't you the one that wanted to reduce the amount of syntax in Pike?
Completely different topic: How was breakpoints supposed to work in unbug in principle? What role did the now disabled F_BREAKPOINT play?
/ Martin Nilsson (saturator)
Previous text:
2004-01-23 00:59: Subject: Re: Sql interface
But the <2 syntax wasn't invented when Pike was split off from LPC. Plus, if all mud parsers jumped off a cliff, should Pike follow? :)
Apart from all that, I would like both having x[a:b] and the <2 syntax :)
/ Fredrik (Naranek) Hubinette (Real Build Master)
Wasn't you the one that wanted to reduce the amount of syntax in Pike?
Yes, but who said I had to make sense? :) Seriously, after using python for a while, I've realized that the pike range operator isn't very good...
Completely different topic: How was breakpoints supposed to work in unbug in principle? What role did the now disabled F_BREAKPOINT play?
Simple: Modify the byte code and insert an F_BREAKPOINT, then set a GDB breakpoint in o_breakpoint(). If I remember correctly, it then used a breakpoint inside the interpreter to ensure that it could put back the original opcode, execute it, and then put the F_BREAKPOINT back again...
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2004-01-23 01:31: Subject: Re: Sql interface
Wasn't you the one that wanted to reduce the amount of syntax in Pike?
Completely different topic: How was breakpoints supposed to work in unbug in principle? What role did the now disabled F_BREAKPOINT play?
/ Martin Nilsson (saturator)
pike-devel@lists.lysator.liu.se