
On 03/28/08 17:35, Markus Werle wrote:
Larry Evans wrote:
that suggestion about complete separation of grammar from transform is just *highly* speculative.
... but one I like to hear someone say. This idea should be investigated.
The bundling of grammar with transform appears to be an example of the "blob" anti-pattern. the attached code is a translation of the example on p. 16 of _C++ Template Metaprogramming_. The translation was needed to convert the templated function into a template class in order to more closely reflect the proto structure. The name, apply_fg, from the book example was retained but appended with _sep or _blob to avoid name conflicts. Hopefully someone will be able to explain why the attachment does or doesn't show that proto's mixture of grammar with transform is an example of the blob anti-pattern. AFAICT, the reason proto mixes the two is to save typing. The reason not to mix the two, in addition to the anti-pattern reason (if that's the case), is that it made the code harder for me to understand. Although better documentation might make it easier for me to understand, that still leaves the question of whether it's an instance of the blob anti-pattern. To me, the mixing of grammar with transform is like mixing the test with the execute of c++ if statement. IOW, instead of: if(test) { execute; } there's just: test_execute; Separating the test from the execute is easier to understand.