Handling of final delimter (was Re: "this me"?)

Kay C Lan lan.kc.macmail at gmail.com
Tue Aug 13 22:01:03 EDT 2013


On Mon, Aug 12, 2013 at 5:47 AM, J. Landman Gay <jacque at hyperactivesw.com>wrote:

>
> It's consistent.


Yes, and so is EVERY bug that's ever plagued a program. destroyStack acts
consistently but it doesn't mean that it's a logical name for the property


> Empying the last item essentially deletes it.


You didn't ask for the item to be deleted, why aren't all items deleted
when they are emptied, why would new users expect LC to do that? Not only
that, delete has it's own unexpected (but consistent) idiosyncrasies.

The terminating comma is retained because it belongs to the item before it.
> The last item beomes "1", and you replace that with 7.
>

> The item delimiter is a terminating character, not a divider, and it
> "belongs" to the text of the item before it.
>

Using the synonym 'terminator' just further confuses the whole issue. To me
a terminator is a "must have" if it doesn't have one it's invalid. i.e. an
opening quote must be terminated with a closing quote, an opening bracket
must be terminated with a closing bracket. If an item in LC requires a
comma as a terminator, in your words the terminator belongs to the PREVIOUS
data, then

1,2,3, = is a 3 item list
1,2,3 = is a 2 item list followed by invalid data because there is no
terminator

Now I don't want to have LC behave that way, I like the fact that LC
recognises "1,2,3" as a 3 item list, I just wish it would be logical enough
to recognise ",2," as a 3 item list with 2 empty items.

Enter the following in the Message Box: (9 lines)

put "1,2,3,,,6" into tStore
put tStore into tStore2
put tStore & " - my 6 item list contains " & the number of items of tStore
& " items" into msg
put empty into item 6 of tStore
put cr & tStore & " - using EMPTY changes my 6 item list to " & the number
of items of tStore & " items" after msg
delete item 6 of tStore2
put cr  &  tStore2 & " - using DELETE changes my 6 item list to " & the
number of items of tStore2 & " items" after msg
put item 1 to -1 of tStore2 into tStore2
put cr & tStore2 & " - trying to fix it with 'ITEM 1 to -1 further mangles
my data down to " & the number of items of tStore2 & " items" after msg

Whilst I appreciate the need to maintain functionality with legacy code, it
doesn't change the fact that the current behaviour of emptying and deleting
items is illogical as it is a sure fire way of ensuring someone will spend
hours, if not days, trying to figure why, emptying item 6 of a list will
100, or 1000, or a million times leave their list the same length, but
every now and then the data is mangled. And with delete, which most times
will only delete the one item you asked it to, but sometimes it will reduce
your list by 2 items.

And what IS inconsistent is the fact that no other program I work with
behaves this way. If I import "1,2,3,4,,6," into a spreadsheet I end up
with 1 row of 7 cells. Exactly the same if I export data from a spreadsheet
or DB; if the last cell of a row is empty/NUL then the last visible
character will be the delimiter/terminator. To put that into current
jargon, LC does not follow industry best practice.

To me it is bizarre that LC allows you to very easily create empty items
left, right and centre, but you have to jump through all sorts of hoops
with additional code if you need empty last items. But worst still is the
fact that ANY empty item can become a liability because if there's any
chance at all that that empty item will become the 2nd last item in a list
where the last item is deleted you now have mangled data. It's more bizarre
than destroyStack



More information about the use-livecode mailing list