[comp.lang.postscript] seeing dictionary names

woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) (03/17/90)

Recently a program that I have has started showing some odd behavior.
After printing many dozens of pages, it reports  dictfull.  
we modified the erhandlr to find out the length of the dictionary on top
of the stack.  The maximum length turns out to be 180.  The programs
dictionaries are 196 and 80.  Exactly how can you extract the name of
the dictinary from the  dstackarray, or for that matter, any dictionary
that is on the dictionary stack.  Typically, you get --dictionary--.
So far, the only 2 ways that I have found to identify the dictionary
is to find the maxlength and current length, or extract say the first
2 or 3 entries with the get  statement or whatever.  Looking at them
can give you a clue as to which dictionary it is, but is there a way
to link the dictionary with the one on the stack, such that you can
get the name?  Dumping a procedure, that invokes a dictionary also shows
--dictionary--  rather than anything that is meaningful.  I know that I
could arrange to embed the name of the dictionary within the dictionary
by creating a text representation of the name as the 0th element in the
dictionary, but is there a clean, known way to find it?

Cheers
Woody

rsilverman@eagle.wesleyan.edu (03/18/90)

In article <1085@chinacat.Lonestar.ORG>, woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) writes:

> Exactly how can you extract the name of
> the dictinary from the  dstackarray, or for that matter, any dictionary
> that is on the dictionary stack.  Typically, you get --dictionary--.
> ...is there a clean, known way to find it?

Woody,

The problem is, there is no "it" to find.  A dictionary is an object; it has a
size, keys, associated values, etc...but no name, intrinsically.  A dictionary
only has a name inasmuch as someone may happen to have bound a reference to it
to a name in a dictionary somewhere.  There might be several such "names," or
none at all.  If all you've got is the dictionary object itself, all you can do
is compare it to other dictionary objects bound elsewhere to names, and see if
you can find one of its "names," or just recognize it by its contents ("oh, of
course, this is userdict!").

                                                Richard Silverman

arpa:	rsilverman@eagle.wesleyan.edu           Systems Engineer
bitnet:	rsilverman@wesleyan.bitnet              AM Computer Products
CIS:	[72727,453]                             Southington, CT 06489

kevin@kosman.UUCP (Kevin O'Gorman) (03/19/90)

In article <12063@eagle.wesleyan.edu> rsilverman@eagle.wesleyan.edu writes:
>In article <1085@chinacat.Lonestar.ORG>, woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) writes:
>
>> Exactly how can you extract the name of
>> the dictinary from the  dstackarray, or for that matter, any dictionary
>> that is on the dictionary stack.  Typically, you get --dictionary--.
>> ...is there a clean, known way to find it?
>
>The problem is, there is no "it" to find.  A dictionary is an object; it has a
>size, keys, associated values, etc...but no name, intrinsically.  A dictionary
>only has a name inasmuch as someone may happen to have bound a reference to it
>to a name in a dictionary somewhere.  There might be several such "names," or
>none at all.  If all you've got is the dictionary object itself, all you can do
>is compare it to other dictionary objects bound elsewhere to names, and see if
>you can find one of its "names," or just recognize it by its contents ("oh, of
>course, this is userdict!").

rsilverman's answer is correct as far as it goes, but if you set aside
theoretical purity, there are some things to consider.  As a practical
matter, there are very few occasions when you would encounter the same
dictionary object under different names.  There is an approach used by
LaserTalk that I just encountered that seems to work pretty well for
supporting their "Dictionary Browse" feature.

They build a dictionary (ND, I think) in userdict.  Its keys are dictionaries,
and its objects are names -- yes, just the reverse of what you usually see.
Then it has some recursive procedures to browse dictstack and find all
dictionaries and file them in ND with the name under which they were first
found.  It's careful enough to stop recursion on a previously-found dictionary,
which is good because some dictionaries contain themselves.

LaserTalk seems to use this to report the names of the dictionaries it
encounters in several contexts.
-- 
Kevin O'Gorman ( kevin@kosman.UUCP, kevin%kosman.uucp@nrc.com )
voice: 805-984-8042 Vital Computer Systems, 5115 Beachcomber, Oxnard, CA  93035
Non-Disclaimer: my boss is me, and he stands behind everything I say.

woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) (03/19/90)

In article <1085@chinacat.Lonestar.ORG>, woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) writes:
> 
> Recently a program that I have has started showing some odd behavior.
> After printing many dozens of pages, it reports  dictfull.  
> we modified the erhandlr to find out the length of the dictionary on top
> of the stack.  The maximum length turns out to be 180.  The programs
> dictionaries are 196 and 80.  Exactly how can you extract the name of
> 
> Cheers
> Woody

