Some thoughts on duck typing

David Bovill david at vaudevillecourt.tv
Wed Jan 12 13:22:44 EST 2011


On 12 January 2011 14:37, Richard Gaskin <ambassador at fourthworld.com> wrote:

> If such metadata are needed for the variables, what would be the downside
> of using an array?  That way you could store/access the type metadata
> quickly:
>
>  put tData into gMyDucksA["label"]["data"]
>  put "rtfText" into gMyDucksA["label"]["type"]
>
> I realize that this is an obvious solution you've probably already
> considered, but given the difficulties of imposing types and OOP constructs
> in a typeless non-OOP language, for practical purposes such a
> Lua-metatable-esque option may provide a reasonable balance between
> performance and flexibility.
>

Yes - your right Richard. I'm being a perfectionist - or just really lazy -
in fact both at the same time :) Seriously, I want to end up with full typed
data specifications in an array format of the form you describe, but
tailored to be useful for internal use, and XML export to things like Django
templating language or XForm type encoding - internally there would be a
standard array format that would work with datagrids and other form widgets.

The duck typing is for the defaults - that's the lazy bit, and the bit that
takes the most effort at the same time. In general I've found getting the
defaults right for things like this to be both incredibly useful in terms of
future usability and incredibly difficult to get right. The usability I'm
looking for internally is simply to create simple arrays, from data in
LiveCode and external files, and not bother about the type of data. The duck
typing would simply fill in the defaults, which you can use to create
default forms for displaying or editing the data - I think this should cover
90% of the cases - for the rest you would manually script the data types to
allow for the appropriate form elements to be selected to display the data.
Indeed you would manually refine the data in all sorts of ways.

Does anyone know of any good widely used or well designed formats for form
representation - Django, HTML5, DOJO, and XForms are the things I've
investigated - I'm not too sure how much traction XForms gets, and if HTML5
forms makes it redundant - but ideally I'd like to borrow from well thought
out data structure designs in other frameworks and know that it is possible
to export the core LiveCode layouts for use in a range of web applications.



More information about the use-livecode mailing list