• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

Andreas
16-Nov-2012
[3814]
No.
BrianH
16-Nov-2012
[3815]
Nope, they do the whole range, just 0-based.
Arnold
16-Nov-2012
[3816]
Oh
BrianH
16-Nov-2012
[3817]
If we are going to have a 0 hole, make it an error, not return none. 
A quiet error is worse than a loud one.
Arnold
16-Nov-2012
[3818]
quiet errors are the worst.
DocKimbel
16-Nov-2012
[3819]
Jerry: I don't have enough time for that, I am counting on the doc-strings 
and extraction tool to generate such documentation automatically. 
Peter is working on such tool.
Kaj
16-Nov-2012
[3820x2]
I think that what we are seeing here is the frontier between academic 
and practical design choices. I am all for following academic principles 
as long as they are not 

too" detrimental to practical usage. I would draw the line at the 
point where most users would get lost. I believe that this is a dangerous 
pitfall in language design if you aim at a widespread use."
My feelings exactly
BrianH
16-Nov-2012
[3822]
It's more of a "which is more useful" versus "which is less confusing 
for newbies". Best to find a balance.
kensingleton
16-Nov-2012
[3823]
As someone who is at say level 5 on the btiffin rebol scale what 
I am about to suggest may be stupid - if so be gentle :) Could we 
not create a different structure other than a series (an array or 
a matrix etc) that is 0 based and index driven and works like in 
most other languages for those who need that kind of usage?  Or could 
we introduce for series an index manipulation system such as this:s1/index: 
4, add s3/index 2, subtract s2/index 2, inc s3/index, dec s2/index, 
++ s1/index, s1/index: s1/index + off etc.
Oldes
16-Nov-2012
[3824]
No, because at least for me, this is very common usage (just with 
different names):
>> b: [index 2 foo 3]
== [index 2 foo 3]
>> b/index
== 2
Kaj
16-Nov-2012
[3825x2]
On a lighter note, Red seems to have something to do with basketball:
https://twitter.com/dreahenson/status/269031419706228736
Ladislav
16-Nov-2012
[3827x2]
Ladislav, REBOL doesn't have a naming convention that handles 0-based 
addressing.

 - actually, REBOL does have a couple of general naming conventions, 
 which, therefore, apply th the 0-based indexing as well
Negative indices being back from the tail of the series: please, 
no, never.

 - yes, this needs some analysis to find out what may be wrong about 
 that idea. The starting point may be that the series tail is "ephemeral" 
 in a sense as I noted, while the head is not ephemeral at all.
DocKimbel
16-Nov-2012
[3829x2]
Indeed, any modification of a series changing its length, in the 
middle of a loop over a "reversed" view of that series, would most 
probably provoke errors.
Kaj: it seems to be restricted to basketball players with funny mustaches 
only. ;-)
Kaj
16-Nov-2012
[3831]
:-)
Ladislav
16-Nov-2012
[3832]
Andreas wrote:

...disallow 0, have 1 return the next element forward, -1 the next 
element backward (R2)

 - I am sorry, but in my opinion this is actually not possible. Once 
 we disallow 0 (can be done) we have absolutely no right to use -1
Kaj
16-Nov-2012
[3833]
Says who?
Ladislav
16-Nov-2012
[3834]
Whoever.1 is not preceded by -1 anyway.
Kaj
16-Nov-2012
[3835x2]
It's just a dialect for going in the opposite direction
And if you implement an index! type, you can make 1 be preceded by 
-1
BrianH
16-Nov-2012
[3837x6]
I don't buy the "no right" argument. Romans had subtraction without 
0. It was a bad idea, but it was possible.
Ladislav, we don't need analysis on negative indices being back from 
the tail of the series. The concept only makes sense if you are only 
able to refer to a series from its head, thus negative indexes don't 
really have a meaning if you see the series as linear, so you decide 
to give negative indexes a meaning by looking at the series as a 
loop where the end wraps around to the beginning and vice-versa. 
If you are able to refer to a series frome a base position of somewhere 
other than at its head then you already have a meaning for negative 
indexes, and don't need to make up another.
frome -> from
We can do Roman indexes if need be. It's really bad for math, so 
we would need PICKZ and POKEZ if we want to do computed offsets (SKIP 
can have side effects with ports in cases where PICK/POKE don't necessarily 
have, but regardless it has overhead). Maybe Roman PICK/POKE will 
be easier for newbies to learn, though they may curse it later once 
they have to do anything hard. (Note: Roman in mathematical difficulty, 
not notation.)
Note that with R3-style bounds checking, the none value is considered 
to be roughly the same as a hole in the data. PICK past either end 
returns none. That means that PICK 0 returning none is basically 
a statement that there is a hole in the middle of the series that 
is just before the current position, and moves along as the series 
position moves along. Now, try to come up with a way to explain to 
newbies that this phantom hole in a series makes sense, or is a good 
idea.
At least triggering an error is easier to explain, it means that 
0 doesn't exist, like we're programming in Roman. It's (slightly) 
better than the 0 index existing but referring to a hole in the series 
(R2-style behavior).
Oldes
17-Nov-2012
[3843x4]
Regarding returning none values against error... note this:
>> b: []
== []
in R2:
>> first b
** Script Error: Out of range or past end
** Near: first b
in R3:
>> first b
== none
Returning null in such a case is natural in other languages as well.
In zero-based REBOL it would not be possible to write:
for i 1 length? b 1 [print i]
but instead:
for i 0 (-1 + length? b) 1 [print i]
On the other side, here is quite nicely explained, why zero-based 
is better http://programmers.stackexchange.com/questions/110804/why-are-zero-based-arrays-the-norm
Pekr
17-Nov-2012
[3847x8]
Oldes - don't care - zero does not exist :-)
why 1 would be a better starting index than zero? Why not 2, or 10? 
The answer itself is interesting because it shows a lot about the 
though process of the people defending the idea.

 - what an flawed argument - the guy completly missess language as 
 REBOL imo, where we have first, second, etc. And first simply returns 
 first real thing. What is zeroth thing?
