Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

TorgoX (1933)

TorgoX
  sburkeNO@SPAMcpan.org
http://search.cpan.org/~sburke/

"Il est beau comme la retractilité des serres des oiseaux rapaces [...] et surtout, comme la rencontre fortuite sur une table de dissection d'une machine à coudre et d'un parapluie !" -- Lautréamont

Journal of TorgoX (1933)

Tuesday September 07, 2004
08:03 PM

PostScript

[ #20776 ]
Dear Log,

PostScript doodlings. Look, I'm "trusting the stack"!!!!!

/reversed {          %   array  => reversed-of-array
  dup length 0 eq {
    pop []   % and that's it

  } {  % else normal case of it being nonempty:
    % This is awful /because/ we do it all on the stack
    dup length array
    0    1     3 index length 1 sub
    {
      % Get everything in order for the "get put" pair at the end
      exch dup   3 2 roll
      dup      4 index length exch sub 1 sub
      exch     4 index exch
      get put
    } for
    exch pop
  } ifelse
} def

/proc {     % name [varnames] routine proc,    -
  exch reversed
  { _ dict begin _ {exch def} forall _ exec end }
     %  /target Oldblock [/c/b/a] Newblock
  3 1 roll
     %  /target Newblock Oldblock [/c/b/a]

  dup length 1 add 3 mul
  3 index exch
  0 exch
  put

  2 index exch
  3 exch put

  1 index exch
  6 exch put
     % name Newblock
  def
} def

All this so I can now declare procedures like this;

/subname [/x /y /z] { ... } proc

and have it expand to:

/subname {
  SomeReasonableNumber dict begin  % begin scope
    /z exch def
    /y exch def
    /x exch def
    ...
  end
} def

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.