Range syntax theory

Okay, maybe we think of it this way. '..' is a club. '...' is a club, with
a bouncer at the door.

Or, '..' is a path. '...' has a marble tripping up the last entry and
pushing it off the path.

Or, '..' represents a 2-dimensions (a vector). And '...' represents two
dimensions with a daemon kicking the last entry into its own exclusion
dimension (a plane) to live forever, planely in lonely solitude.

Or, maybe I should quit now...Drew

-> -----Original Message-----
-> From: Zach Dennis [mailto:zdennis@mktec.com]
-> Sent: Thursday, September 30, 2004 9:31 AM
-> To: ruby-talk@ruby-lang.org
-> Subject: Range syntax theory
->
->
-> I have been thinking lately about rangess and I will give
-> you the two
-> different range operators and what comes to mind first.
->
-> Operator One: .. (two dots)
-> Example: 1..5
-> What comes to mind: Exclusive
-> How It Works: Inclusive (the last number 5, is included)
->
-> Operator Two: ... (three dots)
-> Example: 1...5
-> What comes to mind: Inclusive
-> How It Works: Exclusive (the last number 5, is excluded)
->
-> How range operators work seems sort of backwards to me. It
-> would appear
-> as if the "..." (three dots) would be the inclusive one,
-> including the
-> last value and the ".." (two dots) would be exclusive and
-> exclude the
-> last value.
->
-> Am I off in my own little world here or have others pondered this?
-> (Perhaps it has been brought up before?) I am not requesting
-> a change on
-> this, I am merely pointing out what seems unnatural in a
-> very natural
-> language.
->
-> Zach
->

Mills Thomas (app1tam) wrote:

Okay, maybe we think of it this way. '..' is a club. '...' is a club, with
a bouncer at the door.

Or, '..' is a path. '...' has a marble tripping up the last entry and
pushing it off the path.

Or, '..' represents a 2-dimensions (a vector). And '...' represents two
dimensions with a daemon kicking the last entry into its own exclusion
dimension (a plane) to live forever, planely in lonely solitude.

Or, maybe I should quit now...Drew

This thinking imposes that the reasoning of the syntax should conform to the syntax. I would think that the syntax should conform to the reasoning.

Zach

This has been a very fun discussion. I'll shut up now unless anyone comes up with good reasoning for '..' and '...' or until Matz speaks. I think everyone knows where I stand.

Zach

Zach Dennis wrote:

This has been a very fun discussion. I'll shut up now unless anyone comes up with good reasoning for '..' and '...' or until Matz speaks. I think everyone knows where I stand.

Zach

Indeed. I was not really thinking this to the end.

  Thanks all!

Henrik

I can't think of any better reason than "inclusive ranges are the common
case, so make them simpler"

martin

···

Zach Dennis <zdennis@mktec.com> wrote:

This has been a very fun discussion. I'll shut up now unless anyone
comes up with good reasoning for '..' and '...' or until Matz speaks. I
think everyone knows where I stand.

Zach wrote:

This has been a very fun discussion. I'll shut up now unless anyone
comes up with good reasoning for '..' and '...' or until Matz speaks. I
think everyone knows where I stand.

I'll try to come up with a good reasoning. Pretend I'm designing a language.

x..y is known to programmers of some other languages as representing a
"range" (i.e. not necessarily what we'd call a Range, but something close
to the concept). I decide that this concept will have its own
representation as a Range object. So:

  2..6 # -> Range object

So far so good. And familiar to some, but by no means all, programmers of
other languages.

Now I decide, for the good reasons put forth by others, that end-exlusive
ranges are useful enough to be treated explicitly as well. I go hunting
for a way to represent them, and settle on

  2...6 # -> Range object

I find something visually appealing about it, don't agonise over it too
much, and there you go -- it's in the language.

Speaking as a Ruby programmer again, I personally find nothing whatsoever
confusing about the literal range notation, inclusive or exclusive. And I
dislike the thought of reversing the notations; not based on precedent and
not wanting to change things, but based an aesthetics. And trying to
explain why is like trying to explain appreciation for a poem.

