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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Running a preprocessor from GPS? Date: Sat, 01 Aug 2015 08:20:09 +0100 Organization: A noiseless patient Spider Message-ID: References: <2df4698f-4c8e-457c-822d-209cb2f8ab5e@googlegroups.com> <014427b1-ff7a-4a69-82e6-0330af77ed96@googlegroups.com> <91f88d79-197c-419f-84a8-908e05967a2c@googlegroups.com> <135c2b00-d13c-4f5d-a586-8aca442d363b@googlegroups.com> <87380683vc.fsf@adaheads.sparre-andersen.dk> <347c6be9-c918-4bc0-9494-c93cd6740def@googlegroups.com> <4cb32c40-f659-490d-bbb6-73585fc069e8@googlegroups.com> <7e653a88-e690-431a-9df9-3fc691466e08@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="fbe1d5b0173017f7cc2ccfa8ad3bc8c1"; logging-data="10930"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+teoyGbQGssDPIAMXQd5iCggvAeXhMX2w=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:WSJ2BK6wjALBD1rz7KNxXNTvR3o= sha1:FilyuUOopBJjJ10X+SGV9gG7g7A= Xref: news.eternal-september.org comp.lang.ada:27285 Date: 2015-08-01T08:20:09+01:00 List-Id: EGarrulo writes: > On Friday, July 31, 2015 at 7:54:52 PM UTC+2, Jeffrey R. Carter wrote: >> Many of the "design patterns" are actually implementation patterns to >> work around deficiencies in the languages used in the book. An >> obvious example is the "singleton pattern". In Ada, a singleton is >> simply a pkg. It's only a problem that needs a pattern in languages >> that lack modules. > > But a singleton would be instantiated when the "Get_Instance" function > gets called by client code, not when a module gets loaded. Or does > Ada load a package at the first call? According to Wikipedia, a singleton "is useful when exactly one object is needed to coordinate actions across the system". And encapsulating that object in a package meets that criterion. Isn't a Get_Instance function a way of getting the desired effect in C++ etc, rather than a necessary detail of the pattern? I can see that it allows you to postpone creating the singleton instance until a time of your choosing, rather than the Ada way of doing it during package elaboration in a sequence chosen by the compilation/build engine. With regard to Carter's point about "instantiation", it's a term that Ada has specialised to mean creating an instance of a generic. I don't know if there's an Ada term that means creating an object that is an instance of a type? I could suggest "reification" :-) but I doubt that would fly.