POV-Ray : Newsgroups : povray.off-topic : Really strange design choices : Really strange design choices Server Time
6 Sep 2024 13:16:32 EDT (-0400)
  Really strange design choices  
From: Invisible
Date: 17 Dec 2008 06:07:26
Message: <4948dd6e$1@news.povray.org>
OK, so I'm sitting here reading the PostScript Language Reference Manual 
(3rd edition).

PostScript seems like a simple enough language. But when you sit down to 
try to *implement* it rather than just *use* it... you discover that 
there are a few simple little statements in the spec that make it really 
quite awkward.

For example, PostScript involves "dictionaries". A dictionary stores 
key/value pairs. The key will usually be a "name" object. However, 
reading the small-print, I discover that a key can *actually* be any 
possible PostScript object.

So, for example, you can push the current graphics state onto the 
operand stack and use THE ENTIRE GRAPHICS STATE as a key! o_O

In other small-print, I discover that "composite" objects are explicitly 
mutable. If you "copy" such an object, it merely copies the reference to 
it. If you mutate the copy object, the original object sees the change 
too. Fair enough...

...except, wait a sec. So you're telling me I can MUTATE DICTIONARY KEYS??

This is highly interesting, since the keys of a dictionary must, by 
definition, be unique. If you insert a key into the dictionary, it 
checks to see if such a key already exists. If so, that key's value is 
replaced, otherwise the inserted value becomes a new entry.

But wait! I can insert a new key, and then mutate it to match one of the 
existing keys. How does *that* work?? Do we now have a dictionary with 
two identical keys? Or does one of the keys get deleted? (Which requires 
monitoring every single object mutation to check whether it's a key 
somewhere.) Or...??

Of course, 99% of all PostScript code actually uses names as keys, so 
all of this is a complete non-issue. But theoreticaly 1% of the code out 
there might actually try to use a font description as a key, and if the 
interpretter is going to work properly, it has to support this. *sigh*

Other amusing edge cases include "/":

- A name is usually executable; by preceeding it with "/", it becomes 
literal.

- The toke "/" by itself (i.e., not preceeding a name) is a valid 
(executable) name.

Trixy Hobbitses!


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.