Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] It's time_t to Party!



>>>>> "Jim" == Jim  <jep200404@example.com> writes:

    Jim> I can't think of a better way to salvage printf(), especially
    Jim> if something like TYPE_T_F was adopted in the headers as a
    Jim> standard (if appropriate).

I think it would better be encapsulated in a stringifier, a la
strftime.  In production code I'd have a qxe_strftype function
encapsulating the #define logic.  ("qxe" is the XEmacs standard
internal prefix for functions that encapsulate implementation-
dependent behavior.)

The way the XEmacs Lisp API handles this is to give each type of Lisp
object a number of standard internal methods, a couple of routines for
allocating, initializing, and finalizing, a routine for marking during
garbage collection, and one for stringifying the object.  These are
not available to Lisp programs, of course.  They're called
automatically by the Lisp engine (for allocation and marking), or by
the generic object printer.

Python does the same.

In C, you can't give objects methods, so the way I think this should
be standardized is to say that every standard `struct TYPE_t' should
have a strfTYPE function which takes a `struct TYPE_t' (or `struct
TYPE_t *') and a format string, with % converters for each struct
member.

    Jim> I would make that a little bit more flexible by leaving out
    Jim> the '%' to allow for more modifiers:

I thought about that.  I decided to make it inflexible because I don't
really think it's an interface that should be exposed to people who
have real work to do.  This is the kind of interface that was invented
to keep geeks "happily occupied for hours".  I didn't think about how
to do it right until you forced me to. ;-)



-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links