Parrot's had the facilities in it to call native functions for quite some time (months, possibly upwards of a year) but we've really not used it any--it's just not solved any real problems for folks doing parrot development. Well, since I'm looking at parrot as a target for production work, I've started using it. At the moment, as part of the parrot repository, there are interface files for ncurses (base and form lib) and PostgreSQL.
There's an ncurses version of life in the examples/assembly directory as well, if you want to play around with it. (It's in PIR format, so it's a touch tough to decipher by hand, though if you go back some versions in CVS you'll find a more readable version) Useful? Well... no, not really, at least not at the moment. (Though I need the ncurses and forms stuff for work) Cool, though.
The PostgreSQL interface is also really keen, in its own way. (Though I'm already a touch annoyed with the connection scheme for Postgres. Polling. Bleah) It means, with a bit of code--like, say:
.pcc_sub _MAIN prototyped .param pmc argv .include "postgres.pasm" P17 = global "PostgreSQL::PQconnectStart" P0 = P17 S5 = "host=dbhost dbname=sbinstance user=username password=somepassword" invoke retry: P18 = P5 P0 = global "PostgreSQL::PQconnectPoll" invoke print "status: " print I5 print "\n" eq 3, I5, continue eq 0, I5, panic sleep 1 branch retry panic: print "Argh! Failed\n" end continue: P0 = global "PostgreSQL::PQexec" P5 = P18 S5 = "create table foo (bar int)" invoke P0 = global "PostgreSQL::PQresultErrorMessage" invoke print S5 print "\n" end .endYou can add a new table, foo, to your postgres database. Presumably other things too, I've just not written the PIR to do it. (Though the full PostgreSQL 7.3 C interface is wrapped)
Dunno whether this counts as scary, or really cool. Or, I suppose, both. :)
Posted by Dan at October 8, 2003 11:09 AM
| TrackBack (0)