From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Discriminated records are not the most efficient, but ...
Date: Mon, 23 Aug 2010 07:14:08 +0200
Date: 2010-08-23T07:14:08+02:00 [thread overview]
Message-ID: <op.vhvktu1kule2fv@garhos> (raw)
In-Reply-To: op.vhvbhchkule2fv@garhos
Le Mon, 23 Aug 2010 03:52:14 +0200, Yannick Duchêne (Hibou57)
<yannick_duchene@yahoo.fr> a écrit:
> Now I've just seen about Structures and Functors (you seems to know ML,
> do you ?), and we could say “Ada's functors” 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 place
of that formal parameter.
In ML : a functor has the following signature: “structure -> structure”.
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 exactly
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
“package Name” and “end Name;”. [*]
Application of an ML functor = Ada generic instantiation
Definition of an ML functor = Ada generic body
Definition of an ML signature = 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 Ada
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 the
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
next prev parent reply other threads:[~2010-08-23 5:14 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-21 21:18 Discriminated records are not the most efficient, but Yannick Duchêne (Hibou57)
2010-08-21 21:57 ` Yannick Duchêne (Hibou57)
2010-08-22 5:39 ` Yannick Duchêne (Hibou57)
2010-08-22 20:40 ` Yannick Duchêne (Hibou57)
2010-08-22 20:47 ` Florian Weimer
2010-08-22 22:07 ` Yannick Duchêne (Hibou57)
2010-08-22 22:11 ` Yannick Duchêne (Hibou57)
2010-08-23 3:06 ` Peter C. Chapin
2010-08-23 3:50 ` Yannick Duchêne (Hibou57)
2010-08-23 6:25 ` J-P. Rosen
2010-08-23 8:09 ` Yannick Duchêne (Hibou57)
2010-08-23 6:40 ` Niklas Holsti
2010-08-23 7:33 ` Simon Wright
2010-08-23 11:44 ` Martin
2010-08-23 13:16 ` Georg Bauhaus
2010-08-23 13:32 ` Martin
2010-08-23 17:02 ` Yannick Duchêne (Hibou57)
2010-08-23 8:13 ` Yannick Duchêne (Hibou57)
2010-08-23 1:52 ` Yannick Duchêne (Hibou57)
2010-08-23 5:14 ` Yannick Duchêne (Hibou57) [this message]
2010-08-23 5:43 ` Florian Weimer
2010-08-23 7:55 ` Yannick Duchêne (Hibou57)
2010-08-23 8:06 ` Dmitry A. Kazakov
2010-08-23 8:26 ` Yannick Duchêne (Hibou57)
2010-08-23 8:43 ` Dmitry A. Kazakov
2010-09-04 18:49 ` Florian Weimer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox