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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c406e0c4a6eb74ed X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: ADA Popularity Discussion Request Date: 19 Sep 2004 12:22:27 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <49dc98cf.0408110556.18ae7df@posting.google.com> <17sx057ro5jw5$.t2qlaeoxg611$.dlg@40tude.net> <1095082522.132276@master.nyc.kbcfp.com> <18ym85v67zof3$.7oqswzjfgswr.dlg@40tude.net> <1095090665.624419@master.nyc.kbcfp.com> <68zmgy3b894u.rs67cy6jjfiq$.dlg@40tude.net> <1164383.Vq7EPUUJyU@linux1.krischik.com> <2177491.OlAk1RxoCA@linux1.krischik.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1095593305 535 62.49.19.209 (19 Sep 2004 11:28:25 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 19 Sep 2004 11:28:25 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: g2news1.google.com comp.lang.ada:3840 Date: 2004-09-19T12:22:27+01:00 List-Id: Georg Bauhaus writes: > Martin Krischik wrote: > :> for constants, > :> > :> X: constant Ragged := > :> ( new String'("1"), > :> ... > :> > :> does just as well, the allocations are performed by the compiler, > :> not at run time :-) > : > : Really! I did not know that! Where does it say in the RM - or is a compiler > : dependent optimisation. > > I've found it to be true, and it looks like compatible with > "evaluation of an allocator" and elaboration (control, preelaborate?). > I don't know whether there is a sentence addressing this directly, > maybe the experts can tell? > > Both ObjectAda and GNAT do this. I don't know whether it is at > all possible to intruct ObjectAda not to "preallocate" constant > string pointers. This code package New_String is type String_P is access all String; S : constant String_P := new String'("foo!"); end New_String; with 5.02a1, x86 generates code including [...] new_string___elabs: [...] call __gnat_malloc I think you may be remembering package New_String is type String_P is access constant String; Foo : aliased constant String := "foo!"; S : constant String_P := Foo'Access; end New_String; which generates (in its entirety) with -O2 .file "new_string.ads" .globl new_string_E .data .type new_string_E,@object .size new_string_E,1 new_string_E: .byte 0 .globl new_string__foo .align 4 .type new_string__foo,@object .size new_string__foo,12 new_string__foo: .long 1 .long 4 .ascii "foo!" .globl new_string__s .align 8 .type new_string__s,@object .size new_string__s,8 new_string__s: .long new_string__foo+8 .long new_string__foo .ident "GCC: (GNU) 3.2.3" -- Simon Wright 100% Ada, no bugs.