Boost logo

Boost Users :

Subject: [Boost-users] [Proto] lambda functions with named variables
From: Hossein Haeri (powerprogman_at_[hidden])
Date: 2010-11-01 09:39:23


Dear all,

I am thinking of having creatures like

lam(x)(x + 2)

in my code which would be the Haskell equivalent for

\x -> x + 2.

In fact, I am working in an untyped world (with very limited functionality) and my typical lambda expressions would only include (function) applications, (lambda) abstractions, and let-bindings. It is exactly for the existence of let-bindings that I guess I can't resort to placeholders like:

template<int> placeholder;

const terminal<placeholder<0> >::type _1 = {{}};
const terminal<placeholder<1> >::type _2 = {{}};
const terminal<placeholder<2> >::type _3 = {{}};
...

The point is that I need to store what each variable is bound to. And, AFAIK, I can't store such information in std::map<> for _1 has a different type than _2 for example.

So, the two hopes that I have in Proto for solving this problem are:

1) To provide a type T instances of which can act like untyped variables in accepting values of different C++ types. T should also be storable in a map-like container.

Boost.Any comes to mind for the first requirement but the problem is that there is no meaningful operator < or operator == to use map or unordered_map for boost::any objects. Note that a1 != a2 needs to the case only when a1 and a2 are distinct variables.

Can proto::_ be of any help here?

2) To provide a map-like container in which I can store things like boost::any objects. OK, maybe this is not for Proto to address but though it might still have something to offer...

TIA,
--Hossein


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net