Cheers,
Gavin

Gavin Sinclair wrote:

Zach wrote:

This has been a very fun discussion. I'll shut up now unless anyone
comes up with good reasoning for '..' and '...' or until Matz speaks. I
think everyone knows where I stand.
   
I'll try to come up with a good reasoning. Pretend I'm designing a language.

x..y is known to programmers of some other languages as representing a
"range" (i.e. not necessarily what we'd call a Range, but something close
to the concept). I decide that this concept will have its own
representation as a Range object. So:

2..6 # -> Range object

So far so good. And familiar to some, but by no means all, programmers of
other languages.

Yes I agree with you here. This is how languages have been developed it appears with the Range operator in mind. At this point the idea for an exclusive range operator has not came to mind yet. So why would you even consider '..' vs '...', at this point? You wouldn't.

Now I decide, for the good reasons put forth by others, that end-exlusive
ranges are useful enough to be treated explicitly as well. I go hunting
for a way to represent them, and settle on

2...6 # -> Range object

I find something visually appealing about it, don't agonise over it too
much, and there you go -- it's in the language.

If you design a language in the two steps you just provided then i agree with you. But having 20/20 hindsight what would have made more sense when designing an inclusive and an exclusive range operators? What seems more natural? Try to not include the reasoning "because that's how it is" or "because that's what most people know".

Speaking as a Ruby programmer again, I personally find nothing whatsoever
confusing about the literal range notation, inclusive or exclusive.

I agree with you here as well. As a ruby programmer you know how they work so there is no need to change them. Now envision that there is someone you are teaching Ruby, and at the same time you are teaching them how to program. What makes more sense when describing the .. and ... operators? Again, try not to include "because that's how it is" or "because that's what people know". Try to keep it natural and making sense.

And I
dislike the thought of reversing the notations; not based on precedent and
not wanting to change things, but based an aesthetics.

Where is the aesthetics in the reasoning for .. and ... ? I see no beauty. I see nothing that makes sense. I see something that is done a certain way because that is how it was done before. Does this make it the correct way to do things? Try to think about this from a scientific view point when designing a language. Noting ahead of time you want inclusive and exclusive range operators. Your goal for the language is simplicity, elegance and to make it seem natural for the programmer. What would you use to represent those operators and why? What logically makes sense? Share your reasoning. Try to do this without using the current implementation(s) in mind. Pretend you are designing your language from scratch, or that you are developing a version that doesn't need backwards compatibility. What is your conclusion and how did you achieve it?

If you can answer those and come to a conclusion that the current implementatoin makes the most sense for the elegance and natural feel for your language, then I would love to hear your reasoning. Perhaps you will convince me to change my view. As of yet, I haven't heard a reason.

And trying to
explain why is like trying to explain appreciation for a poem.

If this were an actual language debate you would have just lost. You didn't show any logical reasoning or rational conclusions to support your position. This is like Larry Wall saying that Perl is the best programming language syntacically because it is like a overly complex Haiku and it just cannot be explained because of it's aesthetics.

Zach

Zach wrote:

If you design a language in the two steps you just provided then i agree
with you. But having 20/20 hindsight what would have made more sense
when designing an inclusive and an exclusive range operators? What seems
more natural? Try to not include the reasoning "because that's how it
is" or "because that's what most people know".

To me, neither seems "more natural" once prior experience is removed.
It's quite arbitrary. If you think it's more natural a certain way,
then go ahead, but it's unlikely to convince me.

Speaking as a Ruby programmer again, I personally find nothing
whatsoever confusing about the literal range notation, inclusive or
exclusive.

I agree with you here as well. As a ruby programmer you know how they
work so there is no need to change them. Now envision that there is
someone you are teaching Ruby, and at the same time you are teaching
them how to program. What makes more sense when describing the .. and
... operators?

Again, neither. It's not been a problem when teaching people Ruby.
Those people were existing programmers of other languages, but I doubt
they were familiar with .. from anywhere.

