Boost logo

Boost :

From: Darren Cook (darren_at_[hidden])
Date: 2005-05-04 18:23:19


> The only way as long as you commit to not look outside C++. There are
> plenty of text manipulation tools outside C++ that offer what could be
> done with the C++ preprocessor with programming paradigms that I
> consider unworthy of learning. Those tools (sed, awk, perl) are widely
> available, and in my humble opinion any programmer worth her salt should
> have at least a cursory understanding of them.

I've experimented with using PHP and C++ together, with good success.
The nice thing about PHP is it lives inside my C++ source code, see a
mini example [1] below. In the biggest real-world test of this I had a
big PHP array of PHP objects, each object describing some algorithm.

In my make file (actually scons) I compiled my "X.cpp.php" file into
"X.cpp", which was then compiled by g++.

Some issues I had:
  1. I had to keep switching my editor between PHP syntax hilighting and
 C++ syntax. I could get around this by writing a syntax hilighter file
for my editor.

  2. I had to remember to edit the X.cpp.php file, not the X.cpp file. I
got around this a bit by having scons make the X.cpp file read-only.

  3. Line numbers of error messages.

I guess they can all be summarized as lack of tool support.

Darren

[1]
//Normal C++ code here

<?php
$types=Array('int','double','custom_type');
foreach($types as $t){
?>

<?php echo $t;?> generator_of_<?php echo $t;?>(int id){
//...
<?php if($t)=='custom_type'){ ?>
//Special code to make custom_type
<?php }else{ ?>
//Code to make built-in type
<?php } ?>
} //End of the generator_of_* functions

<?php } ?>

//More normal C++ code here


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk