Crufty blog code, more C++ nastiness

I've crufted together version 0.1 of my blog thing. It's crufty in the extreme, and I need to split out each entry into a separate file really, and have just the few most recent ones on the front page. Still, this generates some XHTML, which RXP says is valid, so it's a start. All in Perl of course, although it isn't the most tasteful Perl I've written.

At work: today I have been mostly writing reference counting smart pointer classes and dicking with auto_ptr.

I also enjoyed splitting apart the two stages of object creation (allocating memory and calling a constructor to turn it into an object). You have to call operator new (which isn't the same as the ‘new operator’, of course) to allocate memory, and use ‘placement new’ to call the constructor. For example:

// Allocate enough memory to hold a 'string', but don't
// initialise it.  This is a 'malloc' in sheep's clothing.
void *memory = operator new(sizeof(string));

// Call some constructor string::string(...).  We have to have
// another form of 'new' to do this, because the constructor is
// far too 'special' to be called directly without fiddling around.
string *s = new (memory) string("hello");

< Where did the last year go? | Mobile phone data cable >

Miniblog

(nuggets of inanity)

Tuesday Apr 24th 2007, 16:54 »
Just took the annual web design survey that AListApart do. I don't realy consider myself to be a web designer, but I have been doing a lot of HTML and CSS lately.
Monday Apr 23rd 2007, 18:23 »
Strange, there appears to be a bare-knuckle boxing match going on in the field outside my flat. Wish they wouldn't make so much noise about it.
Thursday Mar 1st 2007, 18:47 »
“In its written form, Hebrew has no vowels, making it the ideal language for texting.”
—Said in jest on some Radio 4 programme just now.

Archive: 2007 · 2006 · 2005 · 2004
Feed