Well, really difficult to settle, any way you think abou the topic. 
I can think about 0 as about in-between, non real value - like Max 
mentioned vectors, simply first element in series to the left, or 
to the right. Then I can think about 0 as about real value - if I 
look outside, there is -1C temperature. And in order to get to 1C 
temperature, 2 grades are needed, hence 0 is real value here. And 
finally - if I will have some real series in front of me, e.g. 10 
ppl, I can pick first, second, first to the right, first to the left 
(-1), hence no zero or negative index here ...
I will leave it for the more clever to decide :-)
I am not sure REBOL introduced the easy model - it is mixture of 
those real existing values, and virtual elements:

blk: [a b c]
index? head blk == 1
index? tail blk == 4


I can imagine tail simply pointing to the last element, as well as 
head pointng to the "zeroth" element. But then, if we would not think 
about "in-between" positions, how would insert behave? If I would 
once agin think about the real example with e.g. 3 ppl standing in 
the line, and I say - go, and insert yourself to the last position 
- does it mean new person is going to be third, and shifts the last 
one to the fourth position, or does it mean the person just adds 
himself/herself to the fourth position?
prof.dr. Edsger W. Dijkstra - why numbering should start at 0 - http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
In the short article, there's also some experience with early programming 
languages ...
btw - will Red have range! datatype? And would it influence the way 
we look into series, positioning, indices, etc?
Arnold
17-Nov-2012
[3855]
Completely agreed 0 does not exist, even not for computers. A computer 
with 0 memory does not have memory at address 0 either :)

Counting starting at 0 is nonsense. No matter who and how many times 
it is explained. In human/fysic world we only put letter 1 in envelope 
1, letter 2 in envelope 2 etcetera, there is no letter 0 to put into 
envelope 0. It is only a confusing trick to start at 0. (I know you 
can look at memory like a binary tree) In these days of plenty of 
memory, I say let location 0 unused. Besides for who was REBOL meant 
initially? People. Scientists not computerscientists. Let those struggle 
with C and the likes. 1-base is one of the big plusses REBOL has 
over the majority of other languages. (enough bikeshedding from me 
today)
Pekr
17-Nov-2012
[3856]
Yet those ppl use arguments, like even in Bibble, there was zeroth 
day (well, in physics, that might mean the singularity point, where 
our physic laws don't apply), or, that without 0 you are not able 
to count BC to nowadays difference properly. Whoever came with that 
BC AD distinction, was not sane at the first place, and I really 
doubt, that back at those times, they agreed that their age is some 
-2300 years, knowing the point 0 (Christ) ahead :-)
Andreas
17-Nov-2012
[3857]
Please move the discussion whether "0 exists" elsewhere. REBOL's 
integer! corresponds to integers and includes 0. Unless you want 
to change that as well, that's a fact we have to live with.
DocKimbel
17-Nov-2012
[3858]
Default base index in programming languages: 

http://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28array%29#Array%5Fsystem%5Fcross-reference%5Flist


Notable languages with 1-based indexing: FORTRAN, Lua, Mathematica, 
MATLAB, Smalltalk.
Pekr
17-Nov-2012
[3859]
Andreas - stop pesking us for such a chat. Many arguments areound 
are based upon various arguments, some of them leading to history 
of mankind/math itself. Thanks ...
Andreas
17-Nov-2012
[3860]
Pekr, please chat elsewhere.
DocKimbel
17-Nov-2012
[3861]
Range! datatype: I would like to add one, but it needs preliminary 
study on how it can affect series semantics.
PeterWood
17-Nov-2012
[3862x2]
Whilst Pascal allows arrays to have a user specified base for array 
indeces, the default is 1 based. It also allows a zero element:

Code
program Arrays;
uses SysUtils;
var
  i : Integer;
  myArray : Array[-1..1] of Integer = (1,2,3); 
begin
  for i := -1 to 1 do

    writeln('Element ' + IntToStr(i) + ' Value ' + IntToStr(myArray[i]));
end.

Result
Element -1 Value 1
Element 0 Value 2
Element 1 Value 3
An interesting point of view on zero v 1 based indexing - http://alarmingdevelopment.org/?p=470