-1 as last item problem

J. Landman Gay jacque at hyperactivesw.com
Sat May 21 02:10:19 EDT 2005


On 5/20/05 9:35 PM, Richard Gaskin wrote:

> Dennis Brown wrote:
> 
>> Bug# 976 complains about the problem as a bug --resolved as not a bug  
>> due to compatibility with HyperCard
>> Bug#1137 complains about the problem as a lack of proper  
>> documentation about the quirks of the language. --I voted for this also
>>
>> It seems that nobody believes that this inconsistency is the desired  
>> behavior, but because HyperCard did it this way, that is the final  
>> answer. 
> 
> 
> Well, it was the mother tongue, and it may confuse many more people and 
> possibly break scripts if they changed it.
> 
> Personally my own preference is for the consistency you propose.  But 
> before I vote for the bug I'd like to hear the rationale for HyperCard's 
> behavior -- where's JK Calhoun when you need him?  I didn't always agree 
> with his language recommendations but I did always respect the 
> thoroughness of his thinking.

If I remember right, it went something like this. You have a list of lines:

Line One <cr>
Line Two <cr>
Line Three <cr>

How many lines are in the list?

How about this list:

Line One <cr>
Line Two <cr>
Line Three

Most people would say there are three lines in both lists. We expect the 
last line to be the same whether there is a trailing carriage return or 
not. Line -1 of either list is "Line Three".

How many lines in this list:

Line One <cr>
Line Two <cr>
Line Three <cr>
<cr>

Most people would say there are four lines, and the last line is empty. 
That's because there are two trailing returns.

To retain consistency when processing all types of text chunks, single 
trailing delimiters are dropped. Thus:

   item1,item2,item3,

has three items, as does:

   item1,item2,item3

and item -1 of either list is "item3".

And so on. It makes sense in its own way.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list