-1 as last item problem

Dennis Brown see3d at writeme.com
Fri May 13 22:54:29 EDT 2005


Dar,

I don't agree with this.  Commas are significant items.  The -1 is  
supposed to be the same as saying the last.  If I replace the -1 with  
a 10, then it decides that the last comma is significant.  If I had a  
10 comma empty list in "it" and if I were to:

repeat 10 times; get item 1 to -1 of it; end repeat

I would have nothing left. But:

repeat 10 times; get item 1 to 100 of it; end repeat

would preserve all the commas.

Removing a comma destroys part of the list structure.  Just because  
it is empty now does not mean it will not have some data later.  A  
single item line has no comma.  A comma goes between items as you  
said.  A single line has no return.  Returns go between lines.  But  
you are right in that if I ask Rev how many items are on the lines,  
it says:

6,5,6

And that is why the -1 get translated into a 5 instead of a 6.
IMHO this is not a good compromise.  I don't like this at all!  It  
can lead to all sorts of subtle bugs.  If this is the way it is  
supposed to be, then it needs a significant amount of tutorial  
documentation to keep programmers from getting tripped up.

Dennis

On May 13, 2005, at 10:00 PM, Dar Scott wrote:

>
> On May 13, 2005, at 7:08 PM, Dennis Brown wrote:
>
>
>> Notice the missing last comma on the second line.  It does not  
>> matter how many commas I append, it will always leave off the last  
>> one unless there is another character at the end.  Unless I do not  
>> understand how this is supposed to work, this is a bug.  Yes?
>>
>
> I believe the way it works is correct.
>
> It accommodates the best compromise in being able to represent both  
> an empty list and a list of one item that is empty.
>
> If comma is between, then those look the same.  You can't represent  
> both.  If the comma is after, then you can represent both.
>
> Now a comma in between is just fine for lists that do not have any  
> empty items.  In that case, the empty string means the empty list.   
> So, for non-empty items, the traditional list is fine.
>
> If items can be empty, then it would be better to represent lists  
> with the comma at the end of each item.  In both cases the number  
> of items and item representation works.
>
> The same applies to lines.  I think that is easier to accept.  For  
> items, it is harder; a comma should go between things.
>
> Dar Scott
>
>
>
> -- 
> **********************************************
>     DSC (Dar Scott Consulting & Dar's Lab)
>     http://www.swcp.com/dsc/
>     Programming and software
> **********************************************
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list