You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <ga...@gmail.com> on 2011/05/18 18:32:46 UTC

[LANG] Is a Range a kind of Pair?

Why doesn't a Range does extend Pair? It's pretty clear (to me at least)
that a range is a pair of values.

Because the Pair is in our tuple package, it means that it should follow
tuple logic and be thought of as an ordered list of elements, in this case
two elements.

The methods that Range has that are not in Pair could be moved there.

-- 
Thank you,
Gary

http://garygregory.wordpress.com/
http://garygregory.com/
http://people.apache.org/~ggregory/
http://twitter.com/GaryGregory

Re: [LANG] Is a Range a kind of Pair?

Posted by Paul Benedict <pb...@apache.org>.
Is it wrong to assume that a Range is always a 2-dimensional set? Can
ranges ever be Nth dimensional?

On Thu, May 19, 2011 at 8:41 AM, Gary Gregory <ga...@gmail.com> wrote:
> On Wed, May 18, 2011 at 1:03 PM, Matthew Pocock <
> turingatemyhamster@gmail.com> wrote:
>
>> Range is not a sub-type of pair. You can think of a pair as being an
>> ordered
>> set of 2 items. A Range is a contiguous set defined by a lower and upper
>> bound (which may or may not be inclusive). Given some flag
>> Clusive=Inclusive|Exclusive, then every range is uniquely identified by a
>> single Pair<Pair<Clusive, numeric>>. The in-memory representation of the
>> data defining a pair and a range may be the same, but they are not at all
>> the same kind of thing.
>>
>
> I understand the semantic difference, but to me the representation is the
> same, unless you get in the Iterable game (see below.) But it does now feel
> -- with your clear explanation, thank you -- that they are different beasts.
>
> The Inclusive|Exclusive part is not in the code so that does not feel like a
> fair argument to support the difference though.
>
> If "a Range is a contiguous set" (a "list" since a set is not ordered), then
> it would make sense to support Iterable so you can use it in a for-each
> loop, this can be post 3.0 (the remove method in Iterator might be an
> issue.)
>
> Gary
>
>
>>
>> Matthew
>>
>> On 18 May 2011 17:46, Matt Benson <gu...@gmail.com> wrote:
>>
>> > On Wed, May 18, 2011 at 11:32 AM, Gary Gregory <ga...@gmail.com>
>> > wrote:
>> > > Why doesn't a Range does extend Pair? It's pretty clear (to me at
>> least)
>> > > that a range is a pair of values.
>> > >
>> > > Because the Pair is in our tuple package, it means that it should
>> follow
>> > > tuple logic and be thought of as an ordered list of elements, in this
>> > case
>> > > two elements.
>> > >
>> > > The methods that Range has that are not in Pair could be moved there.
>> > >
>> >
>> > IMHO a Range is not precisely a Pair, though it could define its
>> > _limits_ in those terms.
>> >
>> > Matt
>> >
>> > > --
>> > > Thank you,
>> > > Gary
>> > >
>> > > http://garygregory.wordpress.com/
>> > > http://garygregory.com/
>> > > http://people.apache.org/~ggregory/
>> > > http://twitter.com/GaryGregory
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> > For additional commands, e-mail: dev-help@commons.apache.org
>> >
>> >
>>
>>
>> --
>> Matthew Pocock
>> mailto: turingatemyhamster@gmail.com
>> gchat: turingatemyhamster@gmail.com
>> msn: matthew_pocock@yahoo.co.uk
>> irc.freenode.net: drdozer
>> (0191) 2566550
>>
>
>
>
> --
> Thank you,
> Gary
>
> http://garygregory.wordpress.com/
> http://garygregory.com/
> http://people.apache.org/~ggregory/
> http://twitter.com/GaryGregory
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [LANG] Is a Range a kind of Pair?

Posted by Gary Gregory <ga...@gmail.com>.
On Wed, May 18, 2011 at 1:03 PM, Matthew Pocock <
turingatemyhamster@gmail.com> wrote:

> Range is not a sub-type of pair. You can think of a pair as being an
> ordered
> set of 2 items. A Range is a contiguous set defined by a lower and upper
> bound (which may or may not be inclusive). Given some flag
> Clusive=Inclusive|Exclusive, then every range is uniquely identified by a
> single Pair<Pair<Clusive, numeric>>. The in-memory representation of the
> data defining a pair and a range may be the same, but they are not at all
> the same kind of thing.
>

I understand the semantic difference, but to me the representation is the
same, unless you get in the Iterable game (see below.) But it does now feel
-- with your clear explanation, thank you -- that they are different beasts.

The Inclusive|Exclusive part is not in the code so that does not feel like a
fair argument to support the difference though.

If "a Range is a contiguous set" (a "list" since a set is not ordered), then
it would make sense to support Iterable so you can use it in a for-each
loop, this can be post 3.0 (the remove method in Iterator might be an
issue.)

Gary


