Boost logo

Boost :

Subject: Re: [boost] De Bruijn Bind (alternate bind syntax) Interest?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-09-07 15:42:55


On 09/07/10 10:41, David Sankel wrote:
> On Sun, Sep 5, 2010 at 7:56 PM, Larry Evans <cppljevans_at_[hidden]>wrote:
[snip]
>> However, compiling my first try( the attached) gives:
[snip]
>> What am I doing wrong?
>>
>
> int result = app( next, 1 );
>
> With the reference implementation, app should always be used within a lam.
> In this case you don't need a lam:
>
> int result = next( 1 ).
>
> But if you really wanted to make a nullary function (note the extra '()' at
> the end):
>
> int result = lam<0>( app( next, 1 ) )();
>
> Looking at the subsequent expression:
>
> int result = app(lam_app,1);
>
> Again we can apply the function directly here:
>
> int result = lam_app(1);
>
> Does that help?

I tried `lam_app(1)` in the following main:

[CODE "apply_apply.cpp"]
int main()
{
    auto op = lam<1>( app(next,_1_1 ) );
    int op_1 = op(1);
    auto lam_app = lam<1>( app(op,_1_1) );
    int lam_app_1 =
      #if 1
        lam_app(1);
      #else
        2;
      #endif
    return op_1 + lam_app_1;
}
[/CODE "apply_apply.cpp"]

However, this resulted in:

[COMPILE_ERRORS "apply_apply.cpp"]
/home/evansl/download/gcc/4.5.1-release/install/bin/g++ -I../include
-I/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0 -std=gnu++0x
./apply_apply.cpp -o ../bin/apply_apply.exe
In file included from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:41:0,
                 from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/adapter/fused.hpp:16,
                 from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/include/fused.hpp:10,
                 from ../include/DeBruijnBind.hpp:24,
                 from ./apply_apply.cpp:8:
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/utility/result_of.hpp:
In instantiation of 'boost::detail::result_of_nested_result<Abs<1,
App<int (*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >, Abs<1, App<int (*)(int),
boost::fusion::transform_view<const boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >(int&)>':
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/utility/result_of.hpp:87:1:
  instantiated from 'boost::detail::tr1_result_of_impl<Abs<1, App<int
(*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >, Abs<1, App<int (*)(int),
boost::fusion::transform_view<const boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >(int&), false>'
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/utility/detail/result_of_iterate.hpp:33:65:
  instantiated from 'boost::tr1_result_of<Abs<1, App<int (*)(int),
boost::fusion::transform_view<const boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >(int&)>'
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/utility/detail/result_of_iterate.hpp:81:46:
  instantiated from 'boost::result_of<Abs<1, App<int (*)(int),
boost::fusion::transform_view<const boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >(int&)>'
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:199:60:
  instantiated from 'boost::fusion::detail::invoke_impl<Abs<1, App<int
(*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >, boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<1>, boost::fusion::vector1<int>
> >, boost::fusion::void_>, 1, false, true>'
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:159:30:
  instantiated from 'boost::fusion::result_of::invoke<Abs<1, App<int
(*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >&, boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<1>, boost::fusion::vector1<int>
> >, boost::fusion::void_> >'
./apply_apply.cpp:65:18: instantiated from here
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/utility/result_of.hpp:80:1:
error: no class template named 'result' in 'struct Abs<1, App<int
(*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >'
In file included from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/preprocessor/iteration/detail/iter/forward1.hpp:52:0,
                 from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:93,
                 from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/adapter/fused.hpp:16,
                 from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/include/fused.hpp:10,
                 from ../include/DeBruijnBind.hpp:24,
                 from ./apply_apply.cpp:8:
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:
In instantiation of 'boost::fusion::detail::invoke_impl<Abs<1, App<int
(*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >, boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<1>, boost::fusion::vector1<int>
> >, boost::fusion::void_>, 1, false, true>':
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:159:30:
  instantiated from 'boost::fusion::result_of::invoke<Abs<1, App<int
(*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >&, boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<1>, boost::fusion::vector1<int>
> >, boost::fusion::void_> >'
./apply_apply.cpp:65:18: instantiated from here
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:199:60:
error: no type named 'type' in 'struct boost::result_of<Abs<1, App<int
(*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >(int&)>'
In file included from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/invocation/invoke.hpp:41:0,
                 from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/functional/adapter/fused.hpp:16,
                 from
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/fusion/include/fused.hpp:10,
                 from ../include/DeBruijnBind.hpp:24,
                 from ./apply_apply.cpp:8:
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/utility/result_of.hpp:
In instantiation of 'boost::detail::result_of_nested_result<const Abs<1,
App<int (*)(int), boost::fusion::transform_view<const
boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >, const Abs<1, App<int (*)(int),
boost::fusion::transform_view<const boost::fusion::vector1<arg<1, 1> >,
CReduce1<boost::fusion::pair<mpl_::int_<2>, boost::fusion::vector1<int>
> >, boost::fusion::void_> > >(int&)>':
/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0/boost/utility/result_of.hpp:87:1:
  instantiated from 'boost::detail
...
[/COMPILE_ERRORS "apply_apply.cpp"]

and the errors go on for about 40 more lines.

Any ideas?

TIA.

-Larry


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