Article View: comp.lang.postscript
Article #5507Bind is a travesty
From: Tomas G. Rokicki
Date: Mon, 29 Apr 1991 07:34
Date: Mon, 29 Apr 1991 07:34
115 lines
4378 bytes
4378 bytes
I have often expressed the opinion that `bind' was the greatest disservice
to the computing community Adobe has ever made. The attached file will
illustrate why.
Use this file to test random prologs from various applications. The
prologs should be `clean'---they should leave all stacks like they were
originally (no save at the beginning), and they should not exitserver.
Most prologs can easily be modified to fit these requirements. Insert
the prolog at the end of this PostScript file, and add `bind-summary'
to the very end. Print.
*Any* free variables caught point out a potential problem; too many
outer definitions show another possible problem.
[I must admit that I myself am far from perfect; my dvips prolog, even
after many hours spent making sure that bind was used correctly, still
fails this test for a few variables. That is being fixed immediately.
But this is just more evidence that bind was a serious mistake.]
My diatribe against bind is available upon request.
%! This PostScript file Copyright 1991 by Radical Eye Software.
% All Rights Reserved.
%
% This little file will help you test your PostScript prolog for bind
% problems. A bind problem is a case where the `bind' function is used
% on `free' variables:
%
% /test { x y add } bind def
%
% may not work correctly if the document is included in an environment
% where `x' is defined on the dictionary stack.
%
% To use this file, just append the prolog you wish to test to this file,
% and add a call to `bind-summary' at the very end of the prolog. That
% should print out a page containing a list of `free' variables that were
% bound (all of which probably point out problems in your prolog) and a
% list of symbols defined in the dictionary on the outermost level.
% If there are more than a few of these latter, then you are assuming
% that the default dictionary is a certain size, which is not a good idea.
%
% If you don't know what you are doing, don't ever use bind. This file
% should convince you of that when you run it over typical prologs.
%
% Generally, the prolog is the part from the beginning of the file to
% the %%EndProlog comment.
%
% This file needs to be made much more robust.
%
% This won't work for `exitserver' type prologs, but that should be easy
% to fix.
%
% This works by redefining `bind'.
%
/real-bind /bind load def
%
/badbinddict 200 dict def
%
/outerbinddict 200 dict def
%
/userdict outerbinddict def
%
/rbind {
dup type dup /arraytype eq exch /packedarraytype eq or
{
dup rcheck { { rbind } forall } { pop } ifelse
}
{
dup type /nametype eq {
dup xcheck {
dup where { pop pop } {
badbinddict begin
(Uh oh, possible problem?) def
end
} ifelse
} { pop } ifelse
} { pop } ifelse
} ifelse
} def
%
/bind {
dup rbind
} def
%
% Report what happened.
%
/bind-summary {
grestore % just in case someone did something smart.
end % kill off the outerbinddict
/y 720 def
/normalfont /Times-Roman findfont 10 scalefont def
/bindwriteln {
72 y moveto normalfont setfont show
/y y 10 sub def y 72 lt {
showpage /y 720 def
} if
} def
/tempstring 100 string def
(Bind test results) bindwriteln ( ) bindwriteln
(Free variables caught) bindwriteln ( ) bindwriteln
badbinddict { pop tempstring cvs bindwriteln } forall
( ) bindwriteln
(Outer definitions made) bindwriteln ( ) bindwriteln
outerbinddict { pop tempstring cvs bindwriteln } forall
( ) bindwriteln
showpage
} def
%
% We start outerbinddict, so the prolog puts its definitions there.
%
outerbinddict begin gsave
%
% Put your prolog here. At the end, after the prolog, add a call to
%
% bind-summary
Technical Details
Message-ID:
<1991Apr29.073421.2622@neon.Stanford.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stanford.edu!neon.Stanford.EDU!rokickiShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stanford.edu!neon.Stanford.EDU!rokicki From: rokicki@neon.Stanford.EDU (Tomas G. Rokicki) Newsgroups: comp.lang.postscript Subject: Bind is a travesty Message-ID: <1991Apr29.073421.2622@neon.Stanford.EDU> Date: 29 Apr 91 07:34:21 GMT Organization: Computer Science Department, Stanford University, Ca , USA Lines: 115