Reputation: 18577
I'm investigating the start/server loop. The Insi de Postscript book explains the /start procedure. One part of that procedure is the control loop:
...
{
//serverdict /server get exec
//serverdict begin
setstreams
setnulldevice
/execjob
load
end
exec
} loop
...
Now i'm trying to find out what /server exactly does and how it might look like (in its most simple form).
//serverdict /server get exec
This line above gets the server procedure and executes it immediately.
Now I have a server loop like this:
/server {
{ % server loop
(i'm in a server loop) print flush
(%stdin) run
}
loop
} def
but i'm stuck in an infinite loop. How and when can the server loop ever go to the next step (//serverdict begin setstreams etc...) as it is currently in an infinite loop?
Upvotes: 1
Views: 271
Reputation: 11405
In the control loop you show, the object bound to the name server
does not seem to loop the way your code does. It seems to do some initialisation and then return. The expression /execjob load
seems to run the current job. Outside of all that is a { ... } loop
expression which seems to be the server loop which you implemented.
If you want to insert your own server code into the supplied loop, you need to work with the contents of //serverdict
which your interpreter supplies. If you want to write your own server loop, it seems like you need to go out one level, and replace that entire { ... } loop
expression, and maybe //serverdict
as well.
If you want to "find out what /server exactly does and how it might look like…", how about looking at it? The moral equivalent of:
//serverdict /server get == flush
Upvotes: 1