|
Boost : |
From: John Max Skaller (skaller_at_[hidden])
Date: 2001-06-20 16:53:33
Gary Powell wrote:
>
> Hi,
>
> [John Max Skaller]
> Felix is new programming language designed for C++ programmers.
> It generates C++, and has a lot of features you've always wanted. :-)
>
> [Gary]
> I noticed that Felix has "tuples", if boost::tuple was zero based, and had
> pointer to member access, would you use it in the Felix "compiler"?
I don't think I could use it for the native tuple
type, it's too closely integrated into the compiler.
For example, I need to create a list of offsets to any
pointers so the garbage collector will work: the technology
uses
offsetof(S,mem)
However, I could certainly build a binding.
Felix is designed for genericity, but it isn't implemented,
so I'll illustrate with tuple<int, float>:
header """
#include <boost/tuples>
using namespace boost::tuples;
"""
#include <std.flx> // for int, float, etc
type tuple_i_f = "tuple<int,float>";
fun get_first : tuple_i_f -> int = "get<1>($1)";
fun get_second : tuple_i_f -> float = "get<2>($1)";
fun mktuple : int * float -> tuple_i_f = "mk_tuple($1,$2)";
val t = mktuple(1,2.0);
val x = t.first;
val y = t.second;
Note that 't.first' expands to 'get_first(t)'.
> I'm just looking for a justification for doing this work.
IMHO: Don't change anything unless you're
totally convinced.
By the way, the way tuples are implemented
using a recursive type is very clever. It has got
me thinking about a more general solution for C++,
and also Felix.
What C++ extensions are needed to get
rid of the 'nil' things, and make the templates
work for _arbitrary_ length?
The answer is strange: we need list operations
at the template level. I don't know exactly what form.
-- John (Max) Skaller, mailto:skaller_at_[hidden] 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk