idea: Templates + AJAX = breakthrough application

BCS ao at pathlink.com
Sun Nov 18 21:58:33 PST 2007


Reply to Robert,

> BCS wrote:
> 
>> Reply to Robert,
>> 
>>> I had this idea a while back, except I used a compile-time function
>>> not a template.
>>> 
>> how could you do it with a function? How would you get to the
>> argument list of the function or the list of methods for an aggregate
>> type? You have a good point though, it would almost certainly need to
>> use CTFE for much of the work, the JavaScript if nothing else. Other
>> parts (argument and return value marshaling) would be better in pure
>> template code. For instance, I have a set of template functions
>> somewhere that pack and unpack up a unlimited depth of dynamic arrays
>> into a byte array. It's only about 30 lines of code and will suite
>> for any type of dynamic array.
>> 
> Mixins.
> 
> Having never actually used C++ templates, I feel a lot more
> comfortable writing
> 
> mixin(ctfeFunc(args))
> 
> than writing
> 
> templ!(args)
> 
> .
> 

The only clean way to do it still requiter that ctfeFunc be templated or 
you cant get to any of the semantic info. 

Personably I'd rather not use mixins (my parser generator only uses them 
in two place to generate numbered labels and a goto) My feeling is that it's 
sort of going backwards in the abstraction domain. Also I'd rather get a 
lex/syntax error that points to hard text rather than mixin text. I find 
that a little CTFE, a little template functional programming and a pile of 
tuple foreaches can get a LOT done. 

I would actually recommend playing around with template functional programming 
a little (try some scheme or lisp first though). They are remarkably not 
that nasty in D. OTOH that's me saying this and and I'm a bit off in what 
I think of as nasty (my current project involves using lisp to do code-gen 
for some nasty template Foo, but I get ahead of my self ;-)





More information about the Digitalmars-d mailing list