Boost logo

Boost :

Subject: Re: [boost] [local] couple questions
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-05-27 10:21:32


On Thu, May 26, 2011 at 6:52 PM, Jeffrey Lee Hellrung, Jr.
<jeffrey.hellrung_at_[hidden]> wrote:
> 1) I notice from
>
> http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html#boost_local.Getting_Started.installation
>
> that (proposed) Boost.Local has a dependency on Boost.ScopeExit.  It seems
> that Boost.Local provides all the functionality of Boost.ScopeExit, and then
> some; at least, that's what seems to be implied by
>
> http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Alternatives.html#boost_local.Alternatives.local_exits
>
> It would seem reasonable then, maybe, should Boost.Local be accepted, to
> remove the dependence on Boost.ScopeExit and officially deprecate
> Boost.ScopeExit in favor of Boost.Local's BOOST_LOCAL_EXIT:
>
> http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Tutorial.html#boost_local.Tutorial.local_exits
>
> What are your (you = Lorenzo or anyone else) thoughts regarding that
> development path?

Yes, it'd make sense to merge Boost.Local and Boost.ScopeExit -- see
footnote 17 at
http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Tutorial.html#ftn.id879016

I'd think then Alexander Nasonov will participate to Boost.Local
review and appear as a Boost.Local co-author.

> 2) I haven't read through the docs in *too* much detail yet, but I would
> guess from, for example,
>
> http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html#boost_local.Advanced_Topics.assigning_local_functions
>
> that copying a Boost.Local functor amounts to something less than a deep
> copy, and possibly an entirely shallow copy.  In other words, does

The copy is shallow. It essentially copies a couple of function
pointers within boost::local::aux::function and the bound variables
are all internally hold by reference:
http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Implementation.html#boost_local.Implementation.local_functions

However the following example...

> int x = 0;
> void BOOST_LOCAL_FUNCTION_PARAMS( bind(int) x ) { // bind x by value, so a
> copy is taken...
>    std::cout << ++x << std::endl;
> } BOOST_LOCAL_FUNCTION_NAME(f)
>
> boost::function< void ( ) > g(f);
>
> f();
> g();
>
> print "1" followed by "2" (my guess), or does it print "1" twice?  I may

... prints "1" followed by "1" because "x" is bind by value so "x"
becomes 2 only within an execution of the local function and not
across executions (i.e., x is not threated as a static local variable
within the local function). This prints "1" followed by "1" even is
you call f(); f(); instead of f(); g(); so it's not because of copying
f in g but it's because of the binding by value semantics (which are
the same semantics as of Boost.ScopeExit -- but scope exits are always
executed just one time).

This should be explained here:
http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Tutorial.html#boost_local.Tutorial.Binding
And if it's not clear I can explain it better...

> have missed it entirely, but I'd like the semantics of copying a Boost.Local
> functor explicitly spelled out.

Yes, I think I should explain this better maybe in:
http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html#boost_local.Advanced_Topics.assigning_local_functions

> P.S.:  I noticed in
>
> http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html#boost_local.Advanced_Topics.commas_and_symbols_in_macro_parameters
>
> a misspelling in the comments of the last example,
> s/BOOST_IDENTITY_VALE/BOOST_IDENTITY_VALUE/.

OK, I'll fix it.

Thanks,
--Lorenzo


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