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


Groups > comp.lang.postscript > #3198 > unrolled thread

bind’ing loops

Started byjdaw1 <jdawiseman@gmail.com>
First post2017-11-20 04:26 -0800
Last post2017-11-21 16:39 -0800
Articles 3 — 3 participants

Back to article view | Back to comp.lang.postscript


Contents

  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

#3198 — bind’ing loops

Fromjdaw1 <jdawiseman@gmail.com>
Date2017-11-20 04:26 -0800
Subjectbind’ing loops
Message-ID<0a457d13-e123-42e2-9a2f-f1801af3db2c@googlegroups.com>
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

?

[toc] | [next] | [standalone]


#3199

FromCarlos <carlos@cvkm.cz>
Date2017-11-21 21:34 +0100
Message-ID<20171121213455.423a2bee@samara.DOMA>
In reply to#3198
[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).
-- 

[toc] | [prev] | [next] | [standalone]


#3200

Fromluser droog <luser.droog@gmail.com>
Date2017-11-21 16:39 -0800
Message-ID<352c2d0c-e2f6-4b2e-9194-036a234b41a1@googlegroups.com>
In reply to#3199
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web