Sharkysoft home

Package lava.clib.stdarg

Emulates features in C's stdarg library; syntactic sugar for printf.

See:
          Description

Class Summary
Va_list Syntactic sugar for variable argument lists.
 

Package lava.clib.stdarg Description

Emulates features in C's stdarg library; syntactic sugar for printf.

Details: This package was introduced mainly to address a syntax-issue related to our Java port of printf. The C version of printf has an open-ended definition; the length of the parameter list and types of parameters are not known at compile time. Argument processing in this type of C function is complicated and usually requires features in C's stdarg package.

Unfortunately (or should we say "fortunately"?) Java does not directly support variable argument lists, so we had to come up with another way to emulate them for functions like printf and scanf. The Lava solution to variable argument lists is the Object array, because it can contain any number of elements of any type. Primitive types, such as int, char, etc., are of course wrapped in objects such as Integer, Character, etc., before they are stored in Object arrays.

While Object arrays are the best and most direct way to address variable argument lists, for some programmers it is syntactically messy and unpleasant. The sole purpose of this package is to provide syntactic sugar for Java programmers with weak stomachs. These classes insulate such programmers from the rigors of direct Object array manipulation, much as C's stdarg library has insulated C programmers from the gory details of variable argument lists.

If you are a skilled C programmer, it is better to stick with Object arrays and not use this package at all, because Object arrays are more efficient than the solutions provided here.


Sharkysoft home