First Class Arrays: good news and feature requests

David Bovill david at architex.tv
Fri Sep 12 08:40:51 EDT 2008


Oh joy storing the new arrays works! Yes, first lets start with some
congratulations! We can now set and get arrays as stored binary custom
properties of controls!

Now I may be wrong? Possibly this was added earlier and i have not noticed?
But I for one have been using a library to get around the old limitations of
storing arrays as custom properties (using the rather strange syntax of:

set the customproperties ["colour_Properties"] of this card to dataArray

Now we can do this:

set the colour_Properties of this card to dataArray

which is terific, as this would not work for arrays before. I was half way
through filing a feature request for that one :)

*Now the bad news*
While we can pass an array to a function or a command - we still can't do
this for a setprop handler! This is not only inconsistent with the new
behaviour described above, it was akward even in earlier versions for anyone
defining their own custom properties of controls. Its natural to assume if
you have a getprop theri is a matching setprop, and it is useful often to
return arrays from getprop handlers. But while you can do this for getprops
the symetry is broken when you want to set a property to the value of an
array. This becomes really important when you start to define rich
interfaces to widgets or groups that you want to allow other people to
manipulate.

Easiest to describe with a example:
*
Example: creating useful user interfaces*
Below is a simplified example of the sort of interfaces we might wish to
create to our controls. There are many many richer examples, but to get the
point across I've defined a property which manipulates some key visual
properties of a group. In the example we have a group and we want to be able
to easily fetch and set its display data (in the example colours) in a
similar way that rev stores a controls "properties" as an array.

getprop colour_Properties
    put the backgroundcolor of me into colourArray ["back"]
    put the foregroundcolor of me into colourArray ["fore"]
    return colourArray
end colour_Properties

setprop colour_Properties colourArray
    if keys(colourArray) is empty then
        beep
        answer warning "Not first class arrays!"
    else
        set the backgroundcolor of me to colourArray ["back"]
        set the foregroundcolor of me to colourArray ["fore"]
    end if
end colour_Properties

Unfortunately this does did not work in the old array structures, and has
not been added to the new ones. So you can't do things like:

on mouseUp
    get the colour_Array of btn 1
    set the colour_Array of btn 2 to it
end mouseUp


*Feature Requests*
Following on from Trevors list of features to add to the new array structure
- I thought I'd file them as feature requests in bugzilla - feel free to
vote for them if they are relevant to you? I've also added my pet wish as a
big user of getprop / setprop handlers to make easy to use widgets (see
below):

   1. Allow setprop handler to use
arrays<http://quality.runrev.com/qacenter/post_bug.cgi>.
   (for a language refinement and related example see
here<http://quality.runrev.com/qacenter/show_bug.cgi?id=4185>
   )
   2. Ability to reference elements of an array in the order they were added
   to the array <http://quality.runrev.com/qacenter/show_bug.cgi?id=6955>
   3. Ability to reference an multi-dimensional keys
dynamically<http://quality.runrev.com/qacenter/show_bug.cgi?id=7166>.
   Right now we have to build the array key reference and then use 'do'.
   4. Ability to pass a key of an array by
reference<http://quality.runrev.com/qacenter/show_bug.cgi?id=7167>

Trevor - I've taken the liberty of adding your feature requests where i coud
not find them - so I guess you should vote on them :)

* *



More information about the use-livecode mailing list