comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Ada202X : Adding functors
Date: Tue, 13 Nov 2012 16:51:03 -0800 (PST)
Date: 2012-11-13T16:51:03-08:00	[thread overview]
Message-ID: <094f94ed-dbcc-4dba-bd9d-894a75f69037@googlegroups.com> (raw)
In-Reply-To: <57bca956-2348-4825-8f5f-04fb91863696@googlegroups.com>

On Tuesday, November 13, 2012 3:11:57 AM UTC-8, Martin wrote:

> 
> But Adam - that's cool cat is already out the bag!

Well, that's a compelling reason to add a major new language feature.

Not.

> E.g.
>  
> with Ada.Text_IO; use Ada.Text_IO;
> with Project;     use Project;
> with Matrix_3x3s; use Matrix_3x3s;
> with Vector_3s;   use Vector_3s;
> procedure Test is
>    procedure Display (X : Real) is
>    begin
>       Put_Line (Real'Image (X));
>    end Display;
>    V : Vector_3 := Create (X => 12.34,
>                            Y => 123.4,
>                            Z => 1234.0);
>    M : Matrix_3x3 := (Create (X => V,
>                               Y => V * 2.0,
>                               Z => V * 4.0));
> begin
>    V (1) := 1.0;
>    Display (V (1));
>    Display (V (2));
>    Display (V (3));
>    M (1, 1) := 20.0;
>    Display (M (1, 1));
> end Test;
> 
> V and M used as-if they were functions

Umm, no, since you can't have a function call (by itself) on the left side of an assignment.  They're being used as arrays, not as functions.  And I think that's probably one of the reasons Constant_Indexing and Variable_Indexing were added; there wasn't any good way to declare an object that wasn't actually an array but that you wanted to be able to use like an array, where you could define an indexing operation that would produce a *variable* that could be used on the left side of an assignment (or in other situations where a variable was required).  Also, I think it was related to some new features allowing iteration over a container.  I'm really not clear on the details of why this feature was added--I'm mostly just guessing--but the AI involved does mention a desire to avoid syntactic awkwardness and a lot of extra text.  And I don't see anything in your example (the one in your original post) where there's any awkwardness that needs to be avoided.  The workaround I posted involves just adding one more identifier, and in my opinion adding this would make things clearer to the reader, while the syntax you're proposing is, I think, likely to make things more confusing.

There may be other, more complex cases, though, where this would be a useful feature.  I haven't yet followed the link Georg posted, but I'm going to; maybe there are some examples there that would make it clearer why a feature would be worthwhile in Ada.  So far I haven't seen anything like that in the examples here.

                              -- Adam



  reply	other threads:[~2012-11-14  0:51 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-12 22:09 Ada202X : Adding functors Martin
2012-11-12 23:14 ` Jeffrey Carter
2012-11-12 23:19   ` Martin
2012-11-13 10:45     ` Georg Bauhaus
2012-11-13 12:08       ` Yannick Duchêne (Hibou57)
2012-11-13 12:35       ` Martin
2012-11-12 23:44 ` Adam Beneschan
2012-11-13  2:11   ` Jeffrey Carter
2012-11-13 11:11   ` Martin
2012-11-14  0:51     ` Adam Beneschan [this message]
2012-11-14  8:39       ` Martin
2012-11-14 16:54         ` Adam Beneschan
2012-11-14 18:54           ` Martin
2012-11-14 20:37           ` Dmitry A. Kazakov
2012-11-14 20:57             ` Shark8
2012-11-14 21:31             ` Martin
2012-11-14 22:42               ` Adam Beneschan
2012-11-15  9:27               ` Dmitry A. Kazakov
2012-11-14 21:45             ` Simon Wright
2012-11-14 22:22               ` Martin
2012-11-14 22:27               ` Martin
2012-11-13  4:22 ` Shark8
2012-11-15  0:20 ` sbelmont700
2012-11-15  7:12   ` Martin
2012-11-15 12:21     ` Georg Bauhaus
2012-11-15 12:31     ` Georg Bauhaus
2012-11-15 12:46       ` Martin
2012-11-16  6:15       ` Randy Brukardt
2012-11-15 10:11   ` Dmitry A. Kazakov
2012-11-15 15:52     ` Peter C. Chapin
2012-11-15 17:04       ` Dmitry A. Kazakov
2012-11-15 19:57         ` Georg Bauhaus
2012-11-15 20:39           ` Dmitry A. Kazakov
2012-11-16  0:15             ` Peter C. Chapin
2012-11-16 10:12               ` Georg Bauhaus
2012-11-16  0:01         ` Peter C. Chapin
2012-11-16  6:09           ` Randy Brukardt
2012-11-16 12:35             ` Peter C. Chapin
2012-11-16 18:10               ` Martin
2012-11-16  8:59           ` Dmitry A. Kazakov
2012-11-16 12:20             ` Peter C. Chapin
2012-11-16 17:44               ` Dmitry A. Kazakov
2012-11-18 15:58                 ` Peter C. Chapin
2012-11-15 21:34     ` sbelmont700
replies disabled

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