idea: Templates + AJAX = breakthrough application

BCS ao at pathlink.com
Sat Nov 17 21:50:47 PST 2007


I have thought up a really cool template programming idea. I'm so swamped 
now that I don't have time to work on it so I'm throwing it out here to see 
if anyone wants to give it a go. Anyway, her its.

In a nutshell: Auto AJAX from template magic.

it would consist of a template that specializes on a class, interface, struct 
or free function. The template would implement a function that would take 
something of the given type. this function would be the server side of an 
AJAX setup that would exercise the given variable's public interface. The 
template would also generate a const string that is the JavaScript that is 
needed for the client side.

I see it being used something like this:

// given the users partial input,
// return a list of auto compleat choices
char[][] GetChoices(char[] text){...}

const int AJAXport = 0xF00D;
const char[] AJAXaddress = "somwhere.not";

char[] BuildWebPageBody()
{
	char[] ret;

	ret ~= stuff
	ret ~= "<script type='text/javascript'>\n";
	ret ~= AJAX!(GetChoices).JavaScript!(AJAXaddress, AJAXport);
	ret ~= "</script>\n";
	ret ~= moreStuff;
	return ret;
}

AJAXthread AJAXserver;

static this()
{
	AJAXserver = AJAX!(GetChoices).StartServerThread(AJAXport);
}

static ~this()
{
	AJAXserver.kill();
}





More information about the Digitalmars-d mailing list