This is a read-only archive!

PHP namespaces? Nope!

Today, I found out that PHP 5 still doesn't support namespaces. This is kind of extremely crap. I wrote a bunch of classes whose names are simple things like Scale and Numeric. These are good names because non-programmers have to work with this code, and certain names have meanings in those people's field of study which would be helpful to re-use for their sake.

But now I have to rename my classes because I'm sure they're going to clash with something, having such simple and generic names. So I'm likely going to have to append a string to the front or end of each one, e.g. ScaleQuestion and NumericQuestion.

In other words, now I get to implement a hacked-up version of namespaces myself, in nice slow PHP code rather than native compiled PHP-interpreter code, using manual string manipulation of class names. The only thing that's going to allow me to do this is the fact that PHP lets you use strings as symbolic references, which itself is incredibly evil.

Which is worse, living with a deficiency of the language and dumbing down / un-abstracting my code, or making up for its deficiencies by essentially constructing and eval'ing a bunch of strings?

November 12, 2007 @ 5:53 PM PST
Cateogory: Programming
Tags: PHP, OOP

2 Comments

numerodix
Quoth numerodix on November 12, 2007 @ 11:56 PM PST

Eh... I feel for you. The only thing I do with php nowadays is the occasional wordpress hack, and that alone makes me appreciate that I don't have to touch the hackery that is php.

gregf
Quoth gregf on November 13, 2007 @ 3:05 AM PST

I know it sucks, but it is planned for PHP 6 from what I read.