We found the problem.  The clients code was not maintaining variables
in it's own dictionary.  It was filling up userdict.  BUT...Maxlength
reports 180 entries for userdict, the documentation says 200.  I have
not found any mention of the fact that there are apparently 20 entries
that are reserved.  When a dictionary is documented as holding 200 entries,
maxlength should return 200......

> 
> 

jeynes@adobe.COM (Ross A. Jeynes) (03/19/90)

In article <1093@chinacat.Lonestar.ORG> woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) writes:
>in it's own dictionary.  It was filling up userdict.  BUT...Maxlength
>reports 180 entries for userdict, the documentation says 200.  I have
>not found any mention of the fact that there are apparently 20 entries
>that are reserved.  When a dictionary is documented as holding 200 entries,
>maxlength should return 200......

Whose documentation says that userdict has 200 entries?  This is an 
implementation dependent limit.  If your program is making a lot of 
definitions, you should either use maxlength to find out how many entries 
there really are available, or create your own dictionary, since someone 
could have downloaded something outside the server loop that took up some 
slots.

If it's the manufacturer's documentation that specifies 200 entries for 
userdict and maxlength is returning 180, send them a bug report.  (Or send
me a bug report and I'll forward it to QA.)  

If it is the Red Book that you are citing, please realize that the limits 
listed in Appendix B are _typical_ implementation limits, and not values
that are set in Stone (so to speak) for every printer.


Ross Jeynes              
Developer Support                                           jeynes@adobe.com
Adobe Systems Incorporated                         {sun|decwrl}!adobe!jeynes

woody@chinacat.Unicom.COM (Woody Baker @ Eagle Signal) (03/19/90)

In article <1997@adobe.UUCP>, jeynes@adobe.COM (Ross A. Jeynes) writes:
> In article <1093@chinacat.Lonestar.ORG> woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) writes:
> 
> If it's the manufacturer's documentation that specifies 200 entries for 
> userdict and maxlength is returning 180, send them a bug report.  (Or send
> me a bug report and I'll forward it to QA.)  

My printer suppliment doesnot say.  I don't know about the NEC 890.  I
have recommended to the client that he create a dictionary for his variables
and he has done so.  The info in the red book, is basically all most people
have to go on, apparently most manufacturers do not mention the limits.
Inside PostScript (from Systems of Merrit) gives a length of 200 for the
Qms version 38.  The client saw that, and saw the same info in the red
book, and when the length didn't match, decided it wasn't userdict.
H
Thanks for the information.  

Cheers
Woody

> that are set in Stone (so to speak) for every printer.

ARRRRGGGGGHHHH!  This one requires a dump truck and a front end loader....

hemphill@cit-vax.Caltech.Edu (Scott Hemphill) (03/20/90)

In article <1085@chinacat.Lonestar.ORG> woody@chinacat.Lonestar.ORG (Woody Baker @ Eagle Signal) writes:
>
>could arrange to embed the name of the dictionary within the dictionary
>by creating a text representation of the name as the 0th element in the
>dictionary, but is there a clean, known way to find it?
>

Yes, there is.  To prepare things, create a dictionary which I will name
"dictdict".  Since PostScript lets you use any object as a key (except -null-)
you can use actual dictionaries as keys, with the name of the dictionary as
the corresponding value.  After you have done this for all dictionaries of
interest, you can "lookup" the name of any of these dictionaries using "get".

If you are really ambitious, you can find all of the accessible named
dictionaries in the system by recursively scanning dictionaries, starting
with "systemdict", making sure that you don't scan a dictionary that you have
already started scanning.  You can also find dictionaries that are embedded
within procedures, and recursively scan those.
-- 
Scott Hemphill	hemphill@csvax.caltech.edu	...!ames!elroy!cit-vax!hemphill