I'll also point out, as I'm fond of doing, that you learn a language --
and of course, to learn programming at all -- you have to be willing to
actually *learn* a few things. I like to see it made as easy as
possible, but there are other considerations as well. This particular
piece of syntax took me no time at all to learn, and I'm not
extraordianarily brilliant, so I have no concern that it is confusing
for newbies. (I was one, once, and it wasn't confusing.)

Again, try not to include "because that's how it is" or
"because that's what people know". Try to keep it natural and making
sense.

And I
dislike the thought of reversing the notations; not based on precedent
and not wanting to change things, but based an aesthetics.

Where is the aesthetics in the reasoning for .. and ... ? I see no
beauty. I see nothing that makes sense.

Well I do. But that's probably because I take the attitude that it's
arbitrary, that it might as well be kept simple, and because that
notation looks better than any reasonable alternative I can think of.

I see something that is done a
certain way because that is how it was done before. Does this make it
the correct way to do things? Try to think about this from a scientific
view point when designing a language. Noting ahead of time you want
inclusive and exclusive range operators. Your goal for the language is
simplicity, elegance and to make it seem natural for the programmer.
What would you use to represent those operators and why? What logically
makes sense? Share your reasoning. Try to do this without using the
current implementation(s) in mind. Pretend you are designing your
language from scratch, or that you are developing a version that doesn't
need backwards compatibility. What is your conclusion and how did you
achieve it?

If inclusive and exclusive ranges were a significant goal of the
language, then my first thought would be this:

  [x,y]
  [x,y)
  (x,y]
  (x,y)

However, that's almost certainly going to clash with other goals of the
language, like representing arrays, etc. So it's time for plan B. Of
course, this language doesn't _rally_ need ranges as flexible as the
above representation allows, does it?

  # BTW, I'm not entirely happy with Ruby's ranges, I'll have you know.
  # They are only really useful for integers and perhaps some strings,
  # but they _try_ to be useful for anything, and kind of botch it.
  # Further, they take two otherwise aliases methods -- member? and
  # include? -- and make them mean something different. This is poor
  # form, IMO. They're trying to do too much.

So in my new language, I'd say "ranges are for integers only", and use
the .. and ... notations. Which one for inclusive and which one for
exclusive? To be honest, I don't care. Either one of them would make
sense once you're used to it. So, inclusive being the more common case,
perhaps I'd optimise it accordingly.

If you can answer those and come to a conclusion that the current
implementatoin makes the most sense for the elegance and natural feel
for your language, then I would love to hear your reasoning. Perhaps you
will convince me to change my view. As of yet, I haven't heard a
reason.

And trying to
explain why is like trying to explain appreciation for a poem.

If this were an actual language debate you would have just lost. You
didn't show any logical reasoning or rational conclusions to support
your position. This is like Larry Wall saying that Perl is the best
programming language syntacically because it is like a overly complex
Haiku and it just cannot be explained because of it's aesthetics.

I haven't seen any other attempts to portray logical reasoning towards
an unbiased conclusion, so I feel I'm in good company :slight_smile:

Cheers,
Gavin

I believe I remember in your first post you saying you weren't calling for a language restructuring, just seeing if someone could explain the reasoning to you. Obviously, that has changed, by the tone of your later messages.

You have now been given several possible explanations. You are "countering" them as they come in. And yet, I believe the majority has said that it doesn't seem to bother them and they would be against a change.

I'm really not trying to knock your crusade here. By all means, write up an RCR and we'll see how it goes. I just feel like you are getting the common opinion and are less and less interested in it.

James Edward Gray II

···

On Sep 30, 2004, at 9:17 PM, Zach Dennis wrote:

If this were an actual language debate you would have just lost. You didn't show any logical reasoning or rational conclusions to support your position. This is like Larry Wall saying that Perl is the best programming language syntacically because it is like a overly complex Haiku and it just cannot be explained because of it's aesthetics.

Interesting discussion

I will just add my little bit :slight_smile:

Gavin Sinclair wrote:

>
>
>
>
>I'll try to come up with a good reasoning. Pretend I'm designing a
>language.
>
>x..y is known to programmers of some other languages as representing a
>"range" (i.e. not necessarily what we'd call a Range, but something close
>to the concept). I decide that this concept will have its own
>representation as a Range object. So:
>
> 2..6 # -> Range object
>
>So far so good. And familiar to some, but by no means all, programmers of
>other languages.

It is also used that way in 'normal' or mathematical writing, mostly with
two but also with arbitrary number of dots.

>
>
>Now I decide, for the good reasons put forth by others, that end-exlusive
>ranges are useful enough to be treated explicitly as well. I go hunting
>for a way to represent them, and settle on

Or we need another range different from the 'normal'. Using just one
more dot makes it easy to type, using an operator that has the third
character different would be easier to remember. Actually I have to try
the ranges in irb when I am not using them for a while to make sure I
get the right one.
As I am familiar with the <2,6>, <2,6), (or '[' instead of '<')
mathematical notation I would use something that resembles that, the
round braces are easy to remember in that they 'avoid' the extreme
value. but 1[-]6 and 1[-)6 is quite hard to type and the braces would
be hard to parse as they are already used differently..

