Re: [Gaea] Named optional attributes

Dave Abrahams <[email protected]>
Newsgroups gmane.comp.lib.boost.documentation
Message-ID <[email protected]>
on Sat Nov 05 2011, Joel de Guzman <joel-AT-boost-consulting.com> wrote:

> On 11/6/2011 9:08 AM, Joel de Guzman wrote:
>> On 11/6/2011 5:58 AM, Matias Capeletto wrote:
>
> If we go this route (still unsure), perhaps we can make it clear
> by having a naming protocol that makes templates with side-effects
> clear. E.g. we can have in-place versions for:
>
>   [decl [append! x e]]
>   [decl [insert! x e n]]
>   [decl [reverse! x]]
>   [decl [join! x y]]
>
> Even:
>
>   [decl [transform! x f]]
>
> This will open up a whole slew of templates like:
>
>   [decl [for-each! x f]]
>
> Perhaps we should then rename [set x v] --> [set! x v]
>
> Is this good or bad? I don't know. Well, scheme and lisp do
> have side-effects. But, I kinda agree with Terrence Parr:
> "The fact that StringTemplate does not allow such things
> as assignments (no side-effects) should make you suspicious
> of engines that do allow it."

IMO if you can afford it, it's better to go side-effect-free.
If you can't afford it, I suggest labeling the name on which the
side-effect occurs, rather than labeling the function.

   [decl [append 'x e]]
   [decl [insert 'x e n]]
   [decl [reverse 'x]]
   [decl [join 'x y]]
   [decl [transform 'x f]]
   [decl [for-each 'x 'f]]

You might want to ask the caller to label the arguments that way, too...

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.