Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!veritas!amdcad!BitBlocks.COM!bvs From: bvs@BitBlocks.COM (Bakul Shah) Newsgroups: comp.lang.postscript Subject: Re: Bind problems Message-ID: <1991May5.195723.2145@BitBlocks.COM> Date: 5 May 91 19:57:23 GMT References: <1991May5.010114.24826@neon.Stanford.EDU> Organization: Bit Blocks, Inc. Lines: 28 rokicki@neon.Stanford.EDU (Tomas G. Rokicki) writes: >Bind causes problems if a document that includes a definition such as > /p /show load def >then includes a graphic file that does something along the lines of > /test { /p exch def p show } bind def >for a simple example. I have found that this happens fairly often. This is a problem due to the dynamic scoping rules of postscript. What happens if show was redefined in the enclosing environment? The included file has no easy way of protecting itself from such redefinitions, with or without the use of bind. The point is that a programmer has to know language rules and their consequences. Of course, this particular problem is very hard to figure out without being actually bitten by it. And may be even then. A workaround may be to define a procedure that binds to operators only if their names appear in system dict and redefine bind to it (assuming new definitions do not get put in systemdict). Redefining bind to a null proc will work even better but bind does improve performance in some cases so that may not be such a great idea. IMO Adobe should write an app-note about the correct use of bind and other consequences of dynamic scoping to help avoid such problems. Hopefully. Bakul Shah bvs@BitBlocks.com