Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Enjoying the new syntax of Ada 2012

30 views
Skip to first unread message

Georg Bauhaus

unread,
Oct 14, 2011, 9:02:29 AM10/14/11
to
Having thought much about identifiers recently,
I needed to condense something into some source code.
Ada is aids a lot in obfuscating. :-)
Will SPARK have me do it better, syntax-wise?

procedure Coffee is

subtype L is Boolean;
subtype I is Integer;
subtype C is Character;

function O (o : I) return I is
(case 16 is when 16:C0FFEE: ! 2:1: => 0, when others => o);

function O (P : L := 0 = I(0.0 - 0.0)) return L is
(if 0 in 16:16: ! 2:1:-(-1) then O else O(0)=0);

function "-" (L, R: C) return C is (C'Val(C'Pos(L)-C'Pos(R)));

procedure Say (M : C) is separate;

Y : C := '*';
Z : C := 'T';
begin
loop exit when Y > '*';
declare
T: constant L :=
(case O is when 0 <=0=> 0**2:0:>0, when 1<=0=> 2**0>=1);
function O (O : C) return C
is
(if T /= (O>'*') then '_'-'^' else '-'-'-');
begin
Y := Y - O(Y);
Z := Z - O(Y);
exit when Y = '0'-'0';
end;
end loop;
Say(Z);
end Coffee;

with Ada.Text_IO;
separate (Coffee) procedure Say (M : C) is
begin
Ada.Text_IO.Put (I'Image(C'Pos(M)));
end Say;

Georg Bauhaus

unread,
Oct 14, 2011, 9:05:19 AM10/14/11
to
On 14.10.11 15:02, Georg Bauhaus wrote:

> Ada is aids a lot in obfuscating. :-)

This sounds like I need a week off ...

okellogg

unread,
Oct 14, 2011, 9:18:30 AM10/14/11
to
On 14 Okt., 15:02, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:

> Having thought much about identifiers recently,
> I needed to condense something into some source code.
> Ada is aids a lot in obfuscating. :-)
> [...]

Ouch.
You take away some of my happiness about Ada being comparatively
easier to read ;)

As a sidenote, just for the identifiers (not the operators) see also
http://okellogg.de/obfuscada.pl

-- Oliver

Jerry

unread,
Oct 14, 2011, 6:14:12 PM10/14/11
to
On Oct 14, 6:05 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
> On 14.10.11 15:02, Georg Bauhaus wrote:
>
> > Ada is aids a lot in obfuscating. :-)
>
> This sounds like I need a week off ...

Maybe you should have taken a week off before writing Coffee. ;-)
Jerry

Peter C. Chapin

unread,
Oct 15, 2011, 9:15:50 AM10/15/11
to
On 2011-10-14 09:18, okellogg wrote:

> You take away some of my happiness about Ada being comparatively
> easier to read ;)

It isn't that strange looking if you are used to a functional language
that makes an expression out of everything. One could argue that isn't
the Ada way, however, but the syntax seems fine to me.

Peter

Egil Høvik

unread,
Oct 17, 2011, 4:53:57 AM10/17/11
to
Looking at that code, I had a bit of a flashback...

https://groups.google.com/d/msg/comp.lang.ada/0vCvXkQLNn8/T04kaAUH6_EJ

:)


--
~egilhh
0 new messages