>
> Matthew
>
> On 18 May 2011 17:46, Matt Benson <gu...@gmail.com> wrote:
>
> > On Wed, May 18, 2011 at 11:32 AM, Gary Gregory <ga...@gmail.com>
> > wrote:
> > > Why doesn't a Range does extend Pair? It's pretty clear (to me at
> least)
> > > that a range is a pair of values.
> > >
> > > Because the Pair is in our tuple package, it means that it should
> follow
> > > tuple logic and be thought of as an ordered list of elements, in this
> > case
> > > two elements.
> > >
> > > The methods that Range has that are not in Pair could be moved there.
> > >
> >
> > IMHO a Range is not precisely a Pair, though it could define its
> > _limits_ in those terms.
> >
> > Matt
> >
> > > --
> > > Thank you,
> > > Gary
> > >
> > > http://garygregory.wordpress.com/
> > > http://garygregory.com/
> > > http://people.apache.org/~ggregory/
> > > http://twitter.com/GaryGregory
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
>
> --
> Matthew Pocock
> mailto: turingatemyhamster@gmail.com
> gchat: turingatemyhamster@gmail.com
> msn: matthew_pocock@yahoo.co.uk
> irc.freenode.net: drdozer
> (0191) 2566550
>



-- 
Thank you,
Gary

http://garygregory.wordpress.com/
http://garygregory.com/
http://people.apache.org/~ggregory/
http://twitter.com/GaryGregory

Re: [LANG] Is a Range a kind of Pair?

Posted by Matthew Pocock <tu...@gmail.com>.
Range is not a sub-type of pair. You can think of a pair as being an ordered
set of 2 items. A Range is a contiguous set defined by a lower and upper
bound (which may or may not be inclusive). Given some flag
Clusive=Inclusive|Exclusive, then every range is uniquely identified by a
single Pair<Pair<Clusive, numeric>>. The in-memory representation of the
data defining a pair and a range may be the same, but they are not at all
the same kind of thing.

Matthew

On 18 May 2011 17:46, Matt Benson <gu...@gmail.com> wrote:

> On Wed, May 18, 2011 at 11:32 AM, Gary Gregory <ga...@gmail.com>
> wrote:
> > Why doesn't a Range does extend Pair? It's pretty clear (to me at least)
> > that a range is a pair of values.
> >
> > Because the Pair is in our tuple package, it means that it should follow
> > tuple logic and be thought of as an ordered list of elements, in this
> case
> > two elements.
> >
> > The methods that Range has that are not in Pair could be moved there.
> >
>
> IMHO a Range is not precisely a Pair, though it could define its
> _limits_ in those terms.
>
> Matt
>
> > --
> > Thank you,
> > Gary
> >
> > http://garygregory.wordpress.com/
> > http://garygregory.com/
> > http://people.apache.org/~ggregory/
> > http://twitter.com/GaryGregory
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
Matthew Pocock
mailto: turingatemyhamster@gmail.com
gchat: turingatemyhamster@gmail.com
msn: matthew_pocock@yahoo.co.uk
irc.freenode.net: drdozer
(0191) 2566550

Re: [LANG] Is a Range a kind of Pair?

Posted by Henri Yandell <fl...@gmail.com>.
On Wed, May 18, 2011 at 9:54 AM, Stephen Colebourne
<sc...@joda.org> wrote:
> On 18 May 2011 17:46, Matt Benson <gu...@gmail.com> wrote:
>> On Wed, May 18, 2011 at 11:32 AM, Gary Gregory <ga...@gmail.com> wrote:
>>> Why doesn't a Range does extend Pair? It's pretty clear (to me at least)
>>> that a range is a pair of values.
>>>
>>> Because the Pair is in our tuple package, it means that it should follow
>>> tuple logic and be thought of as an ordered list of elements, in this case
>>> two elements.
>>>
>>> The methods that Range has that are not in Pair could be moved there.
>>>
>>
>> IMHO a Range is not precisely a Pair, though it could define its
>> _limits_ in those terms.
>
> The combined opinion of all at OpenGamma ($dayjob) is that a Range is
> a very different beast to a Pair. Simply because there are two data
> points, does not make it a pair :-)

+1. Good sentiment from your colleagues.

Hen

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [LANG] Is a Range a kind of Pair?

Posted by Stephen Colebourne <sc...@joda.org>.
On 18 May 2011 17:46, Matt Benson <gu...@gmail.com> wrote:
> On Wed, May 18, 2011 at 11:32 AM, Gary Gregory <ga...@gmail.com> wrote:
>> Why doesn't a Range does extend Pair? It's pretty clear (to me at least)
>> that a range is a pair of values.
>>
>> Because the Pair is in our tuple package, it means that it should follow
>> tuple logic and be thought of as an ordered list of elements, in this case
>> two elements.
>>
>> The methods that Range has that are not in Pair could be moved there.
>>
>
> IMHO a Range is not precisely a Pair, though it could define its
> _limits_ in those terms.

The combined opinion of all at OpenGamma ($dayjob) is that a Range is
a very different beast to a Pair. Simply because there are two data
points, does not make it a pair :-)

Stephen

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [LANG] Is a Range a kind of Pair?

Posted by Matt Benson <gu...@gmail.com>.
On Wed, May 18, 2011 at 11:32 AM, Gary Gregory <ga...@gmail.com> wrote:
> Why doesn't a Range does extend Pair? It's pretty clear (to me at least)
> that a range is a pair of values.
>
> Because the Pair is in our tuple package, it means that it should follow
> tuple logic and be thought of as an ordered list of elements, in this case
> two elements.
>
> The methods that Range has that are not in Pair could be moved there.
>

IMHO a Range is not precisely a Pair, though it could define its
_limits_ in those terms.

Matt

> --
> Thank you,
> Gary
>
> http://garygregory.wordpress.com/
> http://garygregory.com/
> http://people.apache.org/~ggregory/
> http://twitter.com/GaryGregory
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org