Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2465
| Newsgroups | comp.lang.postscript |
|---|---|
| Date | 2016-03-25 09:32 -0700 |
| References | <7526030b-9d4c-465e-ab14-eac3ad5b98ef@googlegroups.com> |
| Message-ID | <a1d28a35-e3fb-4de1-bba5-0ddfc62f323e@googlegroups.com> (permalink) |
| Subject | Re: save ... restore? setglobal? |
| From | luser- -droog <mijoryx@yahoo.com> |
On Friday, March 25, 2016 at 11:05:17 AM UTC-5, jdaw1 wrote: > I maintain a large PostScript program (≈ 12.7k lines). http://www.jdawiseman.com/placemat.html > It does not use save … restore. Indeed, I have never used save … restore in any PostScript program. > > Do you use save … restore? What for? For what should I be using it? > > And yes, I have read §3.7.3, pp61-62, of PLRM3. > > Relatedly, I never use setglobal. Do you use setglobal? What for? For what should I be using it? `save` and `restore` can be used to bracket sections of the program which allocates memory that is not needed after the `restore`. For instance, if you have a "normal" document (not necessarily DSC-compliant, but roughly laid out the same) with a prologue section and several distinct pages, then you can put `save` ... `restore` around each page description. The memory allocated while executing the page will be rewound to the same state (mostly). Since Level 2, postscript has garbage collection, so this isn't strictly necessary for memory management. But judicious use of `save` and `restore` could reduce the burden on the collector somewhat, with an effect on the speed of execution. Also introduced in Level 2 is global memory. This is a separate memory space which is not (normally) affected by `save` and `restore`. You'll only need to use global memory if you're doing something like defining a resource or some other special structure which must persist past the lifetime of any local objects which `restore` might discard. Because local memory is more perishable, there is the rule that arrays and dicts in global memory cannot contain references to objects in local memory (because they might arbitrarily disappear at any time). tldr; Use `save`...`restore` to rewind the values of all arrays and dicts to their contents at the time of the `save`. Use `setglobal` (correctly) if you're trying to use `defineresource`.
Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
save ... restore? setglobal? jdaw1 <jdawiseman@gmail.com> - 2016-03-25 09:05 -0700
Re: save ... restore? setglobal? luser- -droog <mijoryx@yahoo.com> - 2016-03-25 09:32 -0700
Re: save ... restore? setglobal? jdaw1 <jdawiseman@gmail.com> - 2016-03-25 10:41 -0700
Re: save ... restore? setglobal? luser- -droog <mijoryx@yahoo.com> - 2016-03-25 11:16 -0700
Re: save ... restore? setglobal? jdaw1 <jdawiseman@gmail.com> - 2016-03-25 11:41 -0700
Re: save ... restore? setglobal? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-02 02:38 -0700
Re: save ... restore? setglobal? luser- -droog <mijoryx@yahoo.com> - 2016-06-02 16:08 -0700
Re: save ... restore? setglobal? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2016-03-26 12:07 -0600
Re: save ... restore? setglobal? Markus Triska <triska@metalevel.at> - 2016-03-26 09:12 +0100
Re: save ... restore? setglobal? jdaw1 <jdawiseman@gmail.com> - 2016-03-26 06:37 -0700
Re: save ... restore? setglobal? Markus Triska <triska@metalevel.at> - 2016-03-27 14:51 +0200
Re: save ... restore? setglobal? sjprouty3765@gmail.com - 2016-03-28 12:40 -0700
csiph-web