Archive: March 09, 2003
Via LtU, Copying, Cloning, and Marshalling in .NET.
I hate to admit it, but as a veteran C++ programmer and COM aficionado, I've spent an embarrassingly large part of the last decade thinking about how the objects in my code will be copied, duplicated, and marshalled from one place to the next. In other words, I spent a lot of time pushing bits around. These days, I'm spending more time with C# and the .NET environment, which offer a wide spectrum of language features and runtime services that make the art of programming vastly simpler, in almost every conceivable fashion -- but still, I find myself wondering about the precise semantics of all the various copying, cloning, and marshalling mechanisms at play in my code.
It has a great little diagram to explain shallow vs. deep copying 
Oh my gosh, a Firefly gag reel!!
God I miss that show :'(
The subject says it all. Is it possible to load classes dynamically in PHP? In other words, can I say new $foo, where $foo is a string containing the name of a class? Hmm...
Ok, that answers that... it turns out it's possible to say "new $foo", but not "new "Foo"".
The following works and prints the constructor's message:
<?php class Foo{ function Foo(){ echo "Foo constructor called!<br>"; } }
$foo = "Foo"; $f = new $foo; ?>
But if the last line is $f = new "Foo", it doesn't.
Anyway, this is good enough for my purposes. I wanted to be able to load classes dynamically in my CMS, based on information in a configuration file. If I couldn't do this, I would have gotten around it by dynamically calling a function, which I was sure PHP could do.
Hey, and it's not even case sensitive I can say $f = new $foo; where $foo is "foo".
Hey, I've finally gotten my CMS to the point where it can run my weblog Only downside is that comments don't work yet with it. But, at this point I think the only way to give me the incentive to get that working is to switch over to running my main site on it. So I'm going to do that 
But shoot, I just realized that I didn't put the RSS generation into my CMS yet... well, here goes. Watch for breakage here over the next few hours 
Simon gave me the impetus to fix my code for pinging weblogs.com. So I've fixed it... let's see if this works.
Ok, worked. Now, for why it was broken... there were really two things happening at once that broke it. First, my site is a frankenstein running partially on my CMS and partially not. Some of my settings (I think maybe all now) are coming from the CMS (Settings, as in the name of my weblog and its URL). But through different revisions of my CMS, some settings came from MySQL, and some from the CMS's main configuration file. So stuff's all over the place. It turns out I had the name of my weblog in the config file, but not the address... so I added that.
After I did that, it turns out it was still broken, because while I'm working on version 3, my copy of my XML-RPC library is broken So I had to fix a piece of that before it would work.
Now that Simon mentions it, I may as well ping blo.gs too 
Hey, the only thing that stinks about this is that weblogs.com is so overloaded that it just took 71 seconds to respond to my pings (to both the regular and the RSS versions). So I often have to wait around for it to finish.
Ok, testing pinging blo.gs... Yep! Worked.
|
Generated in about 0.05s. (Used 7 db queries) |
I hate PHP
Elliot Anderson,
Dude!! You theman! The reverse replacement forarray_u...
Alex Ndungu: Oct 11, 1:35am