Amiga.org

Amiga News and Community Announcements => Amiga News and Community Announcements => Amiga Programming and Development => Topic started by: krashan on October 26, 2011, 08:04:34 PM

Title: All you want to know about taglists
Post by: krashan on October 26, 2011, 08:04:34 PM
In the series about MorphOS basics in the MorphZone Library (http://library.morphzone.org), I've written an extensive article (http://library.morphzone.org/Taglists) about taglists, one of main concepts of the AmigaOS (and its derivatives) API. Taglists were introduced in AmigaOS 2 and are present in almost unchanged form in MorphOS, AmigaOS 4 and also AROS, so it may be an interesting reading for developers working will all these systems.
Title: Re: All you want to know about taglists
Post by: jj on October 27, 2011, 03:18:56 PM
Interesting read.  Is the main advantage of tag lists that their are functions for dealing with them as opposed to a normal array of key values ?
Title: Re: All you want to know about taglists
Post by: ChaosLord on October 27, 2011, 04:25:37 PM
Very nice article!  Krashan FTW!
Title: Re: All you want to know about taglists
Post by: Piru on October 27, 2011, 07:44:18 PM
Quote from: JJ;665341
Interesting read.  Is the main advantage of tag lists that their are functions for dealing with them as opposed to a normal array of key values ?

The most benefit comes when tag lists are used to pass arguments to API functions: It's easy to add new functionality or parameters to existing functions, without breaking backward compatibility. Even if a newer implementation knows about new tags it doesn't interfere with old apps calling the function and only using the older tags.
Title: Re: All you want to know about taglists
Post by: Karlos on October 27, 2011, 11:36:57 PM
Quote from: Piru;665372
The most benefit comes when tag lists are used to pass arguments to API functions: It's easy to add new functionality or parameters to existing functions, without breaking backward compatibility. Even if a newer implementation knows about new tags it doesn't interfere with old apps calling the function and only using the older tags.

Also, there are probably performance benefits over... well, what other semantics could you use? Variadic function calls are one possibility in C at least. Considering that the TagItem array can be constructed in a number of ways and can be allocated in more than one storage type (ie, not just "on the stack"), then passing a struct TagItem * pointer to your function beats pushing a long list of temporary variables onto the stack that are then popped off again - especially if the function being called makes calls to other functions internally that might use the same TagItem set (or at least deals with a subset of them).

Having said that, in a lot of use cases, the TagItem array will only be a small collection and allocated on the stack regardless.
Title: Re: All you want to know about taglists
Post by: jj on October 28, 2011, 11:22:39 AM
Thanks for the replies all