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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6689542a60dbcc55 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Discriminated records are not the most efficient, but ... Date: Mon, 23 Aug 2010 07:14:08 +0200 Organization: Ada At Home Message-ID: References: <874oemcr37.fsf@mid.deneb.enyo.de> NNTP-Posting-Host: qaSBlvV+1zCl6PWY+jYb4w.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.61 (Win32) Xref: g2news1.google.com comp.lang.ada:13644 Date: 2010-08-23T07:14:08+02:00 List-Id: Le Mon, 23 Aug 2010 03:52:14 +0200, Yannick Duch=C3=AAne (Hibou57) = a =C3=A9crit: > Now I've just seen about Structures and Functors (you seems to know ML= , = > do you ?), and we could say =E2=80=9CAda's functors=E2=80=9D can only = get functors as = > parameter, not structures. I need to correct something or else what I wrote will be confusing and = incomplete. In Ada : formal parameters may refer to a generic package. However, = instantiation of such a package will requires a package instance in plac= e = of that formal parameter. In ML : a functor has the following signature: =E2=80=9Cstructure -> str= ucture=E2=80=9D. = So at first sight, this may seems ML functors cannot model Ada packages.= = But as a functor takes a structure to return a structure, this is exactl= y = the same as with an Ada generic instantiation. As in ML a functor cannot= = create a structure signature and can only create a structure matching a = = structure signature, finally, application of an ML functor exactly match= = the process of instantiating an Ada generic. Conclusion: the Ada package system can be properly modeled with ML. Note: in ML, the parameters appears only at the functor definition, not = in = the signature, thus, the signature match Ada's package specification, = *excluding the formal part* ; thus is correspond to what is between the = = =E2=80=9Cpackage Name=E2=80=9D and =E2=80=9Cend Name;=E2=80=9D. [*] Application of an ML functor =3D Ada generic instantiation Definition of an ML functor =3D Ada generic body Definition of an ML signature =3D Ada specification of a package or = = generic package (formal part excluded) And a one way equivalence Ada generic specification is the same as ML signature + ML functor's= = signature. That is fun, we may be able to model the Ada language :) This is a new = view on Ada, I like that. There was first the LRM, later there was Ada = Semantic Interface Specification (ASIS), now I get the beginning of an A= da = model in a formal language. [*] With that in mind, the choice made for Ada to have the formal part = preceding the package name, seems less strange! For the requirement of = static checking on public interface, Ada simply required to have both = signature (structure and functor) at one place and the choice to have th= e = formal part preceding the generic package name, simply make these still = = clearly separated, while both at the same place. Clever syntactic choice= = they made! CheckMe: is there is a way to have a functor signature in ML ? -- = * 3 lines of concise statements is readable, 10 pages of concise = statements is unreadable ; * 3 lines of verbose statements may looks unuseful, 10 pages of verbose = = statements will never looks too much pedantic