comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: nice features in Ada 2012, expressions
Date: Wed, 20 Jun 2012 04:29:16 -0500
Date: 2012-06-20T04:29:16-05:00	[thread overview]
Message-ID: <jrs55d$oj0$1@speranza.aioe.org> (raw)

I was looking at Ada 2012 expressions

http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf

and I really like what I see. Ada is becoming more expressive now,
with less code, which I think is a good thing(TM).

It is getting almost as short as Matlab now (but with the strong
type build-in)

Given a matrix A, and I want to find if all elements in
the matrix are say positive, then in Matlab I would write

--------------------
B = all(A(:)>0)

In ada 2012 it is

B := (for all e of A => e>0);
--------------------

and if I want to find if there is at least one
value > 0 then in Matlab I would write

----------------------
B = any(A(:)>0)

and in Ada 2012

B := (for some e of A => e>0);
-----------------------

I think this is nice.

I am not sure yet, since I do not know much about Ada 2012,
if I can use this new iterator form if A was a standard array
variable, or if it will work only if A was a 'container' variable?

i.e. if A above was just variable of type like

        'A_type is array(integer) of float'

I hope it will work on standard arrays and not just on
collections so I can use it this form more.

I think these are the type of improvements needed in Ada to
make it more popular and more used. Real practical and
useful things.

I am looking forward for the 2012 gnat to try it out.

--Nasser



             reply	other threads:[~2012-06-20  9:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-20  9:29 Nasser M. Abbasi [this message]
2012-06-20  9:38 ` nice features in Ada 2012, expressions Pascal Obry
replies disabled

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