Article View: comp.lang.postscript
Article #11Re: How do you clear a dictionary?
From: Val Kartchner
Date: Tue, 27 Oct 1992 20:51
Date: Tue, 27 Oct 1992 20:51
46 lines
2592 bytes
2592 bytes
delahunt@adobe.com (Jim DeLaHunt) writes:
: In article <1992Oct22.142233.10525@fcom.cc.utah.edu> val@news.ccutah.edu
: (Val Kartchner) writes:
: >I need to delete all of the key-value pairs out of a dictionary....
:
: The PostScript language has an "undef" operator, which deletes a key-value
: pair from a dictionary. "undef" is supported in PostScript Level 2
: interpreters only.
I want this to be able to work on PS Level 1. Unfortunately, that lets
"undef" out.
: In a PostScript Level 1 interpreter, you can use "save" and "restore" to
: accomplish the same thing, albeit with many side effects. If you do:
: /mydict 10 dict def
: /emptydict-state save def
: /foo 234 def
: Then "emptydict-state restore" will return "mydict" to its empty condition.
: It will also undo all other changes to VM in the interim, so you'll have
: to allow for that.
I've had some bad experience with "save"-"restore" pairs. I've found
that these can only be used reliably in controlled circumstances. From
the "Postscript Language Reference Manual", "restore":
"restore" does not alter the contents of the operand, dictionary, or
execution stack (except to pop its "save" operand). If any of these
stacks contain array, dictionary, file, name, save, or string objects
that are newer than the snapshot being restored, "restore" executes
the "invalidrestore" error.
This lets out certain types of operations like creating strings to be
used later.
: I've done a lot of PostScript language programming, and I don't find myself
: needing to delete key-value pairs that often. What are you trying to
: achieve?
I create a form whose field values are in a given dictionary. I've
changed my need. I now just blank or null the dictionary entries.
--
|===== The previous was my opinion -- val@csulx.weber.edu =====///============|
| "AMIGA: The computer for the creative mind." (tm) Commodore /// Weber State |
| "Macintosh: The computer for the rest of us."(tm) Apple \\\/// University |
|============== "I think, therefore I AMiga." =============\///=== Ogden, UT =|
Technical Details
Message-ID:
<1992Oct27.205112.26427@fcom.cc.utah.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!pmafire!mica.inel.gov!ux1!fcom.cc.utah.edu!valReferences:
<1992Oct27.040112.4634@adobe.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!mica.inel.gov!ux1!fcom.cc.utah.edu!val From: val@news.ccutah.edu (Val Kartchner) Subject: Re: How do you clear a dictionary? Message-ID: <1992Oct27.205112.26427@fcom.cc.utah.edu> Sender: news@fcom.cc.utah.edu Organization: University of Utah Computer Center X-Newsreader: Tin 1.1 PL3 References: <1992Oct27.040112.4634@adobe.com> Date: Tue, 27 Oct 92 20:51:12 GMT Lines: 46