[jbrown105 at jbrown.mylinuxbox.org: Re: error?]

new topic     » topic index » view thread      » older message » newer message

----- Forwarded message from "Jim C. Brown" <jbrown105 at jbrown.mylinuxbox.org>
-----

From: "Jim C. Brown" <jbrown105 at jbrown.mylinuxbox.org>
Subject: Re: error?

On  0, Kat <kat at kogeijin.com> wrote:
> 
> On 25 Oct 2002, at 23:32, jbrown105 at speedymail.org wrote:
> 
> > 
> > On  0, Kat <kat at kogeijin.com> wrote:
> > > 
> > > Ok, if 
> > > decimalcount = 1
> > > (the debug screen says it is 1)
> > > then shouldn't this line crash?:
> > > 
> > >    resultnum = resultnum[1..decimalcount-1] & "." & 
> > > resultnum[decimalcount..length(resultnum)]
> > > 
> > > since it is the same as:
> > > resultnum[1..0] 
> > > ?
> > > 
> > > Kat
> > > 
> > 
> > No.
> > 
> > resultnum[1..0] is the empty sequence {}
> 
> I can't help but consider that non-standard to Eu's way. It's one atom long,
> it
> should be one atom returned. Or since Rob doesn't want to return reversed 
> sequences if we do 
> 
> s = s[length(s)..1]
> 
> then s[1..0] should crash as a reversed sequence of as a "upper index is 
> less than 1" error. Reliable crashing is as important as reliable
> non-crashing,
> isn't it?
> 
> Kat
> 

You make a very good point.

Actually, s[1..1] is one atom long, as s[1..2] is 2 atoms, s[1..3] is 3,
and so on. If you go backwards, s[1..0] is zero atoms, then s[1..-1] and
so on are negative lengths - which arent allowed and cause crashes.

However this is just Rob's style, other langauges (such as Python, for example)
handle slicing differently.

It all depends on which style you prefer, personally I like Eu's way (other
than the fact there are no reverse indexes) but thats just because Eu was my
first major programming language, so I grew to thing that way when I do
slicing.

jbrown


----- End forwarded message -----

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu