On Dec 16, 2014, at 7:37 PM, Richard Hipp <d...@sqlite.org> wrote: > But they are useful at times.
Yes. It’s not as useful as a type system that simply doesn’t let you do questionable things,[*] but when you have to write in C or C++, it’s good to buttress the type system with some notation. I’ve used a similar system for decades: a = array (some like v for vector instead) b = Boolean c = character (except when used as an 8-bit integer) e = enum f = floating-point number g = global h = handle (haven’t used this since my Win32 days) k = constant n = integer number p = pointer s = string (C++ only; C strings are pc or kpc) _ = trailing underscore on C++ private member variables They combine, of course: const char* akpcStringTable[] = { “lots”, “of”, “strings” }; Some variant schemes I’ve come across separate the storage and access specifiers (k, g) from the type specifiers with an underscore: gk_apcStringTable would be a global array of const pointers to char. The admixture doesn’t bother me, so I’ve never adopted that convention. It’s common among Visual C++ users, where the trailing _ in my scheme becomes an m_ prefix, for “member”. Notice that unlike MS style Hungarian, my integers are all ’n’, not differentiated by storage size. Modern compilers are smart enough to avoid this sort of problem, for the most part. I did manage to confuse the C++ compiler a few months ago, though. I changed a function returning bool (success/failure) to return 0/“error message” instead: bool myFunction() { if (happy) { return true; } else { return false; } } became: const char* myFunction() { if (happy) { return 0; // there’s only one kind of happy } else { return “the frobnitzim have kerflamulated”; // but many kinds of sad } } My actual function was fairly complex, and I accidentally left one of the “return false” calls unchanged. C++ allows false to convert to 0 which converts to const char* which turned a failure condition into success! The compiler didn’t even blink, even with -Wall. Perfectly sane according to GCC. Grrr. [*] e.g. ML family languages like OCaml and F# _______________________________________________ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users