Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1616 > unrolled thread
| Started by | anavi8r@gmail.com |
|---|---|
| First post | 2013-09-11 09:16 -0700 |
| Last post | 2013-09-18 10:11 -0700 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.postscript
Unbalanced [ anavi8r@gmail.com - 2013-09-11 09:16 -0700
Re: Unbalanced [ Mark Carroll <mtbc@bcs.org> - 2013-09-11 17:28 +0100
Re: Unbalanced [ Helge Blischke <h.blischke@acm.org> - 2013-09-11 18:34 +0200
Re: Unbalanced [ luser- -droog <mijoryx@yahoo.com> - 2013-09-11 12:16 -0700
Re: Unbalanced [ Helge Blischke <h.blischke@acm.org> - 2013-09-12 11:31 +0200
Re: Unbalanced [ anavi8r@gmail.com - 2013-09-18 10:11 -0700
| From | anavi8r@gmail.com |
|---|---|
| Date | 2013-09-11 09:16 -0700 |
| Subject | Unbalanced [ |
| Message-ID | <86272e7d-88ce-4adb-ba92-3424ec5e89ca@googlegroups.com> |
Hi everyone,
I am writing a PostScript interpreter for a product I sell, and while working with some sample .EPS files, I ran into the following:
/xpdfm
{
{
dup 0 get/Label eq
{
aload length[exch 1 add 1 roll/PAGELABEL
}{
aload pop
[{ThisPage}<<5 -2 roll>>/PUT
}ifelse
pdfmark_5
}forall
This code snippet contains two unbalanced opening square brackets ([).
Is this normal? How should this be treated by a PostScript interpreter?
Thanks in advance.
-- Peter
[toc] | [next] | [standalone]
| From | Mark Carroll <mtbc@bcs.org> |
|---|---|
| Date | 2013-09-11 17:28 +0100 |
| Message-ID | <87li33xqzn.fsf@ixod.org> |
| In reply to | #1616 |
anavi8r@gmail.com writes: > Is this normal? How should this be treated by a PostScript interpreter? [ just pushes a mark onto the stack. I guess that procedures that look back on the stack for the mark might find it useful, like counttomark. ] looks back for the mark to pop the elements for putting into an array. All marks are the same, they're usually used as a delimiter for the end of a list for consumption by something else. -- Mark
[toc] | [prev] | [next] | [standalone]
| From | Helge Blischke <h.blischke@acm.org> |
|---|---|
| Date | 2013-09-11 18:34 +0200 |
| Message-ID | <b9bkc0F7evuU1@mid.individual.net> |
| In reply to | #1616 |
anavi8r@gmail.com wrote:
> Hi everyone,
>
> I am writing a PostScript interpreter for a product I sell, and while
> working with some sample .EPS files, I ran into the following:
>
> /xpdfm
> {
> {
> dup 0 get/Label eq
> {
> aload length[exch 1 add 1 roll/PAGELABEL
> }{
> aload pop
> [{ThisPage}<<5 -2 roll>>/PUT
> }ifelse
> pdfmark_5
> }forall
>
>
> This code snippet contains two unbalanced opening square brackets ([).
>
> Is this normal? How should this be treated by a PostScript interpreter?
>
> Thanks in advance.
>
> -- Peter
The "[" is a synonym for the "mark" operator. Its purpose is
to process the following objects on the operand stack back
up to the mark (and removing the mark object) without the necessity
to know how many objects to process.
See e.g. the cleartomark operator from the PLRM as a simple
example, or the array operator.
Helge
[toc] | [prev] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2013-09-11 12:16 -0700 |
| Message-ID | <d131f9d1-0bd3-4bfe-98fd-6a3ab6cc7ff7@googlegroups.com> |
| In reply to | #1616 |
On Wednesday, September 11, 2013 11:16:13 AM UTC-5, ana...@gmail.com wrote:
> Hi everyone,
>
> I am writing a PostScript interpreter for a product I sell, and while working with some sample .EPS files, I ran into the following:
>
> /xpdfm
> {
> {
> dup 0 get/Label eq
> {
> aload length[exch 1 add 1 roll/PAGELABEL
> }{
> aload pop
> [{ThisPage}<<5 -2 roll>>/PUT
> }ifelse
> pdfmark_5
> }forall
>
>
> This code snippet contains two unbalanced opening square brackets ([).
>
> Is this normal? How should this be treated by a PostScript interpreter?
>
> Thanks in advance.
>
As others have said, the left bracket [ is defined in systemdict as a
marktype object (same as the name /mark). Since only one of the procedure-
bodies passed to ifelse will be executed, there is really only one mark
without a matching right bracket ]. This style is used in much the same
way as a vararg function in C, to pass an open-ended set of values,
presumably to pdfmark_5. I'm not familiar with the '_5' part, but pdfmark
is used to pass data into a generated pdf file.
If your output device is not a pdf-writer, you can probably safely
define
/pdfmark { cleartomark } def
By the way, the << is also a mark, so you will sometimes see [ used instead.
[ /this (is) /a (dictionary) >>
[toc] | [prev] | [next] | [standalone]
| From | Helge Blischke <h.blischke@acm.org> |
|---|---|
| Date | 2013-09-12 11:31 +0200 |
| Message-ID | <b9dfv4Fith5U1@mid.individual.net> |
| In reply to | #1619 |
luser- -droog wrote:
> On Wednesday, September 11, 2013 11:16:13 AM UTC-5, ana...@gmail.com
> wrote:
>> Hi everyone,
>>
>> I am writing a PostScript interpreter for a product I sell, and while
>> working with some sample .EPS files, I ran into the following:
>>
>> /xpdfm
>> {
>> {
>> dup 0 get/Label eq
>> {
>> aload length[exch 1 add 1 roll/PAGELABEL
>> }{
>> aload pop
>> [{ThisPage}<<5 -2 roll>>/PUT
>> }ifelse
>> pdfmark_5
>> }forall
>>
>>
>> This code snippet contains two unbalanced opening square brackets ([).
>>
>> Is this normal? How should this be treated by a PostScript interpreter?
>>
>> Thanks in advance.
>>
>
> As others have said, the left bracket [ is defined in systemdict as a
> marktype object (same as the name /mark). Since only one of the procedure-
> bodies passed to ifelse will be executed, there is really only one mark
> without a matching right bracket ]. This style is used in much the same
> way as a vararg function in C, to pass an open-ended set of values,
> presumably to pdfmark_5. I'm not familiar with the '_5' part, but pdfmark
> is used to pass data into a generated pdf file.
>
> If your output device is not a pdf-writer, you can probably safely
> define
>
> /pdfmark { cleartomark } def
>
> By the way, the << is also a mark, so you will sometimes see [ used
> instead.
>
> [ /this (is) /a (dictionary) >>
The ample snippet is from the prolog section Acrobat
(Adobe Reader as well) generates when printing to PostScript printers,
and /pdfmark_5 is there defined like:
/currentdistillerparams where{pop currentdistillerparams/CoreDistVersion get 5000 lt}{true}ifelse
{
/pdfmark_5{cleartomark}bind def
}{
/pdfmark_5{pdfmark}bind def
}ifelse
Helge
[toc] | [prev] | [next] | [standalone]
| From | anavi8r@gmail.com |
|---|---|
| Date | 2013-09-18 10:11 -0700 |
| Message-ID | <b1b70aec-0245-4008-a486-abe345e7df07@googlegroups.com> |
| In reply to | #1620 |
Thanks a lot to everyone who replied! Your insight made my realize that my original design was all wrong :-)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web