
On Sun, Sep 5, 2010 at 7:56 PM, Larry Evans <cppljevans@suddenlink.net>wrote:
On 09/04/10 13:54, David Sankel wrote:
On Sat, Sep 4, 2010 at 10:55 AM, Larry Evans <cppljevans@suddenlink.net wrote:
On 09/04/10 08:24, Larry Evans wrote: [snip]
The attached illustrates the difficulty I was having with mpl::apply. Maybe the apply_apply typedef would be a good use-case for De Bruijn's method. [snip] Attached is much simplified code that still illustrates problem. Compile errors included:
Thanks for the example. If a De Bruijn indices were used, this would look like
typedef< app< lam< app< op, _1_1 > > , int_<1> > >::type apply_apply;
Typo:
typedef<
I think this is a valid example of the needlessly cryptic bind/lambda semantics that are widespread.
I tried translating the above code back to the, let's call at the type 'universe' as opposed to the value 'universe'. I'm using universe because that's a term used by nuprl:
http://www.cs.cornell.edu/Info/People/sfa/Nuprl/NuprlPrimitives/Xuniverse_do...
to describe hierarchy of types and also because the only other name I could think of was domain, and that's used by proto and for other reasons. Another candidate was 'kind':
http://www.haskell.org/haskellwiki/Kind
but I thought of 'universe' first and it seemed more general.
However, compiling my first try( the attached) gives: [COMPILATION]
make -f my-make.mk /home/evansl/download/gcc/4.5.1-release/install/bin/g++ -Iinclude -I/home/evansl/prog_dev/boost-svn/ro/boost_1_44_0 -std=gnu++0x src/apply_apply.cpp src/test.cpp -o bin/apply_apply.exe src/apply_apply.cpp: In function 'int main()': src/apply_apply.cpp:63:28: error: cannot convert 'App<int (*)(int), boost::fusion::vector1<int> >' to 'int' in initialization make: *** [bin/apply_apply.exe] Error 1 [/COMPILATION]
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? -David -- David Sankel Sankel Software www.sankelsoftware.com 585 617 4748 (Office)