home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!news.funet.fi!news.cs.tut.fi!tut!pk
- From: pk@cs.tut.fi (Kellom{ki Pertti)
- Newsgroups: comp.lang.scheme
- Subject: Location tags of primitive procedures
- Date: 13 Nov 92 12:26:24
- Organization: Tampere Univ. of Technology, Finland.
- Lines: 43
- Distribution: comp
- Message-ID: <PK.92Nov13122624@talitiainen.cs.tut.fi>
- NNTP-Posting-Host: talitiainen.cs.tut.fi
-
- R4RS requires that each procedure created as the result of evaluating
- a lambda is tagged with a storage location. This location can then be
- used for comparing procedures with eqv? and eq?. My question is: does
- this also hold for builtin procedures, and if it does, do the tags of
- builtins have to be unique?
-
- I have run into situation in practise where this matters. In my
- debugger I try to catch application of a primitive procedure that
- would cause a runtime error. This is done by having an alist of
- procedures and associated information about the parameters they
- accept, for example
-
- ...
- (,close-input-port (1 ,(assert 1 input-port?)))
- (,close-output-port (1 ,(assert 1 output-port?)))
-
- Before a procedure is actually applied, it is first looked up in the
- alist. Thus, for the call
-
- (close-output-port port)
-
- the entry for close-output-port is fetched. There is only one
- parameter, so that part is ok, and if the value of port is an output
- port, the call will be made.
-
- It now happens that in scm there is a more general procedure
- close-port, to which both close-input-port and close-output-port are
- bound, which makes perfect sense to me. For my debugger it does not
- make sense, though, because it will find the entry for
- close-input-port, and test wether the value of port satisfies
- input-port?.
-
- I know how to work around this (as T. Kurt Bond suggested in his bug
- report): redefine close-input-port and close-output-port using lambda,
- and everything will be all right. However, I can imagine other situations
- where it would be nice for builtin procedures to have a unique
- identity.
- --
- Pertti Kellom\"aki (TeX format) # These opinions are mine,
- Tampere Univ. of TeXnology # ALL MINE !
- Software Systems Lab # (but go ahead and use them, if you like)
-
-
-