List Object

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

List Object

Post by edgore » Tue Aug 13, 2013 6:37 pm

In the Number of Items discussion (http://forums.runrev.com/viewtopic.php?f=66&t=16383) runrevmark mentioned that they are working on a list object of some kind for future implementation. Since so much of what I do is dealing with lists of multiple items on multiple lines I am curious to find out more about what is planned in this area, and what some of the thinking around this is. For example, how would this interact/compare with arrays, and what kind of operations would be available for comparing lists, processing lists, intersecting lists, etc. There are a bunch of things that I would like to be able to do more easily (and in a more readable, easy to follow fashion) than what I am doing today with arrays and the current text lists with delimiters. For example, it would be great to be able to do something like:

put "xxxx" into item 5 of the lines of list "myList" (or put "xxxx" into item 5 of every line in list "myList" - however the syntax worked out)

and have that put the value "xxxx" into item 5 of every line in the list called "myList

It would also be great to be able to do something like

Put "xxxx" into item 5 of the lines of list "myList" where item 4 of the line is "yyyy" (or whatever the syntax end up being like)

which would only put "xxxx" into item 5 of those lines in the list where item 4 of the line is currently "yyyy"

I can do everything that I want with for each loops, and I can speed it up by carefully figuring out how to reorder the items of a text delimited list, then split and combine things into arrays and reorder the list back to the way I want it , but if a list object is going to get made, it would be nice to think about what kinds of operations should be possible and how that should work. I think that most of this stuff could end up being as fast as the array stuff is today (since I assume similar types of things would be going on behind the scenes) but it would probably be much easier for people to understand and implement, and much easier to read.

Anyway, I guess what I am wondering is as the thinking starts to happen about lists, where will I (a person that can't read C, or even begin to understand github) be able to go and read about the thinking that is going into the development of the list object and make my suggestions about how I would like it to work? I figured that posting in this forum was the best first step.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: List Object

Post by LCMark » Wed Aug 14, 2013 9:56 pm

@edgore: Thanks for your interest in this - I did post some more ideas on this topic on the other thread, but thought it worth reproducing here :)

What I was proposing on the 'number of items' thread wasn't a list object exactly, but a new kind of value which is a sequence of any kind of value - equivalent to (but with a different internal representation for efficiency from) an array with integer keys from 1 up to the number of elements of the list. You'd be able to manipulate them with syntax along the lines of:

Code: Select all

put element 3 of tList
put tList[3]
push tValue onto front of tList
push tValue onto back of tList
pop front of tList into tHead
pop back of tList into tTail
insert tValue before element 5 of tList
insert tValue after element 6 of tList
Additionally, we would have the option to add auto-conversion to and from strings - perhaps with an 'elementDelimiter' to control how to connect the elements together.

The list concept can also come into play in connection with existing chunks. e.g.

Code: Select all

  put the items of tString into tList
  put the lines of tString into tList
In terms of your suggestions about being able to manipulate certain elements of lists selectively in one go, then that is actually a more general chunk operation (things along the lines of):

Code: Select all

put "xxxx" into item 5 of each line of tStringList
put "xxxx" into item 5 of each line of tStringList where item 4 of the line is "yyyy"
put "xxxx" into item 5 of each element of tRealList
put "xxxx" into item 5 of each element of tRealList where the element is "yyyy"
put the lines of tStringList where item 4 of the line is "yyyy" into tRealList
put the elements of tRealList where item 5 of the element is "yyyy" into tRealList
(Here using 'each' - or something similar - as an adjective means the syntax nicely extends to the other chunks we have, and isn't just limited to lists).

There's probably a whole host of other operations that could be conceived to operate on them (feel free to suggest!), and their unity with arrays (of a certain kind) mean they would be very amenable to working in different contexts.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: List Object

Post by malte » Thu Aug 15, 2013 10:06 pm

This sounds really powerful. I would love to have that. If we had each there, something along the lines of

Code: Select all

put "xxxx" into item 5 of line 3 to -2 of tStringList
put "xxxx" into item 5 of line 3 to -2 of tStringList where item 4 of the line is "yyyy" or item 2 of the line ="zzzz"
would be one of the next things I'd desire :-)

Locked

Return to “Engine Contributors”