comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex Mentis" <foo@invalid.invalid>
Subject: Re: Callback in Ada
Date: Tue, 4 Jan 2011 18:33:53 +0000 (UTC)
Date: 2011-01-04T18:33:53+00:00	[thread overview]
Message-ID: <ifvp6h$qga$1@news.eternal-september.org> (raw)
In-Reply-To: iftfko$m0h$1@munin.nbi.dk

Randy Brukardt wrote:

> "Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
> news:wcck4inqpij.fsf@shell01.TheWorld.com...  >"Alex Mentis"
> <foo@invalid.invalid> writes:
> > 
> > > I was not able to get a short test program using the code above to
> > > compile using GNAT GPL 2010 from AdaCore, even when using the Ada
> > > 2012 switches (-gnat12 and -gnat2012) and pragma (pragma
> > > Ada_2012).  The error I get makes it appear that the parser is
> > > looking for a "begin" for function Foobar.
> > > 
> > > Using the following worked, though:
> > > 
> > > function Foobar (A : Integer) return Integer is
> > > begin
> >>   return (if A > 10 then A - 5 else A);
> > > end Foobar;
> > > 
> > > What am I missing?
> > 
> > I don't remember when these features were implemented.
> > Apparently, the GPL 2010 has 'if' expressions,
> > but expression functions are more recent.
> 
> That would make sense; I didn't actually write the wording for this
> proposal until mid-October (this was my AI). That was then approved
> at the late October ARG meeting. There are an outline of the feature
> before that, but no details; it would have been tough to implement it
> usefully without those details.
> 
>                                   Randy.

Since it�s the topic of discussion, and since you wrote the proposal,
is it true that expression functions (which, in effect, appear to be
function specifications that include small expressions as the function
bodies), when supported, could appear in a package specification,
rather than in the body, or did I miss-read the information I saw
online?

In other words, from what I read, it looks like once this is supported
one could have a function Foobar in an .ads file that looks like

function Foobar (A : Integer) return Integer is (if A > 10 then A - 5
else A);

and not need a corresponding function in the .adb file.

-Alex



  parent reply	other threads:[~2011-01-04 18:33 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-27  9:47 Callback in Ada Georg Maubach
2010-11-27 10:11 ` Dmitry A. Kazakov
2010-11-27 10:22 ` Ludovic Brenta
2010-11-27 11:04   ` Vinzent Hoefler
2010-11-27 22:05   ` Maciej Sobczak
2010-11-27 10:26 ` Alex Mentis
2010-11-27 10:46 ` Vinzent Hoefler
2010-11-27 11:32 ` Georg Bauhaus
2010-11-27 21:11   ` Jeffrey Carter
2010-11-27 21:20     ` Dmitry A. Kazakov
2010-11-28 21:35       ` Maciej Sobczak
2010-11-29  8:41         ` Dmitry A. Kazakov
2010-11-29 10:12           ` Maciej Sobczak
2010-11-29 11:04             ` Dmitry A. Kazakov
2010-11-30  1:32               ` Randy Brukardt
2010-11-30  8:38                 ` Dmitry A. Kazakov
2010-11-30  9:14                 ` AdaMagica
2010-11-30 12:37                   ` Georg Bauhaus
2010-11-30 20:28                     ` Randy Brukardt
2010-11-30 20:31                   ` Randy Brukardt
2011-01-01 16:46                 ` Yannick Duchêne (Hibou57)
2011-01-02 10:14                   ` AdaMagica
2011-01-02 14:11                     ` Robert A Duff
2011-01-02 15:15                       ` AdaMagica
2011-01-02 15:28                         ` Robert A Duff
2011-01-02 15:38                       ` Alex Mentis
2011-01-02 15:44                         ` Robert A Duff
2011-01-03 21:38                           ` Randy Brukardt
2011-01-04  0:11                             ` Robert A Duff
2011-01-04 18:33                             ` Alex Mentis [this message]
2011-01-04 19:47                               ` Robert A Duff
2011-01-04 20:21                                 ` Randy Brukardt
2011-01-04 20:15                               ` Randy Brukardt
2010-11-29 15:24     ` Callback in Ada (User Data argument) Warren
2010-11-30  1:35       ` Randy Brukardt
2010-11-30 16:51         ` Warren
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox