From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!news.alt.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.112.MISMATCH!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: What is your opinion on Global Objects? References: <8561e9omp7.fsf@stephe-leake.org> <65f2470c-0828-4f97-9f0e-f11966896c06@googlegroups.com> Date: Fri, 21 Nov 2014 09:25:18 -0600 Message-ID: <85lhn4shi9.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.94 (windows-nt) Cancel-Lock: sha1:aaVHYXQQ7WQKLDDE96HbEetg6hg= MIME-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 91584546f5960e3fb833009493 X-Received-Bytes: 2585 X-Received-Body-CRC: 1186497445 Xref: number.nntp.giganews.com comp.lang.ada:190911 Date: 2014-11-21T09:25:18-06:00 List-Id: Adam Beneschan writes: > On Thursday, November 20, 2014 8:34:31 AM UTC-8, Stephen Leake wrote: >> >> > That basically is a vote for global objects. Whether they are accessed >> > through a global variable or some sort of getter function that returns >> > access, it means bypassing the parameters. Well from what I read here, >> > there are no strong opinions for either concept. Strange, I wasn't >> > able to find good arguments for or against the two concepts anywhere, >> >> If you can really, truly, absolutely guarrantee that you will _never_ >> need two different copies of the data structure, then the singleton >> pattern makes sense (data in a single variable in a package body). >> >> If you ever need two different copies of the data structure, then you >> need to pass it around in parameters. >> >> The symbol table for a compiler is a good candidate for a singleton. > > This doesn't seem right to me. > > I haven't followed the whole discussion closely, so I might have > missed something... But in the case of a symbol table, an Ada compiler > that implements generics by "macro instantiation" is an example of why > a symbol table should *not* be a singleton. If the compiler rescans > the text of the generic, the entire context (i.e. what symbols are > visible) That's not the _entire_ symbol table, just one subtree. I've never implemented a compiler, but I have implemented an interpreter; it has a singleton symbol table. I imagine "context" is a pointer into the symbol table, showing what is visible at the current code position. It certainly depends on how the compiler uses the symbol table. -- -- Stephe