As the mathematical notation is used even in the last years of elementary
school around here I would consider it very widespread. But I have no
knowledge of the rest of the world.

My suggestion would be to use some cleverly English named functions for
clarity :slight_smile:

Thanks

Michal Suchanek

···

On Fri, Oct 01, 2004 at 11:17:11AM +0900, Zach Dennis wrote:

Hello! I'd like to help translate some of the Japanese documentation to
English, but am not sure where to begin. I found a list of pending
translations at <http://www.rubygarden.org/ruby?TranslationsInProgress>, but
the list is quite out of date. I've also searched ruby-talk and ruby-list, but
didn't immediately find any current information.

Does anybody have suggestions for getting started? I'd hate to duplicate the
work of other people.

Best,
Steve

···

_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

Well, while were at it here's mine:

  0..9 inclusive
  0..9.0 exclusive

And .. would be a method.

BTW: why can I say 'a=1,2' and get an array, but not 'a=(1,2)' ?

T.

···

On Friday 01 October 2004 02:36 am, Gavin Sinclair wrote:

So in my new language, I'd say "ranges are for integers only", and use
the .. and ... notations. Which one for inclusive and which one for
exclusive? To be honest, I don't care. Either one of them would make
sense once you're used to it. So, inclusive being the more common case,
perhaps I'd optimise it accordingly.

James Edward Gray II wrote:

If this were an actual language debate you would have just lost. You didn't show any logical reasoning or rational conclusions to support your position. This is like Larry Wall saying that Perl is the best programming language syntacically because it is like a overly complex Haiku and it just cannot be explained because of it's aesthetics.

I believe I remember in your first post you saying you weren't calling for a language restructuring, just seeing if someone could explain the reasoning to you. Obviously, that has changed, by the tone of your later messages.

Yes, I did say that. And I still don't want the near future versions of Ruby to change. I was expecting someone to point out some reasoning that I was unaware of for why .. and ... are like that. And there just haven't been reasons besides it already being like that.

You have now been given several possible explanations. You are "countering" them as they come in. And yet, I believe the majority has said that it doesn't seem to bother them and they would be against a change.

The several explanations you talk about are either a) revolving around the "it's already that way and we already know it" b) think of it this way descriptions (which just a way to train your brain) c) possible alternatives.

The syntax doesn't bother me personally, and as I've noted in previous posts that I am thinking abuot future programmers and raising the question, would this be more one step for Ruby to be more natural and make more sense for those future programmers.

I'm really not trying to knock your crusade here.

Any and all feedback/response is greatly appreciated James whether it's for or against me, or neither.

By all means, write up an RCR and we'll see how it goes. I just feel like you are getting the common opinion and are less and less interested in it.

The common opinion doesn't answer any of my original questions. I was not asking if people can live with the syntax. I was asking if others had ever thought it was sort of backwards and if they knew why it was done that way. Some people said, they have never thought of being backwards, and others have said yes it appeared backwards, but they just retrained their brain.

