[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NICKLEN, CHANLEN, PATHLEN
Sorry, I missed this one when I was rolling up comments.
>> Also, it might be worthwhile to consider adding defines like NICKLEN,
>> CHANLEN, and PATHLEN to xchat-plugin.h, as it may save some people from
>> having to pull in xchat.h too (which can equate to a small can of worms).
>>
>> I'm looking forward to developing for this client. Thanks for everyone's
>> efforts!
>
>Those are internal sizes, they really don't apply to the plugin API. There
>really must be a layer of abstraction, so using anything in xchat.h is at
>your own risk (i.e. potentially breaking compatability with the next
>release).
Well, you'll recall I did suggest including specific defines in
xchat-plugin.h, and disrecommended including xchat.h... in fact I even
commented on opening a can of worms in the latter case. I understand about
abstraction, data hiding, and so on, and I agree with those principles. But
let's look at why these defines perhaps DO apply to the plugin API. Here's
one example:
Let's say I decide to write a plugin that does something with nicks. Since
I'll only be working with one at a time, I'll just use a few fixed character
string variables. So, now: How much space do I declare? If I set aside 10
bytes for NICKLEN=9 IRCDs, my code will blow up when I hit a NICKLEN=30
network. I could just say "char varname[255]" or something otherwise huge and
be safe, of course. Or I could allocate dynamically, though that'd be kind of
silly for a handful of variables with short lifespans.
BUT... If I know that the longest nick XChat can support is 64 bytes (e.g.
#define NICKLEN 64), then I also know my plugin should never receive a nick
longer than that. By using NICKLEN, CHANLEN, PATHLEN, etc. to dimension
variables in my plugin, I know I'm "in sync" with whatever XChat might be
passing me.
To my mind, this is less a matter of revealing internals than it is exporting
some of the specifications for the API so external code can be compliant.
It's not a big deal... just a suggestion for consideration.
Cheers,
James
--
XChat-discuss: mailing list for XChat users
Archive: http://mail.nl.linux.org/xchat-discuss/