Re: [Gaea] Named optional attributes

Joel de Guzman <[email protected]>
Newsgroups gmane.comp.lib.boost.documentation
Message-ID <[email protected]>
On 11/6/2011 9:08 AM, Joel de Guzman wrote:
> On 11/6/2011 5:58 AM, Matias Capeletto wrote:
>>>> [var footnotes-list []]
>>>>  [set footnotes-list [append [footnotes-list] [...]]
>>>
>>> TBH, I'm not quite happy with it either. The language is purely
>>> functional apart from that. There should be a way to do above using
>>> a purely FP way, but it's not as easy.
>>
>> At least it follows scheme's (define x y) (set! x z).
>>
>>> As always, suggestions welcome.
>>
>> I was asking about other uses cases, because if it is only introduced
>> to deal with footnotes in HTML maybe they shouldn't need to be
>> introduced right now if it is only used to produce LaTeX or Docbook.
>> That way you can get some time to see how the real implementation
>> works.
> 
> Indeed.
> 
>> If they are introduced, I am tempted to add a [push mutable-var
>> element] construct so the collectors are easier to write.
> 
> Well, that's easy:
> 
>   [def [push x e]
>     [set [x][append [x][e]]]
>   ]
> 
> What's interesting is that you should be able to pass 'var'
> arguments much like C++ references.
> 
> The side-effects make me feel uneasy though. Here, push
> has side-effects while append (and the rest of the gang)
> does not :-(

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."

Regards,
-- 
Joel de Guzman
http://www.boostpro.com
http://boost-spirit.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.