home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18286 < prev    next >
Encoding:
Text File  |  1992-12-13  |  2.0 KB  |  51 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!news.hawaii.edu!stego!yamada
  3. From: yamada@stego.ifa.hawaii.edu (Hubert Yamada)
  4. Subject: Re: Updated and improved "testing competence" questions
  5. Message-ID: <1992Dec13.083731.15395@news.Hawaii.Edu>
  6. Sender: root@news.Hawaii.Edu (News Service)
  7. Nntp-Posting-Host: stego.ifa.hawaii.edu
  8. Organization: University of Hawaii, Institute for Astronomy
  9. References: <1gbstkINNfcp@almaak.usc.edu>
  10. Date: Sun, 13 Dec 1992 08:37:31 GMT
  11. Lines: 38
  12.  
  13. In article <1gbstkINNfcp@almaak.usc.edu> ajayshah@almaak.usc.edu (Ajay Shah) writes:
  14. >7. There is a C program which contains the line
  15. >
  16. >#include "min.h"
  17. >
  18. >   Now min.h EITHER contains
  19. >        #define min(a, b) (a)<(b)?(a):(b)
  20. >   OR
  21. >        int min(int a, int b);
  22. >   but you don't know which.
  23. >
  24. >   Write a test program which will tell you what is in min.h
  25. >   You are not allowed to know anything about how your program is linked;
  26. >   you are only allowed to write this program, and see it's behaviour in
  27. >   compilation and execution.
  28.  
  29. I really wonder what this question is trying to test.  If you're trying
  30. to see if your applicant knows about the danger of side effects when
  31. macro has arguments, then why not just ask the more straight forward
  32. question:
  33.  
  34.     Given:
  35.         #define MIN(a,b) ((a) < (b) ? (a) : (b))
  36.         int min(int a, int b) { return MIN(a, b); }
  37.  
  38.     What are the differences between using MIN() and using min()?  Is
  39.     there any time when you could use one, but not the other?
  40.  
  41. I think that a valid answer to _your_ question would be: who cares
  42. whether it's the macro or the function?  If I was that unsure about a
  43. function that I had to use, I would either reimplement it, find a
  44. suitable replacement, find the documentation, or write code that would
  45. work correctly in either case.
  46. -- 
  47. Hubert Yamada                   * Our hero is called before the alien
  48. yamada@galileo.ifa.hawaii.edu   * potentate!  Where it becomes clear that
  49. yamada@uhunix.uhcc.hawaii.edu   * Spiff is about to be sacrificed to appease
  50. Bitnet: yamada@uhunix.bitnet    * the evil god they call "Nollij"!
  51.