in reply to Re: XS from XS?
in thread XS from XS?

This is a situation where "X macros" (https://en.wikipedia.org/wiki/X_Macro) really help, as used by PDL. It used to have highly redundant, multiple lists of the PDL API functions in several files. Now it uses the "X macro" technique, which for this application would look like (untested - see https://github.com/PDLPorters/pdl/blob/master/Basic/Core/pdlcore.h for defines and use, and https://github.com/PDLPorters/pdl/blob/master/Basic/Core/Core.xs for use, of PDL_CORE_LIST):
/* in C part of .xs, else in a .h */ #define SNOWBALL_FUNCS(X) \ X(list, 39) \ X(new, 38) \ X(delete, 41) \ X(stem, 39) \ X(length, 41) MODULE = Lingua::Stem::Snowball PACKAGE = Lingua::Stem::Snowball PROTOTYPES: disable BOOT: { #ifdef I_HAVE_C99 /* not a real symbol, don't use this */ #define X(symname, no, ...) \ SV *sb_stemmer_ ## symname ## _sv = newSViv(PTR2IV(sb_stemmer_ # +# symname)); \ hv_store(PL_modglobal, "Lingua::Stem::Snowball::sb_stemmer_" #symn +ame, no, sb_stemmer_ ## symname ## _sv, 0); SNOWBALL_FUNCS(X) #undef X #else #define X(symname, no, ...) \ SV *sb_stemmer_ ## symname ## _sv = newSViv(PTR2IV(sb_stemmer_ # +# symname)); SNOWBALL_FUNCS(X) #undef X #define X(symname, no, ...) \ hv_store(PL_modglobal, "Lingua::Stem::Snowball::sb_stemmer_" #symn +ame, no, sb_stemmer_ ## symname ## _sv, 0); SNOWBALL_FUNCS(X) #undef X #endif }
The biggest benefit is maintainability. You'll see the PDL example also captures the C functions' return types and argument types, so adding to the API is a matter of adding lines to the big macro calling X.

Edited to add how to use this if you're not using C99, where you can declare things anywhere.