From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-03-05 20:03:24
On Mon, Mar 05, 2001 at 11:24:47AM -0600, Mike McCarty wrote: > For better readability you may want to use macros: > > #define POKE(addr,val) (*(unsigned char *)(addr)=(val)) > > This definitely REDUCES readability and obscures what the code > is doing. > > Which code is easier for you to read? > > (a) VideoMode = VIDEO_REVERSE; > > (b) POKE(199,1) /* Set video mode to reverse */ Your quote is completely out of context (or my english is even worse than I thought). The sentence "For better readability you may want to use macros" on the page references the example above (in the FAQ), where memory access is done in full length. Which code is easier for you to read? (a) *(unsigned char*)199 = 1; (b) POKE (199, 1); And, later on I'm proposing predefined variables for hardware access, saying that this is the most readable way. So where is the difference between your statements and mine? > I recommend that people NOT implement PEEK and POKE at all. The direct C > is more readable than the macros. Even better is to implement macros > which make the code understandable without having to add comments. For someone with a BASIC background (and many people programming the old machines do have BASIC knowledge), PEEK and POKE are completely readable and do have a meaning. It is easy to translate BASIC programs using PEEK and POKE, this would be another reason to use them. So while I would recommend to use fixed memory variables as I have done in the FAQ and in posts to this list, I don't think that PEEK and POKE are evil. Just use what is best in a given situation. Regards Uz -- Ullrich von Bassewitz uz_at_musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:39 CET