Converting iso-4217-currencies.scm to C?

Derek Atkins warlord at MIT.EDU
Mon Feb 9 11:54:54 EST 2009


Christian Stimming <stimming at tuhh.de> writes:

> Right now we have a scheme -> C generator that generates a list of 3000 
> function calls. I think Alan's proposal was to change this into a generator 
> that generates a C array with 3000 entries, and writing some simple looping 
> code that loops over this array. In effect, I think this isn't much of a 
> difference (meaning Alan's time can probably be spent on more important 
> things instead), but if Alan would like to submit a patch, I'd probably agree 
> to commit this.

That seems relatively silly, IMHO.  Why have scheme generate a
C array?  Why not just encode the list in the C array in the first
place?

I.e., I can imagine something like:

typedef struct {
  const char* fullname;
  const char* unitname;
  const char* partname;
  const char* namespace;
  const char* mnemonic;
  const char* exchange_code;
  unsigned    parts_per_unit;
  unsigned    smallest_fraction;
} GNCCurrencyDef;

static GNCCurrencyDef gncISOCurrencies[] = {
 { "Afghanistan Afghani (old)", "afghani", "pul", "ISO4217", "AFA", "004", 100, 100 }, // through 2003-01-02
 { "Afghanistan Afghani", "afghani", "afghani", "ISO4217", "AFN", "971", 1, 1 }, // from 2002-10-07
 ...
};

Alan, is this what you had in mind?

> Regards,
>
> Christian

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list