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!feeder.eternal-september.org!news.albasani.net!.POSTED!not-for-mail From: Dirk Heinrichs Newsgroups: comp.lang.ada Subject: Re: Generics crash course Date: Fri, 16 Jan 2015 06:33:15 +0100 Organization: Privat Message-ID: References: <121014ba-309c-45a0-950a-20b5b15210c5@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.albasani.net 376wwlU3YA21y0iB8hdrrc/K4MaI5BNqUhM7yBVqi3W06gos3dejHmkdiwbgs4eZed3OmfIrBR1OmRnEcKNCPxhY1rvANCyzcLxt4mvOiOYK0fvw2ZZAgllEHY+BmIiG NNTP-Posting-Date: Fri, 16 Jan 2015 05:33:17 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="5N8c4wASnIJHgHlo+lRQS0TZlNG6QwDIJJehlTg1HjdJk9klWx8ohOS57BWQ99cmOn6eS5BpMP2rg3pun1J9JqynYqE4q4W9UGbB9Ua0LC2HwSFgaowtJYxRoAnGLpdD"; mail-complaints-to="abuse@albasani.net" User-Agent: KNode/4.14.1 Cancel-Lock: sha1:0Nns9IsE4/IvZXz0f/mMpbUlMxA= Xref: news.eternal-september.org comp.lang.ada:24590 Date: 2015-01-16T06:33:15+01:00 List-Id: John Smith wrote: > I'm going through the wikibook about Ada. It has this example when it > comes to generics: > http://wikibook-ada.sourceforge.net/html/Algorithms__binary_search__adb.htm > > What I don't understand is from lines 12 to 21. How does this work > exactly? I mean, does this somehow "connect" the overloaded < operator to > the Search procedure? These lines define the generic formal parameters. The important line here, when it comes to "<", is 21. The box operator "<>" here means that this subprogram will be instantiated with one that is visible and matches the specification. Since the example uses Float for Element_Type (see lines 73 - 76), its "<" function is used automatically. See http://en.wikibooks.org/wiki/Ada_Programming/Generics#Generic_formal_subprograms > Also, on line 53, if this code is ever reached, then this means that the > entire application will stop executing, yes? The procedure won't just > return to the caller. No. It will just exit the surrounding loop. HTH... Dirk -- Dirk Heinrichs Tel: +49 (0)2471 209385 | Mobil: +49 (0)176 34473913 GPG Public Key CB614542 | Jabber: dirk.heinrichs@altum.de Tox: heini@toxme.se Sichere Internetkommunikation: http://www.retroshare.org Privacy Handbuch: https://www.privacy-handbuch.de