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: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: How To Pass Large Object Arguments Date: Sun, 24 Nov 2013 12:12:46 +0100 Organization: A noiseless patient Spider Message-ID: <87k3fyf3yp.fsf@ludovic-brenta.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="e490d00bfa90af0ff7a4df43d7a4a177"; logging-data="8180"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/c2Ys1y0VcgDHtU6vnC5c/" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:3eWX2DzqZa6mECGvwQgrqGEHWnI= sha1:nHXjUfj50wdQDSXlbo01IcFUxTQ= X-Original-Bytes: 1879 Xref: number.nntp.dca.giganews.com comp.lang.ada:183982 Date: 2013-11-24T12:12:46+01:00 List-Id: FritzVonBraun writes: > I am fairly new to Ada and I am wondering how I should pass large > parameters to subprograms like arrays or records that contain other > components like vectors or lists. You should not pass parameters by copy or by reference; this is the job of the compiler. And you should not presume to know better than the optimizer in the compiler which method is faster. So, pass parameters "in" or "in out". > I did a lot of reading but wasnt able to find a definite answer. The definitive resource is the Ada Reference Manual (i.e. the ISO standard that defines the language), which is Free, unlike for some other languages... http://www.adaic.org/resources/add_content/standards/12rm/html/RM-6-2.html GNAT normally passes arrays (including Strings) by reference but very short arrays might be passed by copy in registers, which is *faster* than by reference. HTH -- Ludovic Brenta.