Welcome, Guest. Please login or register.

Author Topic: All you want to know about taglists  (Read 3389 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: All you want to know about taglists
« 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.
int p; // A