Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3200

Re: bind’ing loops

Newsgroups comp.lang.postscript
Date 2017-11-21 16:39 -0800
References <0a457d13-e123-42e2-9a2f-f1801af3db2c@googlegroups.com> <20171121213455.423a2bee@samara.DOMA>
Message-ID <352c2d0c-e2f6-4b2e-9194-036a234b41a1@googlegroups.com> (permalink)
Subject Re: bind’ing loops
From luser droog <luser.droog@gmail.com>

Show all headers | View raw


On Tuesday, November 21, 2017 at 2:34:56 PM UTC-6, Carlos wrote:
> [jdaw1 <jdawiseman@gmail.com>, 2017-11-20 04:26]
> > Much PostScript code includes pieces resembling “/… {…} bind def”. Very
> > standard.
> > 
> > Rarely do I use “… {…} bind forall”, and likewise “… {…} bind repeat” and “…
> > … … {…} bind for”. Is this just me? Are you folks all enthusiastic bind’ers
> > of loops?
> > 
> > Let’s be specific. Would you bind: 
> > 
> > true
> > [ /showpage /setcolorspace /setcolorspace /setgray /setrgbcolor /sethsbcolor /setcmykcolor /setpattern /setcolor /image /imagemask ]
> > {load type /operatortype ne {pop //false exit} if} forall
> > 
> > ?
> 
> If I have a loop at top level, its body is almost never more complicated than
> a couple of gsave/grestore, a call to a named proc that does the work, and
> maybe a showpage. I don't bind them (but the proc that does the work is usually
> bound, and, of course, therefore also the loop bodies in it).
> --

I agree. Rarely have I seen or used bind on a proc that is fed straight
to a looping operator, with one huge exception ie. the `image` operator
which usually /is/ in mainline code rather than in a function.

But it may be considered unusual to think of `image` in the same class
as `loop` but the difference is only in its (enormously useful) side-effect.
Particularly the dictionary form of calling `image` steers away from this
view.

If the code in question is in a larger procedure body which is already
`bind`ed than its useless (and therefore wasteful) to call it again 
every time you call the function that it is a part of.

A potential use is in the dynamically generated procedure stuff I was doing,
but idiom recognition (or merely my lack of knowledge about it) appears
to bog the works there and is perhaps better avoided.

Back to comp.lang.postscript | Previous | NextPrevious in thread | Find similar


Thread

bind’ing loops jdaw1 <jdawiseman@gmail.com> - 2017-11-20 04:26 -0800
  Re: bind’ing loops Carlos <carlos@cvkm.cz> - 2017-11-21 21:34 +0100
    Re: bind’ing loops luser droog <luser.droog@gmail.com> - 2017-11-21 16:39 -0800

csiph-web