Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-03-20 18:59:28


On 03/20/08 16:53, Eric Niebler wrote:
> Larry Evans wrote:
>> What about recording the arity *with* the tag instead of in
>> the expression associated with the tag? IOW, instead of:
>>
>> expr<Tag,Args,Arity>
>>
>> have:
>>
>> expr<tag_arity<Tag,Arity>,Args>
>>
>> Why? Well, it directly associates the arity with the Tag instead
>> of with the expression. After all, sin(X) is not expressed
>> as sin(x,1). [or in lisp terms, (sin x) is not expressed as
>> (sin x 1) ].
>
> What problem does that solve?
>

I don't think it solves any problem that can't
already be solved, but it makes the solution
clearer. It's clearer because the arity
is associated with the tag *not* the
expression. The arity of a tag does not depend
on the expression; so, it should not be in
the expression. Instead the arity of the tag
determines the expression validity.

OK, but you may say "the arity *still* is in
the expression:

   expr<tag_arity<Tag,Arity>,Args>

"; however, it's "more closely" associated
with the tag than the expression, so it's
really more a matter of style, I guess.
OTOH, I would guess it would make specifying
morphisms between algebra's easier since
any morphism would map equal arity's to
equal arities; and if the arity were
directly associate with the tag, as in
tag_arity<Tag,Arity>, then the mapping
would be easier to understand and verify
(with maybe a boost concepts class
which assured the pairs in the mpl map
had equal arities on both sides).


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