🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #1672

Re: seeing dictionary names

#1672
From: Kevin O'Gorman
Date: Sun, 18 Mar 1990 16:10
37 lines
2717 bytes
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.
Technical Details
Message-ID: <1141@kosman.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!srhqla!nrcvax!kosman!kevin
References: <7986@sdcsvax.UCSD.Edu> <3295@hcx1.SSD.CSD.HARRIS.COM> <1085@chinacat.Lonestar.ORG> <12063@eagle.wesleyan.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!srhqla!nrcvax!kosman!kevin
From: kevin@kosman.UUCP (Kevin O'Gorman)
Newsgroups: comp.lang.postscript
Subject: Re: seeing dictionary names
Message-ID: <1141@kosman.UUCP>
Date: 18 Mar 90 16:10:25 GMT
References: <7986@sdcsvax.UCSD.Edu> <3295@hcx1.SSD.CSD.HARRIS.COM> <1085@chinacat.Lonestar.ORG> <12063@eagle.wesleyan.edu>
Distribution: na
Organization: K.O.'s Manor - Vital Computer Systems, Oxnard, CA 93035
Lines: 37