And this is just a fun discussion to have IMO. But it'll have to end today because I will gone for the next few days. :wink:

Thanks for your response and your honesty. I hate sarcasm and I appreciate it when people are frank with me.

Zach

···

On Sep 30, 2004, at 9:17 PM, Zach Dennis wrote:

  # BTW, I'm not entirely happy with Ruby's ranges, I'll have you know.
  # They are only really useful for integers and perhaps some strings,
  # but they _try_ to be useful for anything, and kind of botch it.
  # Further, they take two otherwise aliases methods -- member? and
  # include? -- and make them mean something different.

      This is simply untrue. Float ranges and Time ranges are both very
useful, especially if you extend them (which in a language like ruby you
can). The sort of operations you'll want on Intervals (Time ranges) are
slightly different than you'll want on Error_bars, Bounding_box_sides,
and other sorts of Float ranges anyway.
      If anything, I'd expand the range of ranges.

    -- Markus

Gavin Sinclair wrote:

I haven't seen any other attempts to portray logical reasoning towards
an unbiased conclusion, so I feel I'm in good company :slight_smile:

Yeah, no one has gave unbias'ed conclusions or reasoning. Oh well. It was good discussing with you though.

Zach

Not exactly documentation, but I think many people would be happy
to have a translation of

http://jp.rubyist.net/magazine/

···

On Fri, Oct 01, 2004 at 03:52:07PM +0900, Steve Brumbaugh wrote:

Hello! I'd like to help translate some of the Japanese documentation to
English, but am not sure where to begin. I found a list of pending
translations at <http://www.rubygarden.org/ruby?TranslationsInProgress&gt;, but
the list is quite out of date. I've also searched ruby-talk and ruby-list, but
didn't immediately find any current information.

Does anybody have suggestions for getting started? I'd hate to duplicate the
work of other people.

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

["trans. (T. Onoma)" <transami@runbox.com>, 2004-10-01 12.59 CEST]

BTW: why can I say 'a=1,2' and get an array, but not 'a=(1,2)' ?

I guess, for the same reason you can't say '1,2'.

$ ruby -e '1,2'
-e:1: syntax error

···

--

Steve Brumbaugh ha scritto:

Does anybody have suggestions for getting started? I'd hate to duplicate the
work of other people.

I think that translating the Ruby/Dl tutorial could be a cool thing:
http://ttsky.net/ruby/ruby-dl.html

And I second the suggestion from Pena,Botp .

For what relates to duplicated work, I guess contacting the original author would be the best thing, he may know if someone is already working on it. Oh, and advice ruby-talk/comp.lang.ruby :slight_smile:

So perhaps have someone work on some of the Japanese documentation, and
someone else work on RubiMa (the magazine)? Or a team of people, or whatnot?

-Jasmine

···

On Fri, Oct 01, 2004 at 03:52:07PM +0900, Steve Brumbaugh wrote:

Hello! I'd like to help translate some of the Japanese documentation
to English, but am not sure where to begin. I found a list of pending
translations at
<http://www.rubygarden.org/ruby?TranslationsInProgress&gt;, but the list
is quite out of date. I've also searched ruby-talk and ruby-list, but
didn't immediately find any current information.

Does anybody have suggestions for getting started? I'd hate to
duplicate the work of other people.

Not exactly documentation, but I think many people would be happy
to have a translation of

http://jp.rubyist.net/magazine/

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

--
"Life's not fair, but the root password helps."

.:.plum blossom dreaming .:.
   navi | mahou | ume

gabriele renzi <rff_rff@remove-yahoo.it> wrote in message news:<vvg7d.18192$H11.560869@twister1.libero.it>...

Steve Brumbaugh ha scritto:

> Does anybody have suggestions for getting started? I'd hate to duplicate the
> work of other people.
>

I think that translating the Ruby/Dl tutorial could be a cool thing:
http://ttsky.net/ruby/ruby-dl.html

I can translate(*) that (the tutorial part -- the document gets a bit
bitty after that) if you want... I need something to do with my hands.

(*) For approximate values of 'translate'.

Benjamin