home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / scheme / 2583 < prev    next >
Encoding:
Internet Message Format  |  1992-11-13  |  2.1 KB

  1. Path: sparky!uunet!mcsun!news.funet.fi!news.cs.tut.fi!tut!pk
  2. From: pk@cs.tut.fi (Kellom{ki Pertti)
  3. Newsgroups: comp.lang.scheme
  4. Subject: Location tags of primitive procedures
  5. Date: 13 Nov 92 12:26:24
  6. Organization: Tampere Univ. of Technology, Finland.
  7. Lines: 43
  8. Distribution: comp
  9. Message-ID: <PK.92Nov13122624@talitiainen.cs.tut.fi>
  10. NNTP-Posting-Host: talitiainen.cs.tut.fi
  11.  
  12. R4RS requires that each procedure created as the result of evaluating
  13. a lambda is tagged with a storage location. This location can then be
  14. used for comparing procedures with eqv? and eq?. My question is: does
  15. this also hold for builtin procedures, and if it does, do the tags of
  16. builtins have to be unique?
  17.  
  18. I have run into situation in practise where this matters. In my
  19. debugger I try to catch application of a primitive procedure that
  20. would cause a runtime error. This is done by having an alist of
  21. procedures and associated information about the parameters they
  22. accept, for example
  23.  
  24.   ...
  25.   (,close-input-port (1 ,(assert 1 input-port?)))
  26.   (,close-output-port (1 ,(assert 1 output-port?)))
  27.  
  28. Before a procedure is actually applied, it is first looked up in the
  29. alist. Thus, for the call
  30.  
  31.   (close-output-port port)
  32.  
  33. the entry for close-output-port is fetched. There is only one
  34. parameter, so that part is ok, and if the value of port is an output
  35. port, the call will be made.
  36.  
  37. It now happens that in scm there is a more general procedure
  38. close-port, to which both close-input-port and close-output-port are
  39. bound, which makes perfect sense to me. For my debugger it does not
  40. make sense, though, because it will find the entry for
  41. close-input-port, and test wether the value of port satisfies
  42. input-port?.
  43.  
  44. I know how to work around this (as T. Kurt Bond suggested in his bug
  45. report): redefine close-input-port and close-output-port using lambda,
  46. and everything will be all right. However, I can imagine other situations
  47. where it would be nice for builtin procedures to have a unique
  48. identity. 
  49. --
  50. Pertti Kellom\"aki (TeX format)  #       These opinions are mine, 
  51.   Tampere Univ. of TeXnology     #              ALL MINE !
  52.       Software Systems Lab       #  (but go ahead and use them, if you like)
  53.  
  54.  
  55.