Boost logo

Boost Users :

Subject: Re: [Boost-users] [Tuple] What's the point?
From: Joel de Guzman (joel_at_[hidden])
Date: 2009-07-10 20:06:37


Zachary Turner wrote:
> On Fri, Jul 10, 2009 at 11:26 AM, Joel de
> Guzman<joel_at_[hidden]> wrote:
>> Zachary Turner wrote:
>>> This may cause some disagreements but I'm honestly not sure that I
>>> agree with the idea that tuples should behave like sequences. Most
>>> other languages that enable functional programming style explicitly
>>> disallow this, and for good reason.
>> Really? "explicitly"? Can you provide an example of a language
>> that explicitly states this and the reasons why?

> I didn't say they explicitly wrote in the standard "tuples cannot be
> treated as sequences by design", I said that it was a conscious design
> decision not to allow tuples to be treated as sequences.

Woa! Whose conscious decision? which language? Unless you can
provide some basis/references, this is all nonsense.

> Lisp is the
> exception which I forgot about, if there are other widely used
> functional languages that allow one to treat tuples as sequences that
> I'm not aware of then I'd be interested to know what they are.

Are you talking about FP only? I can name a lot of languages
with heterogeneous sequences. All dynamically typed languages
like Lisp inherently have hetero-sequences. C++ and Fusion is
unique in that we can have statically typed heterogeneous
sequences.

> For starters, the word "sequence" implies (in the mathematical sense)
> that there is a possibility of the length being unbounded.

Sure. Sequences can be finite and infinite.

> While one
> could argue that it's possible to design a tuple class that could hold
> a number of elements bounded only by the amount of memory in one's
> computer (which for all intents and purpose we can consider an
> infinite tuple), a programmer can only define a finite number of
> types, so there must exist at least one type in the tuple that has
> values occuring an infinite number of times.

Wrong. Composition of a finite set of types can lead to a
virtually(*) infinite number of *unique* types. Of course the
limit now is the compiler. Seems you haven't done any
expression templates yet?

(*the number of permutations is very very large)

> So this begs the
> question of why not change the design of the application, and group
> similar types together. After all, if you've actually _specified_ an

Sure, why not? There's no-one preventing you from doing that
in that particular case. But you forget that in many cases the
position in the sequence is important. Seems you haven't done any
expression templates alright. It's a very good use-case and exemplifies
why we need heterogeneous sequences.

> infinite number of values of said types to put into said tuple, then
> there is necessarily a relation between the values, or a formula if
> you will allowing one to generate them.

Fusion deals mostly with finite sequences. Infinite sequences are
limited to specialized views such as repetitive_view. Anyway, your
promise is flawed so I'll stop here. It seems you are against the
whole concept of MPL and Fusion purely on pedantic reasons, and even
so, without sufficient basis. Sorry, but I don't have time to engage
in such a debate. So, unless you have a stronger basis for your
claims in the form of real code/examples/use-cases, I'll leave it
as it is.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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