comp.lang.ada
 help / color / mirror / Atom feed
* Invade wikipedia!
@ 2009-02-24 11:03 Jean-Pierre Rosen
  2009-02-24 13:40 ` Dmitry A. Kazakov
                   ` (4 more replies)
  0 siblings, 5 replies; 91+ messages in thread
From: Jean-Pierre Rosen @ 2009-02-24 11:03 UTC (permalink / raw)


I was musing recently through Wikipedia. There are lots of topics
related to algorithms or similar stuff that have examples, generally in
C, often with examples in some other languages for comparison.

It would be nice if the community joined forces to add Ada examples.
Nobody can do that alone, but if everyone add some examples when finding
an opportunity, we could give much more visibility to Ada.
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 11:03 Invade wikipedia! Jean-Pierre Rosen
@ 2009-02-24 13:40 ` Dmitry A. Kazakov
  2009-02-24 14:49   ` (see below)
  2009-02-24 14:50   ` Martin
  2009-02-24 14:52 ` Peter Hermann
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-24 13:40 UTC (permalink / raw)


On Tue, 24 Feb 2009 12:03:47 +0100, Jean-Pierre Rosen wrote:

> I was musing recently through Wikipedia. There are lots of topics
> related to algorithms or similar stuff that have examples, generally in
> C, often with examples in some other languages for comparison.
> 
> It would be nice if the community joined forces to add Ada examples.
> Nobody can do that alone, but if everyone add some examples when finding
> an opportunity, we could give much more visibility to Ada.

As a suggestion / addition. Rosetta Code

   http://www.rosettacode.org/wiki/Main_Page

has a big Ada penetration. In fact, Ada is second to only Pyton there. Ada
code examples can be borrowed from there.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 13:40 ` Dmitry A. Kazakov
@ 2009-02-24 14:49   ` (see below)
  2009-02-24 15:11     ` Dmitry A. Kazakov
  2009-02-24 14:50   ` Martin
  1 sibling, 1 reply; 91+ messages in thread
From: (see below) @ 2009-02-24 14:49 UTC (permalink / raw)


On 24/02/2009 13:40, in article 1tw8gryqdolal$.1osqedj9x821c.dlg@40tude.net,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:

> On Tue, 24 Feb 2009 12:03:47 +0100, Jean-Pierre Rosen wrote:
> 
>> I was musing recently through Wikipedia. There are lots of topics
>> related to algorithms or similar stuff that have examples, generally in
>> C, often with examples in some other languages for comparison.
>> 
>> It would be nice if the community joined forces to add Ada examples.
>> Nobody can do that alone, but if everyone add some examples when finding
>> an opportunity, we could give much more visibility to Ada.
> 
> As a suggestion / addition. Rosetta Code
> 
>    http://www.rosettacode.org/wiki/Main_Page
> 
> has a big Ada penetration. In fact, Ada is second to only Pyton there. Ada
> code examples can be borrowed from there.

Some of the concurrency code in Rosetta is horribly wrong (in Ada as well as
other languages).

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 13:40 ` Dmitry A. Kazakov
  2009-02-24 14:49   ` (see below)
@ 2009-02-24 14:50   ` Martin
  2009-02-24 15:16     ` Dmitry A. Kazakov
  2009-02-24 19:48     ` Hibou57 (Yannick Duchêne)
  1 sibling, 2 replies; 91+ messages in thread
From: Martin @ 2009-02-24 14:50 UTC (permalink / raw)


On Feb 24, 1:40 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Tue, 24 Feb 2009 12:03:47 +0100, Jean-Pierre Rosen wrote:
> > I was musing recently through Wikipedia. There are lots of topics
> > related to algorithms or similar stuff that have examples, generally in
> > C, often with examples in some other languages for comparison.
>
> > It would be nice if the community joined forces to add Ada examples.
> > Nobody can do that alone, but if everyone add some examples when finding
> > an opportunity, we could give much more visibility to Ada.
>
> As a suggestion / addition. Rosetta Code
>
>    http://www.rosettacode.org/wiki/Main_Page
>
> has a big Ada penetration. In fact, Ada is second to only Pyton there. Ada
> code examples can be borrowed from there.
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

Could we agree get rid of the box comments, e.g.

   ------------------
   -- Do_Something --
   ------------------

   procedure Do_Something ...;

There fine for large projects but for example on the web they just
make the code look a lot larger than it really is...and that's a turn
off - rightly or wrongly, but it is...

Cheers
-- Martin



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 11:03 Invade wikipedia! Jean-Pierre Rosen
  2009-02-24 13:40 ` Dmitry A. Kazakov
@ 2009-02-24 14:52 ` Peter Hermann
  2009-02-24 15:44 ` Georg Bauhaus
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 91+ messages in thread
From: Peter Hermann @ 2009-02-24 14:52 UTC (permalink / raw)


Jean-Pierre Rosen <rosen@adalog.fr> wrote:
> I was musing recently through Wikipedia. There are lots of topics
> related to algorithms or similar stuff that have examples, generally in
> C, often with examples in some other languages for comparison.
> 
> It would be nice if the community joined forces to add Ada examples.
> Nobody can do that alone, but if everyone add some examples when finding
> an opportunity, we could give much more visibility to Ada.

true.
maybe we should have an internal list similar to
http://www.ihr.uni-stuttgart.de/fileadmin/user_upload/autoren/ph/ada/gems.html
in order to have at least a summary of points of attack.
I could gather them even from those who do not really act
but know about links. maybe send me links with subject line [wikis for ada]?

Anyway I maintain my
http://www.ihr.uni-stuttgart.de/forschung/ada/resources_on_ada/
from time to time.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 14:49   ` (see below)
@ 2009-02-24 15:11     ` Dmitry A. Kazakov
  2009-02-24 15:22       ` (see below)
  0 siblings, 1 reply; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-24 15:11 UTC (permalink / raw)


On Tue, 24 Feb 2009 14:49:05 +0000, (see below) wrote:

> Some of the concurrency code in Rosetta is horribly wrong (in Ada as well as
> other languages).

Why not to fix it?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 14:50   ` Martin
@ 2009-02-24 15:16     ` Dmitry A. Kazakov
  2009-02-24 19:48     ` Hibou57 (Yannick Duchêne)
  1 sibling, 0 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-24 15:16 UTC (permalink / raw)


On Tue, 24 Feb 2009 06:50:30 -0800 (PST), Martin wrote:

> Could we agree get rid of the box comments, e.g.
> 
>    ------------------
>    -- Do_Something --
>    ------------------
> 
>    procedure Do_Something ...;

I fully agree with that. It reminds me FORTRAN-IV comments. Could it be
borrowed from?

C-------------------------
C     Do something
C-------------------------
 
-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:11     ` Dmitry A. Kazakov
@ 2009-02-24 15:22       ` (see below)
  2009-02-24 15:49         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 91+ messages in thread
From: (see below) @ 2009-02-24 15:22 UTC (permalink / raw)


On 24/02/2009 15:11, in article 1o0daku7d3ttb$.aqm60en944rb$.dlg@40tude.net,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:

> On Tue, 24 Feb 2009 14:49:05 +0000, (see below) wrote:
> 
>> Some of the concurrency code in Rosetta is horribly wrong (in Ada as well as
>> other languages).
> 
> Why not to fix it?

Better things to do.

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 11:03 Invade wikipedia! Jean-Pierre Rosen
  2009-02-24 13:40 ` Dmitry A. Kazakov
  2009-02-24 14:52 ` Peter Hermann
@ 2009-02-24 15:44 ` Georg Bauhaus
  2009-02-24 15:53   ` Peter Hermann
                     ` (3 more replies)
  2009-02-24 19:29 ` Martin Krischik
  2009-02-25 22:31 ` Ivan Levashew
  4 siblings, 4 replies; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-24 15:44 UTC (permalink / raw)


Jean-Pierre Rosen schrieb:
> I was musing recently through Wikipedia. There are lots of topics
> related to algorithms or similar stuff that have examples, generally in
> C, often with examples in some other languages for comparison.
> 
> It would be nice if the community joined forces to add Ada examples.
> Nobody can do that alone, but if everyone add some examples when finding
> an opportunity, we could give much more visibility to Ada.


From the point of view of Wikipedia, topics related to
algorithms should really not use a programming language.
Any specific language has idiosyncrasies that distract
from the topic of algorithms.  Specific languages can only
be justified if the implementation matters. (This is also
approach in Knuth's TAOCP.)

So, for rewriting algorithm examples there is a well
specified and well established pseudo code notation,
to be found in

 Cormen/Leiserson/Rivest/Stein (2001):
 Introduction to Algorithms, Second Edition.

The notation used there is becoming more popular.

But then, when implementation matters, one could always
show how Ada helps with getting details right and readable.

--
Avoid Ada hype.  -- RBKD at MIT, ~2005



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:22       ` (see below)
@ 2009-02-24 15:49         ` Dmitry A. Kazakov
  2009-02-24 16:32           ` (see below)
  0 siblings, 1 reply; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-24 15:49 UTC (permalink / raw)


On Tue, 24 Feb 2009 15:22:02 +0000, (see below) wrote:

> On 24/02/2009 15:11, in article 1o0daku7d3ttb$.aqm60en944rb$.dlg@40tude.net,
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
> 
>> On Tue, 24 Feb 2009 14:49:05 +0000, (see below) wrote:
>> 
>>> Some of the concurrency code in Rosetta is horribly wrong (in Ada as well as
>>> other languages).
>> 
>> Why not to fix it?
> 
> Better things to do.

Well, wiki model is based on contributions. If you have no time to
contribute, then you have to take it as it is.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:44 ` Georg Bauhaus
@ 2009-02-24 15:53   ` Peter Hermann
  2009-02-24 16:18     ` Georg Bauhaus
  2009-02-24 16:32   ` Jean-Pierre Rosen
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 91+ messages in thread
From: Peter Hermann @ 2009-02-24 15:53 UTC (permalink / raw)


Georg Bauhaus <rm.dash-bauhaus@futureapps.de> wrote:
> From the point of view of Wikipedia, topics related to
> algorithms should really not use a programming language.

Our very modesty has led to our invisibility...

(-: helau am Faschingsdienstag :-)



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:53   ` Peter Hermann
@ 2009-02-24 16:18     ` Georg Bauhaus
  0 siblings, 0 replies; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-24 16:18 UTC (permalink / raw)


Peter Hermann schrieb:
> Georg Bauhaus <rm.dash-bauhaus@futureapps.de> wrote:
>> From the point of view of Wikipedia, topics related to
>> algorithms should really not use a programming language.
> 
> Our very modesty has led to our invisibility...

Tä-Tä! ;->

Well, Ada modesty, ... not really what I can see in
the writings of Richard Riehle concerning
the early political marketing of Ada and its effects ...

So then, Wikipedia's auto-highlighter needs an update by
someone familiar with lookback parsing needed to make
apostrophe work (and maybe other issues).

If Ada is better for examples, then at least do not
mention the language's name.  Seems better if first-timers
see Ada in examples without associating any of its
non-technical reputation.  Prove that Ada is readable!





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:49         ` Dmitry A. Kazakov
@ 2009-02-24 16:32           ` (see below)
  2009-02-24 17:31             ` Dmitry A. Kazakov
  0 siblings, 1 reply; 91+ messages in thread
From: (see below) @ 2009-02-24 16:32 UTC (permalink / raw)


On 24/02/2009 15:49, in article 8e02ektrmxpn.gn0vubkewe3j.dlg@40tude.net,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:

> On Tue, 24 Feb 2009 15:22:02 +0000, (see below) wrote:
> 
>> On 24/02/2009 15:11, in article 1o0daku7d3ttb$.aqm60en944rb$.dlg@40tude.net,
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
>> 
>>> On Tue, 24 Feb 2009 14:49:05 +0000, (see below) wrote:
>>> 
>>>> Some of the concurrency code in Rosetta is horribly wrong (in Ada as well
>>>> as
>>>> other languages).
>>> 
>>> Why not to fix it?
>> 
>> Better things to do.
> 
> Well, wiki model is based on contributions. If you have no time to
> contribute, then you have to take it as it is.

And do you not think that drawing attention to defects is a contribution?

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:44 ` Georg Bauhaus
  2009-02-24 15:53   ` Peter Hermann
@ 2009-02-24 16:32   ` Jean-Pierre Rosen
  2009-02-24 16:52   ` Adam Beneschan
  2009-02-24 19:42   ` Hibou57 (Yannick Duchêne)
  3 siblings, 0 replies; 91+ messages in thread
From: Jean-Pierre Rosen @ 2009-02-24 16:32 UTC (permalink / raw)


Georg Bauhaus a �crit :
[...]
> So, for rewriting algorithm examples there is a well
> specified and well established pseudo code notation,
> to be found in
> 
>  Cormen/Leiserson/Rivest/Stein (2001):
>  Introduction to Algorithms, Second Edition.
> 
> The notation used there is becoming more popular.
> 
> But then, when implementation matters, one could always
> show how Ada helps with getting details right and readable.
> 
It is generally interesting to compare the theoretical algorithm with
how it is translated in various languages. Of course, Ada should not
/replace/ existing pseudo-code, but when we come across examples in C
and/or Python and/or ..., then we may add our Ada version.

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:44 ` Georg Bauhaus
  2009-02-24 15:53   ` Peter Hermann
  2009-02-24 16:32   ` Jean-Pierre Rosen
@ 2009-02-24 16:52   ` Adam Beneschan
  2009-02-24 18:30     ` Georg Bauhaus
  2009-02-24 19:42   ` Hibou57 (Yannick Duchêne)
  3 siblings, 1 reply; 91+ messages in thread
From: Adam Beneschan @ 2009-02-24 16:52 UTC (permalink / raw)


On Feb 24, 7:44 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
> Jean-Pierre Rosen schrieb:
>
> > I was musing recently through Wikipedia. There are lots of topics
> > related to algorithms or similar stuff that have examples, generally in
> > C, often with examples in some other languages for comparison.
>
> > It would be nice if the community joined forces to add Ada examples.
> > Nobody can do that alone, but if everyone add some examples when finding
> > an opportunity, we could give much more visibility to Ada.
>
> From the point of view of Wikipedia, topics related to
> algorithms should really not use a programming language.
> Any specific language has idiosyncrasies that distract
> from the topic of algorithms.  Specific languages can only
> be justified if the implementation matters. (This is also
> approach in Knuth's TAOCP.)
>
> So, for rewriting algorithm examples there is a well
> specified and well established pseudo code notation,
> to be found in
>
>  Cormen/Leiserson/Rivest/Stein (2001):
>  Introduction to Algorithms, Second Edition.
>
> The notation used there is becoming more popular.

Is this a (somewhat) standardized enough notation that it's described
online somewhere?  If so, where?  I don't have the CLRS book handy and
I'm certainly not going to buy it just to see what the pseudo-code
notation looks like.

In any case, though, I'd expect that Ada (as well as Pascal or other
languages that can claim Algol as an ancestor) would be close enough
to what we expect "pseudo"-code to look like, that there shouldn't be
much issue with language idiosyncrasies.  Just my uninformed opinion---
there could be some language-specific aspects that would get in the
way; I haven't looked at the referenced Wikipedia articles, given that
I have approximately as much time as Bill to work on this.

                                   -- Adam




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 16:32           ` (see below)
@ 2009-02-24 17:31             ` Dmitry A. Kazakov
  0 siblings, 0 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-24 17:31 UTC (permalink / raw)


On Tue, 24 Feb 2009 16:32:32 +0000, (see below) wrote:

> On 24/02/2009 15:49, in article 8e02ektrmxpn.gn0vubkewe3j.dlg@40tude.net,
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
> 
>> On Tue, 24 Feb 2009 15:22:02 +0000, (see below) wrote:
>> 
>>> On 24/02/2009 15:11, in article 1o0daku7d3ttb$.aqm60en944rb$.dlg@40tude.net,
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
>>> 
>>>> On Tue, 24 Feb 2009 14:49:05 +0000, (see below) wrote:
>>>> 
>>>>> Some of the concurrency code in Rosetta is horribly wrong (in Ada as well
>>>>> as
>>>>> other languages).
>>>> 
>>>> Why not to fix it?
>>> 
>>> Better things to do.
>> 
>> Well, wiki model is based on contributions. If you have no time to
>> contribute, then you have to take it as it is.
> 
> And do you not think that drawing attention to defects is a contribution?

Yes, when it is done by editing the corresponding "discussion page" of the 
wiki. Rosetta Code has it for each task. You can briefly describe the 
problem there. You also can flag the corresponding solutions as requiring a 
review.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 16:52   ` Adam Beneschan
@ 2009-02-24 18:30     ` Georg Bauhaus
  2009-02-24 18:46       ` Adam Beneschan
  0 siblings, 1 reply; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-24 18:30 UTC (permalink / raw)


Adam Beneschan schrieb:

>>  Cormen/Leiserson/Rivest/Stein (2001):
>>  Introduction to Algorithms, Second Edition.
>>
>> The notation used there is becoming more popular.
> 
> Is this a (somewhat) standardized enough notation that it's described
> online somewhere?  If so, where?  I don't have the CLRS book handy and
> I'm certainly not going to buy it just to see what the pseudo-code
> notation looks like.

I'm not aware of an online description, sorry.
An example, quickly taken from their making-of manual,
is http://home.arcor.de/bauhaus/Ada/clrs.pdf (36k)

The algorithm has also popped up in the description of the
notation offered by Google Books' edition of CLRS when gooogling
"cormen pseudocode notation".

A similar notation is used in Russel and Norvig's
Artifical Intelligence, another seemingly influencial and
popular book.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 18:30     ` Georg Bauhaus
@ 2009-02-24 18:46       ` Adam Beneschan
  0 siblings, 0 replies; 91+ messages in thread
From: Adam Beneschan @ 2009-02-24 18:46 UTC (permalink / raw)


On Feb 24, 10:30 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
> Adam Beneschan schrieb:
>
> >>  Cormen/Leiserson/Rivest/Stein (2001):
> >>  Introduction to Algorithms, Second Edition.
>
> >> The notation used there is becoming more popular.
>
> > Is this a (somewhat) standardized enough notation that it's described
> > online somewhere?  If so, where?  I don't have the CLRS book handy and
> > I'm certainly not going to buy it just to see what the pseudo-code
> > notation looks like.
>
> I'm not aware of an online description, sorry.
> An example, quickly taken from their making-of manual,
> ishttp://home.arcor.de/bauhaus/Ada/clrs.pdf(36k)
>
> The algorithm has also popped up in the description of the
> notation offered by Google Books' edition of CLRS when gooogling
> "cormen pseudocode notation".

Thanks for the link.  As it turns out, that particular example helps
make my point... you could rewrite that particular piece of pseudocode
in Ada and it would translate directly.  There would be syntax
differences, of course (":=" instead of left-arrow, A'Length instead
of Length[A], "loop" instead of "do", a few others), but it certainly
is *not* a case where any language idiosyncrasies would detract from
the description of the algorithm in a way that pseudo-code wouldn't.

                             -- Adam





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 11:03 Invade wikipedia! Jean-Pierre Rosen
                   ` (2 preceding siblings ...)
  2009-02-24 15:44 ` Georg Bauhaus
@ 2009-02-24 19:29 ` Martin Krischik
  2009-02-25 22:31 ` Ivan Levashew
  4 siblings, 0 replies; 91+ messages in thread
From: Martin Krischik @ 2009-02-24 19:29 UTC (permalink / raw)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jean-Pierre Rosen schrieb:

> I was musing recently through Wikipedia. There are lots of topics
> related to algorithms or similar stuff that have examples, generally in
> C, often with examples in some other languages for comparison.

I started something similar on the Algorithm book on Wikibooks. But as
you said: One person is not enough. We need a little team - including
team leader ;-).

Martin

- --
Martin Krischik
krischik@me.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJpEqdijwKaHyem9cRArdQAJ9ORTvf/qSq3Jd3uKet4gHGuBgRDwCcC96M
Y4mx/ajoMReJTllLfA+wGWg=
=fhIG
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 15:44 ` Georg Bauhaus
                     ` (2 preceding siblings ...)
  2009-02-24 16:52   ` Adam Beneschan
@ 2009-02-24 19:42   ` Hibou57 (Yannick Duchêne)
  2009-02-24 19:59     ` Dmitry A. Kazakov
  2009-02-24 23:01     ` Georg Bauhaus
  3 siblings, 2 replies; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-24 19:42 UTC (permalink / raw)


On 24 fév, 16:44, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> From the point of view of Wikipedia, topics related to
> algorithms should really not use a programming language.
> Any specific language has idiosyncrasies that distract
> from the topic of algorithms.  Specific languages can only
> be justified if the implementation matters. (This is also
> approach in Knuth's TAOCP.)
>
> So, for rewriting algorithm examples there is a well
> specified and well established pseudo code notation,
> to be found in
>
>  Cormen/Leiserson/Rivest/Stein (2001):
>  Introduction to Algorithms, Second Edition.
>
> The notation used there is becoming more popular.
>
> But then, when implementation matters, one could always
> show how Ada helps with getting details right and readable.
>
> --
> Avoid Ada hype.  -- RBKD at MIT, ~2005

This is not just a matter of implementation, it is also a matter of
precision.

If this kind of pseudo code was suffiscient to really and precisely
express algorithms, it would be a real language.

There is an exception about declarative languages, like part of the
mathematical one, beceause these ones express properties.

There is alaways some lacks and this pseudo-code has nothing better
than others. This is just a discret way to claim one langage is better
to another.... pseudo-code is a langage, beside any other one, and I
do not see a way it is better to any other one at expressing
algorithms.

Pseudo-code is commonly used in a loosy way (I do not mean it is a bad
thing) which could not work at all if one would try to map it in an
"implementation langage". Otherwise, it is a competitor which
errorneously claim to be the only one to be better than any one else.

And indeed, it is a good idea to not talk about algorithms using a
particular "implementation language", beceause algorithms are better
discussed using declarative meanings (implementation decision as well,
should be disccused using declarative meanings).



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 14:50   ` Martin
  2009-02-24 15:16     ` Dmitry A. Kazakov
@ 2009-02-24 19:48     ` Hibou57 (Yannick Duchêne)
  2009-02-24 20:34       ` sjw
                         ` (2 more replies)
  1 sibling, 3 replies; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-24 19:48 UTC (permalink / raw)


On 24 fév, 15:50, Martin <martin.do...@btopenworld.com> wrote:
>
> Could we agree get rid of the box comments, e.g.
>
>    ------------------
>    -- Do_Something --
>    ------------------
>
>    procedure Do_Something ...;
>
> Cheers
> -- Martin

Please, help me to understand : what's the trouble with this ?



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 19:42   ` Hibou57 (Yannick Duchêne)
@ 2009-02-24 19:59     ` Dmitry A. Kazakov
  2009-02-24 20:08       ` Hibou57 (Yannick Duchêne)
  2009-02-24 23:01     ` Georg Bauhaus
  1 sibling, 1 reply; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-24 19:59 UTC (permalink / raw)


On Tue, 24 Feb 2009 11:42:18 -0800 (PST), Hibou57 (Yannick Duch�ne) wrote:

[points I agree with]

> And indeed, it is a good idea to not talk about algorithms using a
> particular "implementation language", beceause algorithms are better
> discussed using declarative meanings (implementation decision as well,
> should be disccused using declarative meanings).

I doubt it. The idea of algorithms is imperative, and thus constructive. In
contrast to this declarative descriptions are often non-constructive.
Compare a differential equation (declarative description of a solution) to
an algorithm of solving the equation.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 19:59     ` Dmitry A. Kazakov
@ 2009-02-24 20:08       ` Hibou57 (Yannick Duchêne)
  0 siblings, 0 replies; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-24 20:08 UTC (permalink / raw)


On 24 fév, 20:59, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> I doubt it. The idea of algorithms is imperative, and thus constructive. In
> contrast to this declarative descriptions are often non-constructive.
> Compare a differential equation (declarative description of a solution) to
> an algorithm of solving the equation.
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

It is a fact that the most effective (or good enough) implementation
of an algorithm is most of time the most effective (or good enough)
implementation which fulfill a requirement. Efficient implementations
looks very different to the expression of the algorithm. Thus, what we
finally want, is not the implementation of an algorithm, but rather,
the implementation of something which fulfill a request/requirement...
requirements/request which are better expressed in declarative ways.

Beside of that, this is the basic of the client/solution-provider
relationship.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 19:48     ` Hibou57 (Yannick Duchêne)
@ 2009-02-24 20:34       ` sjw
  2009-02-24 21:27       ` Jeffrey R. Carter
  2009-02-24 23:02       ` Adam Beneschan
  2 siblings, 0 replies; 91+ messages in thread
From: sjw @ 2009-02-24 20:34 UTC (permalink / raw)


On Feb 24, 7:48 pm, Hibou57 (Yannick Duchêne)
<yannick_duch...@yahoo.fr> wrote:
> On 24 fév, 15:50, Martin <martin.do...@btopenworld.com> wrote:
>
>
>
> > Could we agree get rid of the box comments, e.g.
>
> >    ------------------
> >    -- Do_Something --
> >    ------------------
>
> >    procedure Do_Something ...;
>
> > Cheers
> > -- Martin
>
> Please, help me to understand : what's the trouble with this ?

It takes up *so* much room on the page. And, if you have a capable IDE
(eg, Emacs with imenu), you can hop straight to each subprogram/type
declaration ..

Nothing against box comments per se, but they seem to fit better with
major structural divisions.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 19:48     ` Hibou57 (Yannick Duchêne)
  2009-02-24 20:34       ` sjw
@ 2009-02-24 21:27       ` Jeffrey R. Carter
  2009-02-24 21:48         ` Hibou57 (Yannick Duchêne)
  2009-02-24 23:03         ` Adam Beneschan
  2009-02-24 23:02       ` Adam Beneschan
  2 siblings, 2 replies; 91+ messages in thread
From: Jeffrey R. Carter @ 2009-02-24 21:27 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:
> On 24 f�v, 15:50, Martin <martin.do...@btopenworld.com> wrote:
>> Could we agree get rid of the box comments, e.g.
>>
>>    ------------------
>>    -- Do_Something --
>>    ------------------
>>
>>    procedure Do_Something ...;
>>
>> Cheers
>> -- Martin
> 
> Please, help me to understand : what's the trouble with this ?

In this particular example, the comment adds no value.

-- 
Jeff Carter
"Pray that there's intelligent life somewhere up in
space, 'cause there's bugger all down here on earth."
Monty Python's Meaning of Life
61



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 21:27       ` Jeffrey R. Carter
@ 2009-02-24 21:48         ` Hibou57 (Yannick Duchêne)
  2009-02-24 22:43           ` Jeffrey R. Carter
  2009-02-24 23:03         ` Adam Beneschan
  1 sibling, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-24 21:48 UTC (permalink / raw)


Hello Jeffrey,

On 24 fév, 22:27, "Jeffrey R. Carter" <spam.jrcarter....@spam.acm.org>
wrote:
>
> In this particular example, the comment adds no value.
>
> --
> Jeff Carter
> "Pray that there's intelligent life somewhere up in
> space, 'cause there's bugger all down here on earth."
> Monty Python's Meaning of Life
> 61

No value in which area ?

I'm joking.... I guess what you meant : you were thinking about code
value, and I agree about this one value.
But there is visual value as well, as long as code is to be read with
eyes.

Someone talked about Emac (which I do not use, I use something else),
but a lot of editors are plain text editors, and further more, in this
particular case, the code is displayed on webpage as plain text, not
in Emac or any other valuable text editor. So an argument saying "it
is unuseful, beceause Emac helps me to not need this", is meaningful
only in a context where Emac is in used. Here, on a web page, it is
not.

By the way, if I'm allowed to be a bit out of subject, I thinking
about adding to my editor, the capacity to export files replacing
headings with similar comments.... in order to be best viewed in a
plain text context.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 21:48         ` Hibou57 (Yannick Duchêne)
@ 2009-02-24 22:43           ` Jeffrey R. Carter
  0 siblings, 0 replies; 91+ messages in thread
From: Jeffrey R. Carter @ 2009-02-24 22:43 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:
> 
> No value in which area ?

The basic rule for comments is that they must add value: they must tell you 
something that the code doesn't. The comment in question simply repeats the name 
of the procedure; the code already tells you that. Therefore, the comment adds 
no value.

-- 
Jeff Carter
"Pray that there's intelligent life somewhere up in
space, 'cause there's bugger all down here on earth."
Monty Python's Meaning of Life
61



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 19:42   ` Hibou57 (Yannick Duchêne)
  2009-02-24 19:59     ` Dmitry A. Kazakov
@ 2009-02-24 23:01     ` Georg Bauhaus
  2009-02-24 23:47       ` Hibou57 (Yannick Duchêne)
  2009-02-25 22:15       ` Ivan Levashew
  1 sibling, 2 replies; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-24 23:01 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:

>> But then, when implementation matters, one could always
>> show how Ada helps with getting details right and readable.

> This is not just a matter of implementation, it is also a matter of
> precision.

The word "precision" can be misused.  The precision of an algorithm
is measured against what? More than some typical level?
Less than it?  What's typical? And why? --  That is,
should Wikipedia, in an algorithms book, be so precise
that it illustrates certain CPU-specific integer overflow
detection machanisms in the examples?[*]  Or should it delegate
discussions of this level of precision to some book about
implementation strategies?

The following premises produce a partial answer.
Any choice of notation (code or pseudo code) has to start from
the writer's intentions:

1 - What do you want to explain?
2 - Who is your audience?

Suppose you want to express an algorithm that sorts a thousand
whole numbers of any size.[**]

If you start from just about any Ada-like programming language
you are in trouble already:  the fundamental type system is not
capable of expressing types of arbitrarily large whole numbers
because

(a) the fundamental type system is really built around the idea
that whole numbers basically fit in register words,

(b) the language definitions reflect CPU properties by requirement
or by advice to *of* *course* take advantage of hardware properties
(quick addition in inner loops; an overflow trap).

These constraints add real things, but they do not help with
achieving the clearly specified goal (of explaining the
algorithm): When I want to explain just how to sort a thousand
arbitrarily large whole numbers there is no need to refer to
the limits of a machine model.

First, a finite machine may not be relevant to my audience.
They just want the sorting of the numbers they already know.

Second, coding this algorithm in Ada or some other "real"
language, I *have* to go outside the fundamental type system,
because it does not have large numbers.  Worse,
I start waving hands:
"You know, just assume these magic types I gave you can
deal with large whole numbers fine. I'm omitting the
details of how this is possible etc etc."  What you loose,
then, is what you wanted to add: precise explanation,
of nothing but the algorithm!


> If this kind of pseudo code was suffiscient to really and precisely
> express algorithms, it would be a real language.

Pseudo code of the kind in question is a real language.
By analogy, no one writes Turing machine programs in
commercial applications[***]. Still, his fictional(!)
machine is entirely programmed using "pseudo code"[****].
A Turing machine is defined precisely and
its languages are real programming languages.

An algorithm, for example a shortest path procedure, can well
be explained, formally and precisely, in lines and characters,
drawn using a pencil. A picture shows the current state of
graph traversal. Each picture has circled letters, some shading,
some straight lines. Each is like a picture in a slide show:
You follow the pictures as the algorithm steps forward, if necessary
you can look backwards at an earlier picture.  That is, you follow
the snapshots of an algorithm forwards and backwards.

The objects of the pictorial algorithm are well defined,
as are the steps. To explain it, mo larger amount of
precision is needed. There is a *machine* *model*.
Obviously, its not that of a PC.

The machine *may* be a sequential digital RAM of the kind we
think we know. If this is important, it will be instructive to
*add* more aspects to the algorithm.  Can we afford large numbers?
What *is* a large number, by the way?  The a real programming
language will become important insofar as it reflects
the constraints imposed by the digital RAM and the PL definition.



> There is an exception about declarative languages, like part of the
> mathematical one, beceause these ones express properties.

Properties of what? Try it, I discovered many details that
need to be masterd before the expressions become clear.
They are just not stated in the declarations, but in preparatory
texts and preparatory exercises.

> pseudo-code is a langage, beside any other one, and I
> do not see a way it is better to any other one at expressing
> algorithms.

Example:
The basic idea of a 1-dimensional array in a conventional
programming language may be expressed, WLOG, as a sequence of
items that can be addressed directly, using index numbers.[*****]

When explaining an array algorithm, you can do so with this or that
(better or worse) reification of the array idea that some
programming language offers.  Sure, there are array reifications
that produce a lot of overflow errors in real programs. Yes,
Ada's tight coupling between the array object and its index type
makes the language stand out.  Yet, any special features of arrays
need to be explained first unless they are self-explanatory.
The subject, however, is algorithms, not array reifications.
OTOH, the CLRS pseudo code notation has array functions similar
to Ada's 'Length, but simpler. It seems to work in teaching.


> And indeed, it is a good idea to not talk about algorithms using a
> particular "implementation language", beceause algorithms are better
> discussed using declarative meanings (implementation decision as well,
> should be disccused using declarative meanings).

Algorithms being better discussed using declarative meanings is
a claim frequently made (and hardly ever shown to be correct)
by mathematicians.
Statistically, there is a remarkable correlation between
those who make this claim and their profession (mathematics).
I'm stating this as an observation, no comment is intended.
(Still, when I see equational function assemblies of an absurd
combinatorial complexity at the source level, I start to
think about blind spots in FP.)

When we try to understand a declaration or equational
definition, our brain does operate(!)!  It does not just denote,
if it does denote at all.
In order to really understand what a "functional equation"
means, you have to perform(!) some backtracking:

   f(0) = 1
   f(t + 1) = "*"(t, f(t - 1))   for all t in N

To understand what is going on here you need to follow the
recursion. This process(!) is never emphasized in a
functional showcase.[******] Why not?

Proceding on the declarative route, you arrive at assembling(!)
functions in tricky ways in order to achieve an efficient
evaluation strategy. Isn't this totally obscuring the explanatory
goal?

_____
[*] For sure, detecting overflow would largely remove the need
for all these "security patches" that revolve
almost exclusively around the very subject of overflows...

[**] Not unrealistic, we do have libraries for these kinds
of numbers for a reason.

[***] other than programs demonstrating Turing machines, maybe.

[****] barring toilet rolls and human hands and heads of state...

[*****] Dmitry, could you resist explaining why arrays should
really be interfaces? They are, BTW, in CLRS pseudo code, I should
think :-)

[******] The Little Schemer (etc) was an exception.

Vista is driving me mad. It's switching locale settings
at unforeseen moments, makes me start tzping funnz words.
Do thez ever use anzthing but Office inside MS?



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 19:48     ` Hibou57 (Yannick Duchêne)
  2009-02-24 20:34       ` sjw
  2009-02-24 21:27       ` Jeffrey R. Carter
@ 2009-02-24 23:02       ` Adam Beneschan
  2 siblings, 0 replies; 91+ messages in thread
From: Adam Beneschan @ 2009-02-24 23:02 UTC (permalink / raw)


On Feb 24, 11:48 am, Hibou57 (Yannick Duchêne)
<yannick_duch...@yahoo.fr> wrote:
> On 24 fév, 15:50, Martin <martin.do...@btopenworld.com> wrote:
>
>
>
> > Could we agree get rid of the box comments, e.g.
>
> >    ------------------
> >    -- Do_Something --
> >    ------------------
>
> >    procedure Do_Something ...;
>
> > Cheers
> > -- Martin
>
> Please, help me to understand : what's the trouble with this ?

In large source files, having comments like this can sometimes help a
reader who is scanning the entire source.  (Yes, the advantage of this
has been lessened with all the fancy editing tools we now have.  I'm
speaking as a Cobolosaurus who still remembers programs being on punch
cards and having to read listings from the line printer.  Even with
the tools available, I still sometimes find it useful to just read
through a whole source top to bottom, and something is needed to break
it up and put some structure in the list so that my eyes don't see it
as just one big continuous 1200-line blob.)

But in a small source, it's just clutter and it gets in the way.

                               -- Adam




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 21:27       ` Jeffrey R. Carter
  2009-02-24 21:48         ` Hibou57 (Yannick Duchêne)
@ 2009-02-24 23:03         ` Adam Beneschan
  2009-02-24 23:28           ` Martin
  1 sibling, 1 reply; 91+ messages in thread
From: Adam Beneschan @ 2009-02-24 23:03 UTC (permalink / raw)


On Feb 24, 1:27 pm, "Jeffrey R. Carter"
<spam.jrcarter....@spam.acm.org> wrote:
> Hibou57 (Yannick Duchêne) wrote:
> > On 24 fév, 15:50, Martin <martin.do...@btopenworld.com> wrote:
> >> Could we agree get rid of the box comments, e.g.
>
> >>    ------------------
> >>    -- Do_Something --
> >>    ------------------
>
> >>    procedure Do_Something ...;
>
> >> Cheers
> >> -- Martin
>
> > Please, help me to understand : what's the trouble with this ?
>
> In this particular example, the comment adds no value.

I would not expect *any* comment to have *any* value coming from a
programmer who would name a procedure Do_Something.....

                               -- Adam



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:03         ` Adam Beneschan
@ 2009-02-24 23:28           ` Martin
  2009-02-24 23:33             ` (see below)
  2009-02-24 23:53             ` Hibou57 (Yannick Duchêne)
  0 siblings, 2 replies; 91+ messages in thread
From: Martin @ 2009-02-24 23:28 UTC (permalink / raw)


On Feb 24, 11:03 pm, Adam Beneschan <a...@irvine.com> wrote:
> On Feb 24, 1:27 pm, "Jeffrey R. Carter"
>
>
>
>
>
>
>
> <spam.jrcarter....@spam.acm.org> wrote:
> > Hibou57 (Yannick Duchêne) wrote:
> > > On 24 fév, 15:50, Martin <martin.do...@btopenworld.com> wrote:
> > >> Could we agree get rid of the box comments, e.g.
>
> > >>    ------------------
> > >>    -- Do_Something --
> > >>    ------------------
>
> > >>    procedure Do_Something ...;
>
> > >> Cheers
> > >> -- Martin
>
> > > Please, help me to understand : what's the trouble with this ?
>
> > In this particular example, the comment adds no value.
>
> I would not expect *any* comment to have *any* value coming from a
> programmer who would name a procedure Do_Something.....
>
>                                -- Adam

Sorry my made up example doesn't cut mustard! Does this make it any
clearer? :-)

------------------------
-- Calculate_Velocity --
------------------------

procedure Calculate_Velocity
             (Speed    :     Meters_Per_Second;
              Time     :     Seconds;
              Velocity : out Meters_Per_Second_Per_Second);

Cheers
-- Martin




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:28           ` Martin
@ 2009-02-24 23:33             ` (see below)
  2009-02-25  0:08               ` Martin
  2009-02-25  8:05               ` Jacob Sparre Andersen
  2009-02-24 23:53             ` Hibou57 (Yannick Duchêne)
  1 sibling, 2 replies; 91+ messages in thread
From: (see below) @ 2009-02-24 23:33 UTC (permalink / raw)


On 24/02/2009 23:28, in article
9f2553d3-66f5-4708-a237-bfef1d8404f4@v42g2000yqj.googlegroups.com, "Martin"
<martin.dowie@btopenworld.com> wrote:

> Sorry my made up example doesn't cut mustard! Does this make it any
> clearer? :-)
> 
> ------------------------
> -- Calculate_Velocity --
> ------------------------
> 
> procedure Calculate_Velocity
>              (Speed    :     Meters_Per_Second;
>               Time     :     Seconds;
>               Velocity : out Meters_Per_Second_Per_Second);

Nope!
The reason why is left as an exercise for the student. 8-)

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:01     ` Georg Bauhaus
@ 2009-02-24 23:47       ` Hibou57 (Yannick Duchêne)
  2009-02-26  0:52         ` Georg Bauhaus
  2009-02-25 22:15       ` Ivan Levashew
  1 sibling, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-24 23:47 UTC (permalink / raw)


On 25 fév, 00:01, Georg Bauhaus <rm.tsoh.plus-
bug.bauh...@maps.futureapps.de> wrote:
> The word "precision" can be misused.  The precision of an algorithm
> is measured against what? More than some typical level?
> Less than it?  What's typical? And why? --  That is,
> should Wikipedia, in an algorithms book, be so precise
> that it illustrates certain CPU-specific integer overflow
> detection machanisms in the examples?[*]  Or should it delegate
> discussions of this level of precision to some book about
> implementation strategies?
As too many references are possible, I suppose this would be
delegated, using a formalism which would help to make the link between
these two references.

Algorithmic is oftenly learned using such abstractions.

> These constraints add real things, but they do not help with
> achieving the clearly specified goal (of explaining the
> algorithm): When I want to explain just how to sort a thousand
> arbitrarily large whole numbers there is no need to refer to
> the limits of a machine model.
I agree, this is an algo.

> Worse, I start waving hands:
> "You know, just assume these magic types I gave you can
> deal with large whole numbers fine. I'm omitting the
> details of how this is possible etc etc."  What you loose,
> then, is what you wanted to add: precise explanation,
> of nothing but the algorithm!
>
This is another step of the process, which deals with different
matters.

Previously I've said that an efficient or good enough implementation
is oftenly far from what looks a theoric algorithm... while this does
not mean the algorithm does not drive the imagination on the road to
the effective solution.

> > If this kind of pseudo code was suffiscient to really and precisely
> > express algorithms, it would be a real language.
>
> Pseudo code of the kind in question is a real language.
> By analogy, no one writes Turing machine programs in
> commercial applications[***]. Still, his fictional(!)
> machine is entirely programmed using "pseudo code"[****].
> A Turing machine is defined precisely and
> its languages are real programming languages.
When I read you, I'm thinking about something like LISP. Is that Ok if
got this image in mind ?

> The machine *may* be a sequential digital RAM of the kind we
> think we know. If this is important, it will be instructive to
> *add* more aspects to the algorithm.  Can we afford large numbers?
> What *is* a large number, by the way?  The a real programming
> language will become important insofar as it reflects
> the constraints imposed by the digital RAM and the PL definition.

This is a next step, applied to an algorithm, which may have numerous
live cycles (the algo).

> Properties of what? Try it, I discovered many details that
> need to be masterd before the expressions become clear.
> They are just not stated in the declarations, but in preparatory
> texts and preparatory exercises.
Properties like "can I compute this in a human life time ?", or else
"how does the computation time will increase ?"... these are fuzzy
view, I agree, I know this is many times a bit far from the reality,
while what it says is most of time true in the big shape.

> Algorithms being better discussed using declarative meanings is
> a claim frequently made (and hardly ever shown to be correct)
> by mathematicians.
> Statistically, there is a remarkable correlation between
> those who make this claim and their profession (mathematics).

I'm my self really out of this staticical assertion.

> When we try to understand a declaration or equational
> definition, our brain does operate(!)!  It does not just denote,
> if it does denote at all.
Yes, it operates, in its most convenient way of the moment, which is
far less restrictive that what would be any real machine. We operate,
but in a far differente way a machine would do. We get freedom we
would not have if we were operating like a machine.

> In order to really understand what a "functional equation"
> means, you have to perform(!) some backtracking:
>
>    f(0) = 1
>    f(t + 1) = "*"(t, f(t - 1))   for all t in N
>
> To understand what is going on here you need to follow the
> recursion. This process(!) is never emphasized in a
> functional showcase.[******] Why not?

You are right again..... but we do not follow the process like a
machine would do. We may sometime go using a shortcut (which may be
wrong by the way, thus making a wrong intial assertion) a machine will
never use (not so far, perhaps in the futur this gonna not be true
anymore).

> Proceding on the declarative route, you arrive at assembling(!)
> functions in tricky ways in order to achieve an efficient
> evaluation strategy. Isn't this totally obscuring the explanatory
> goal?


I apologize to not have replied to all exact points (I'm not as fluent
as you are at english), but any way, I would like to temporaly end
with this (as least, an attempt) : What've learned so fat, is that an
algorithm as least something similar with a piece of code (supposed we
all agree). Peoples may write this kind of piece of code with
different goals in minds (as peoples are all different and has
differents though). Then, one see this, and try to map it on its own
expectations.... finally, there are different expactations on one
thing which seems to be the same to everyones eyes.

This is not surprising, there are so many expectations on the computer
idead it-self : is it a game machine ? a modeling machine ? a concret
tool ? an abstract tool ? Differents peoples use the same thing, the
computer, with different expactations.

After that is said, I can tell about my own expactation on
algorithms : I expect it to be something with can help me to see in
which direction I should go to get a good solution to a given request.
Something which would be abstract enough to temporaly avoid thinking
about real machines limitations, and which I will bring into a concret
methods in a concret langage, perhaps using other algorithms to solve
some requested steps to there.

The algorithm is also what I do in a reverse way, when I try to
understand why a particular piece of code does not work : I get rid of
implementation details, try to mentaly build an abstract algorithm on
which I will mentaly operate. By the way, I may or may not solve the
trouble this way : this view may tell me the algo is ok, and the
trouble is perhaps somewhere else (a browser bug, or a not well
understood context, or something else).

There are concret codes which applies very well to machine, and there
alternate view, more abstract, sometimes more fuzzy, with which
humans, who are not machines, deals.

(I hope I did not miss an important point)

> Vista is driving me mad. It's switching locale settings
> at unforeseen moments, makes me start tzping funnz words.
> Do thez ever use anzthing but Office inside MS?

Yes, I agree agree with this too :D (joking, with a serious though
behind)



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:28           ` Martin
  2009-02-24 23:33             ` (see below)
@ 2009-02-24 23:53             ` Hibou57 (Yannick Duchêne)
  2009-02-25  0:07               ` Martin
  1 sibling, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-24 23:53 UTC (permalink / raw)


On 25 fév, 00:28, Martin <martin.do...@btopenworld.com> wrote:
> Sorry my made up example doesn't cut mustard! Does this make it any
> clearer? :-)
>
> ------------------------
> -- Calculate_Velocity --
> ------------------------
>
> procedure Calculate_Velocity
>              (Speed    :     Meters_Per_Second;
>               Time     :     Seconds;
>               Velocity : out Meters_Per_Second_Per_Second);
>
> Cheers
> -- Martin

For visual seeking in a long page, I would reply “yes” about me.
Perhaps my eyes need this while others will not.
As somebody enjoy white text on black or dark background while others
feel theire eyes hurt with this layout.
Visual perception and ergonomy is a complex and big science.




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:53             ` Hibou57 (Yannick Duchêne)
@ 2009-02-25  0:07               ` Martin
  0 siblings, 0 replies; 91+ messages in thread
From: Martin @ 2009-02-25  0:07 UTC (permalink / raw)


On Feb 24, 11:53 pm, Hibou57 (Yannick Duchêne)
<yannick_duch...@yahoo.fr> wrote:
> On 25 fév, 00:28, Martin <martin.do...@btopenworld.com> wrote:
>
> > Sorry my made up example doesn't cut mustard! Does this make it any
> > clearer? :-)
>
> > ------------------------
> > -- Calculate_Velocity --
> > ------------------------
>
> > procedure Calculate_Velocity
> >              (Speed    :     Meters_Per_Second;
> >               Time     :     Seconds;
> >               Velocity : out Meters_Per_Second_Per_Second);
>
> > Cheers
> > -- Martin
>
> For visual seeking in a long page, I would reply “yes” about me.
> Perhaps my eyes need this while others will not.
> As somebody enjoy white text on black or dark background while others
> feel theire eyes hurt with this layout.
> Visual perception and ergonomy is a complex and big science.


Sorry, the point I was making has been lost...

The problem I have with 'box comments' _in_examples_ - as found in
Wikipedia, Rosetta, etc - is that they distract the reader and nothing
to do with helping reads scan source in the real world.

For all I know they may actually lead some people to believe that Ada /
requires/ such comments or that they are common practice.

<shout>
That's just going to put potential Ada users off.
</shout>

NB: Check other languages examples - no comments. And certainly no
comments that don't actually explain something useful.

They /may/ or /may not/ have a use in the real world but that's a
topic for another thread.

Cheers
-- Martin



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:33             ` (see below)
@ 2009-02-25  0:08               ` Martin
  2009-02-25  0:52                 ` Adam Beneschan
                                   ` (2 more replies)
  2009-02-25  8:05               ` Jacob Sparre Andersen
  1 sibling, 3 replies; 91+ messages in thread
From: Martin @ 2009-02-25  0:08 UTC (permalink / raw)


On Feb 24, 11:33 pm, "(see below)" <yaldni...@blueyonder.co.uk> wrote:
> On 24/02/2009 23:28, in article
> 9f2553d3-66f5-4708-a237-bfef1d840...@v42g2000yqj.googlegroups.com, "Martin"
>
> <martin.do...@btopenworld.com> wrote:
> > Sorry my made up example doesn't cut mustard! Does this make it any
> > clearer? :-)
>
> > ------------------------
> > -- Calculate_Velocity --
> > ------------------------
>
> > procedure Calculate_Velocity
> >              (Speed    :     Meters_Per_Second;
> >               Time     :     Seconds;
> >               Velocity : out Meters_Per_Second_Per_Second);
>
> Nope!
> The reason why is left as an exercise for the student. 8-)
>
> --
> Bill Findlay
> <surname><forename> chez blueyonder.co.uk

Hmmm, the tautology? I'm using C too much these days...

---------------
-- Calculate --
---------------

procedure Calculate (Speed    :     Meters_Per_Second;
                     Time     :     Seconds;
                     Velocity : out Meters_Per_Second_Per_Second);




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25  0:08               ` Martin
@ 2009-02-25  0:52                 ` Adam Beneschan
  2009-02-25  1:45                 ` (see below)
  2009-02-25 16:38                 ` Martin
  2 siblings, 0 replies; 91+ messages in thread
From: Adam Beneschan @ 2009-02-25  0:52 UTC (permalink / raw)


On Feb 24, 4:08 pm, Martin <martin.do...@btopenworld.com> wrote:
> On Feb 24, 11:33 pm, "(see below)" <yaldni...@blueyonder.co.uk> wrote:
>
>
>
> > On 24/02/2009 23:28, in article
> > 9f2553d3-66f5-4708-a237-bfef1d840...@v42g2000yqj.googlegroups.com, "Martin"
>
> > <martin.do...@btopenworld.com> wrote:
> > > Sorry my made up example doesn't cut mustard! Does this make it any
> > > clearer? :-)
>
> > > ------------------------
> > > -- Calculate_Velocity --
> > > ------------------------
>
> > > procedure Calculate_Velocity
> > >              (Speed    :     Meters_Per_Second;
> > >               Time     :     Seconds;
> > >               Velocity : out Meters_Per_Second_Per_Second);
>
> > Nope!
> > The reason why is left as an exercise for the student. 8-)
>
> Hmmm, the tautology? I'm using C too much these days...

Nope, that wasn't it.  Actually, I think Calculate_Velocity would look
a bit better and make things a bit clearer for the reader at the point
of the call---assuming the name wasn't a lie and that the velocity was
what it was actually computing...  :)

                               -- Adam


> ---------------
> -- Calculate --
> ---------------
>
> procedure Calculate (Speed    :     Meters_Per_Second;
>                      Time     :     Seconds;
>                      Velocity : out Meters_Per_Second_Per_Second);




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25  0:08               ` Martin
  2009-02-25  0:52                 ` Adam Beneschan
@ 2009-02-25  1:45                 ` (see below)
  2009-02-25 16:38                 ` Martin
  2 siblings, 0 replies; 91+ messages in thread
From: (see below) @ 2009-02-25  1:45 UTC (permalink / raw)


On 25/02/2009 00:08, in article
9c729d86-763b-446e-9ba0-3bd682ba23fa@u38g2000yqe.googlegroups.com, "Martin"
<martin.dowie@btopenworld.com> wrote:

> On Feb 24, 11:33�pm, "(see below)" <yaldni...@blueyonder.co.uk> wrote:
>> On 24/02/2009 23:28, in article
>> 9f2553d3-66f5-4708-a237-bfef1d840...@v42g2000yqj.googlegroups.com, "Martin"
>> 
>> <martin.do...@btopenworld.com> wrote:
>>> Sorry my made up example doesn't cut mustard! Does this make it any
>>> clearer? :-)
>> 
>>> ------------------------
>>> -- Calculate_Velocity --
>>> ------------------------
>> 
>>> procedure Calculate_Velocity
>>> � � � � � � �(Speed � �: � � Meters_Per_Second;
>>> � � � � � � � Time � � : � � Seconds;
>>> � � � � � � � Velocity : out Meters_Per_Second_Per_Second);
>> 
>> Nope!
>> The reason why is left as an exercise for the student. 8-)
>> 
>> --
>> Bill Findlay
>> <surname><forename> chez blueyonder.co.uk
> 
> Hmmm, the tautology? I'm using C too much these days...
> 
> ---------------
> -- Calculate --
> ---------------
> 
> procedure Calculate (Speed    :     Meters_Per_Second;
>                      Time     :     Seconds;
>                      Velocity : out Meters_Per_Second_Per_Second);
> 

Still cold! 8-)

I hate comments, for being next to un-maintainable, and write as few as
possible (but no fewer). Better to make the code say what it really means,
as this example shows.

The comments I find useful are reminders to myself in stereotyped formats
that are easy to retrieve with an editor (e.g. "STUB" or "??").
 
Short clarifications of inherent obscurities are sometimes necessary.

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:33             ` (see below)
  2009-02-25  0:08               ` Martin
@ 2009-02-25  8:05               ` Jacob Sparre Andersen
  2009-02-25  8:59                 ` Hibou57 (Yannick Duchêne)
                                   ` (2 more replies)
  1 sibling, 3 replies; 91+ messages in thread
From: Jacob Sparre Andersen @ 2009-02-25  8:05 UTC (permalink / raw)


Bill wrote:
> Martin wrote:

>> Sorry my made up example doesn't cut mustard! Does this make it any
>> clearer? :-)
>> 
>> ------------------------
>> -- Calculate_Velocity --
>> ------------------------
>> 
>> procedure Calculate_Velocity
>>              (Speed    :     Meters_Per_Second;
>>               Time     :     Seconds;
>>               Velocity : out Meters_Per_Second_Per_Second);
>
> Nope!
> The reason why is left as an exercise for the student. 8-)

I'm not really a student any more, but now that the students have had
their chance ...

There are several problems with this:

 + The subroutine doesn't do what its name says it does (physicists
   see this easily).

 + Since the subroutine only returns a single, simple object, it would
   typically make much more sense implementing it as a function.

 + In the specific discussed context (programming example wikis), each
   subroutine usually already stands out alone.

 + Comments are inherently dangerous (since they are not checked by
   the compiler).

Greetings,

Jacob
-- 
"Never trust a statistic you have not falsified yourself."



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25  8:05               ` Jacob Sparre Andersen
@ 2009-02-25  8:59                 ` Hibou57 (Yannick Duchêne)
  2009-02-25 16:10                   ` (see below)
  2009-02-25 15:57                 ` (see below)
  2009-02-25 22:14                 ` Adam Beneschan
  2 siblings, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-25  8:59 UTC (permalink / raw)


To say that these comments does not offer any value, ... it is a
valuable point of view (as is as much the one which says that it may
be useful for visual seeking).

But the to comment on comments asserting it is unuseful and dangerous,
is another matter.

In my humble opinion, it is impossible to understand a full
application without comments... impossible to know what was the
choices made when a particular method were setted up, what aspects
were balanced, what design principle it belongs to, how it does
collaborate with other parts of the program, etc, etc.

A source without comments, is a source which hides every thing.

If comments are dangerous, so the human though which drives the
application developpement (or order it), is as much dangerous.

I agree that comments may be dangerous when these are not up to date,
but this is another matter.

Comments acts like UML schemas : it helps to make sense, it offers one
more view on an application, and multiple view at least helps to
discover inconsistencies. The first thing I look at in my own code, in
not the code, it is at comments, when there are some (I try to comment
every methods, every singular line of code, but it usually come at
ends, when things are mature enough).

Did you ever tried to come back to you own code two years, three years
later ? I use to do, on some application I lacked to comment.... the
only one thing I could do was to regret this lack, and restart the
whole work, without forgetting comments the second time.

Well, perhpaps it should be worth to point about the life cycle. If
you are talking about very short life cycle applications, then, I
agree.... you can drop comments. But if not, you will inevitably face
a fact : meanings, purpose and implementations are not the same
things. There is code for implementations and purposes, and comments
for purposes and meanings.

Other exemples of useful comments : let comments which tell how to
update the application (extend, modify, etc), let



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25  8:05               ` Jacob Sparre Andersen
  2009-02-25  8:59                 ` Hibou57 (Yannick Duchêne)
@ 2009-02-25 15:57                 ` (see below)
  2009-02-25 22:14                 ` Adam Beneschan
  2 siblings, 0 replies; 91+ messages in thread
From: (see below) @ 2009-02-25 15:57 UTC (permalink / raw)


On 25/02/2009 08:05, in article ygeab8bvt3s.fsf@sparre-andersen.dk, "Jacob
Sparre Andersen" <sparre@nbi.dk> wrote:

> Bill wrote:
>> Martin wrote:
> 
>>> Sorry my made up example doesn't cut mustard! Does this make it any
>>> clearer? :-)
>>> 
>>> ------------------------
>>> -- Calculate_Velocity --
>>> ------------------------
>>> 
>>> procedure Calculate_Velocity
>>>              (Speed    :     Meters_Per_Second;
>>>               Time     :     Seconds;
>>>               Velocity : out Meters_Per_Second_Per_Second);
>> 
>> Nope!
>> The reason why is left as an exercise for the student. 8-)
> 
> I'm not really a student any more, but now that the students have had
> their chance ...
> 
> There are several problems with this:
> 
>  + The subroutine doesn't do what its name says it does (physicists
>    see this easily).

Yup.
 
>  + Comments are inherently dangerous (since they are not checked by
>    the compiler).

And again.

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25  8:59                 ` Hibou57 (Yannick Duchêne)
@ 2009-02-25 16:10                   ` (see below)
  2009-02-25 18:13                     ` Georg Bauhaus
  2009-02-26  3:20                     ` Hibou57 (Yannick Duchêne)
  0 siblings, 2 replies; 91+ messages in thread
From: (see below) @ 2009-02-25 16:10 UTC (permalink / raw)


On 25/02/2009 08:59, in article
4013d6a4-f4f4-4d6e-92bd-161687608db9@w9g2000yqa.googlegroups.com, "Hibou57
(Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote:

> To say that these comments does not offer any value, ... it is a
> valuable point of view (as is as much the one which says that it may
> be useful for visual seeking).

It is not at all clear who you are replying to, but I take it to be me.

> But the to comment on comments asserting it is unuseful and dangerous,
> is another matter.

Indeed, it is more insightful and accurate to say the letter. 8-)

[...] 
> A source without comments, is a source which hides every thing.

Please note that I did NOT say that source should be without comments.
 
> If comments are dangerous, so the human though which drives the
> application developpement (or order it), is as much dangerous.

True, but the compiler checks the human (through their code).
It does not check the comments.
 
> I agree that comments may be dangerous when these are not up to date,
> but this is another matter.

No, it is not another matter.

> Did you ever tried to come back to you own code two years, three years

I have code that I wrote 40 years ago, and I can easily follow it.
That is because I did the work needed to made it understandable.
(That included writing a few, judicious, comments.)

> later ? I use to do, on some application I lacked to comment.... the
> only one thing I could do was to regret this lack, and restart the
> whole work, without forgetting comments the second time.

How much better to have written the code comprehensibly the first time!

> Well, perhpaps it should be worth to point about the life cycle. If
> you are talking about very short life cycle applications, then, I
> agree.... you can drop comments. But if not, you will inevitably face
> a fact : meanings, purpose and implementations are not the same
> things. There is code for implementations and purposes, and comments
> for purposes and meanings.

Agreed, if we extend <comments> to <documentation>.

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25  0:08               ` Martin
  2009-02-25  0:52                 ` Adam Beneschan
  2009-02-25  1:45                 ` (see below)
@ 2009-02-25 16:38                 ` Martin
  2009-02-25 21:03                   ` Adam Beneschan
  2 siblings, 1 reply; 91+ messages in thread
From: Martin @ 2009-02-25 16:38 UTC (permalink / raw)


On Feb 25, 12:08 am, Martin <martin.do...@btopenworld.com> wrote:
> On Feb 24, 11:33 pm, "(see below)" <yaldni...@blueyonder.co.uk> wrote:
>
>
>
> > On 24/02/2009 23:28, in article
> > 9f2553d3-66f5-4708-a237-bfef1d840...@v42g2000yqj.googlegroups.com, "Martin"
>
> > <martin.do...@btopenworld.com> wrote:
> > > Sorry my made up example doesn't cut mustard! Does this make it any
> > > clearer? :-)
>
> > > ------------------------
> > > -- Calculate_Velocity --
> > > ------------------------
>
> > > procedure Calculate_Velocity
> > >              (Speed    :     Meters_Per_Second;
> > >               Time     :     Seconds;
> > >               Velocity : out Meters_Per_Second_Per_Second);
>
> > Nope!
> > The reason why is left as an exercise for the student. 8-)
>
> > --
> > Bill Findlay
> > <surname><forename> chez blueyonder.co.uk
>
> Hmmm, the tautology? I'm using C too much these days...
>
> ---------------
> -- Calculate --
> ---------------
>
> procedure Calculate (Speed    :     Meters_Per_Second;
>                      Time     :     Seconds;
>                      Velocity : out Meters_Per_Second_Per_Second);

It's a 'doh' moment... Velocity - no, Acceleration - yes (and change
'Speed' to 'Velocity').

Must stop typing at 11:33pm... :-)

Cheers
-- Martin



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 16:10                   ` (see below)
@ 2009-02-25 18:13                     ` Georg Bauhaus
  2009-02-25 18:53                       ` (see below)
                                         ` (3 more replies)
  2009-02-26  3:20                     ` Hibou57 (Yannick Duchêne)
  1 sibling, 4 replies; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-25 18:13 UTC (permalink / raw)


(see below) schrieb:
> On 25/02/2009 08:59, in article
> 4013d6a4-f4f4-4d6e-92bd-161687608db9@w9g2000yqa.googlegroups.com, "Hibou57
> (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote:

>> If comments are dangerous, so the human though which drives the
>> application developpement (or order it), is as much dangerous.
> 
> True, but the compiler checks the human (through their code).
> It does not check the comments.

All the more we could profit from pre/post assertions
and invariant type constraints specified by the programmer.
Perfectly clear, checkable, and international.

Doesn't someone have the ressouces to help Randy Brukardt
continue his work on these?  Please! :-) :-) :-)



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 18:13                     ` Georg Bauhaus
@ 2009-02-25 18:53                       ` (see below)
  2009-02-25 19:19                         ` Georg Bauhaus
  2009-02-25 19:17                       ` Dmitry A. Kazakov
                                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 91+ messages in thread
From: (see below) @ 2009-02-25 18:53 UTC (permalink / raw)


On 25/02/2009 18:13, in article
49a58a60$0$30235$9b4e6d93@newsspool1.arcor-online.net, "Georg Bauhaus"
<rm.dash-bauhaus@futureapps.de> wrote:

> (see below) schrieb:
>> On 25/02/2009 08:59, in article
>> 4013d6a4-f4f4-4d6e-92bd-161687608db9@w9g2000yqa.googlegroups.com, "Hibou57
>> (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote:
> 
>>> If comments are dangerous, so the human though which drives the
>>> application developpement (or order it), is as much dangerous.
>> 
>> True, but the compiler checks the human (through their code).
>> It does not check the comments.
> 
> All the more we could profit from pre/post assertions
> and invariant type constraints specified by the programmer.
> Perfectly clear, checkable, and international.
> 
> Doesn't someone have the ressouces to help Randy Brukardt
> continue his work on these?  Please! :-) :-) :-)

Could I encourage Randy to say something about this?
I had not heard of this work before, and it sounds very valuable.

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 18:13                     ` Georg Bauhaus
  2009-02-25 18:53                       ` (see below)
@ 2009-02-25 19:17                       ` Dmitry A. Kazakov
  2009-02-25 22:48                       ` Robert A Duff
  2009-02-26  3:21                       ` Hibou57 (Yannick Duchêne)
  3 siblings, 0 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-25 19:17 UTC (permalink / raw)


On Wed, 25 Feb 2009 19:13:51 +0100, Georg Bauhaus wrote:

> (see below) schrieb:
>> On 25/02/2009 08:59, in article
>> 4013d6a4-f4f4-4d6e-92bd-161687608db9@w9g2000yqa.googlegroups.com, "Hibou57
>> (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote:
> 
>>> If comments are dangerous, so the human though which drives the
>>> application developpement (or order it), is as much dangerous.
>> 
>> True, but the compiler checks the human (through their code).
>> It does not check the comments.
> 
> All the more we could profit from pre/post assertions
> and invariant type constraints specified by the programmer.
> Perfectly clear, checkable, and international.

The danger of astray comments is that the program is not checked against
them. Pre-/postconditions aren't checkable in exactly same way as comments
aren't. It is the program which becomes checkable in presence of [static]
pre-/postconditions, not the conditions themselves.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 18:53                       ` (see below)
@ 2009-02-25 19:19                         ` Georg Bauhaus
  2009-02-27 23:53                           ` Randy Brukardt
  0 siblings, 1 reply; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-25 19:19 UTC (permalink / raw)


(see below) schrieb:

>> All the more we could profit from pre/post assertions
>> and invariant type constraints specified by the programmer.
>> Perfectly clear, checkable, and international.
>>
>> Doesn't someone have the ressouces to help Randy Brukardt
>> continue his work on these?  Please! :-) :-) :-)
> 
> Could I encourage Randy to say something about this?
> I had not heard of this work before, and it sounds very valuable.
> 

There is a longer thread entitled "contracts in Ada" on the
Ada Comments mailing list, started by Robert Duff discussing
"AI95-00288 (and perhaps AI95-00375)" on Jan 10th 2009.
This is archived, there is a description of a procedure
for searching the archives in
http://www.adaic.org/standards/articles/comment.html
Haven't tried this myself, though.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 16:38                 ` Martin
@ 2009-02-25 21:03                   ` Adam Beneschan
  0 siblings, 0 replies; 91+ messages in thread
From: Adam Beneschan @ 2009-02-25 21:03 UTC (permalink / raw)


On Feb 25, 8:38 am, Martin <martin.do...@btopenworld.com> wrote:
> > ---------------
> > -- Calculate --
> > ---------------
>
> > procedure Calculate (Speed    :     Meters_Per_Second;
> >                      Time     :     Seconds;
> >                      Velocity : out Meters_Per_Second_Per_Second);
>
> It's a 'doh' moment... Velocity - no, Acceleration - yes (and change
> 'Speed' to 'Velocity').
>
> Must stop typing at 11:33pm... :-)
>
> Cheers
> -- Martin- Hide quoted text -
>
> - Show quoted text -

Well, you're partway there.  It still isn't clear from the profile of
this procedure what it does.  After all, if you have an object
traveling at velocity Velocity m/sec for a period of Time seconds,
what's the acceleration?  Zero, since it's not getting any faster over
that time.  And I presume you're not writing a procedure whose purpose
is just to return 0.0 every time, right?  So I still don't know what
this does.

                              -- Adam



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25  8:05               ` Jacob Sparre Andersen
  2009-02-25  8:59                 ` Hibou57 (Yannick Duchêne)
  2009-02-25 15:57                 ` (see below)
@ 2009-02-25 22:14                 ` Adam Beneschan
  2 siblings, 0 replies; 91+ messages in thread
From: Adam Beneschan @ 2009-02-25 22:14 UTC (permalink / raw)


On Feb 25, 12:05 am, Jacob Sparre Andersen <spa...@nbi.dk> wrote:

>  + Comments are inherently dangerous (since they are not checked by
>    the compiler).

I can't sign on to this last one.  If I'm maintaining someone else's
program and they've written a routine that doesn't work right, I'd
much rather have some comments indicating what the other programmer
THOUGHT they were accomplishing, than no comments at all.  I think I
see what you were trying to get at, that comments can mislead a reader
into thinking code does something that it doesn't.  But if that's the
case, removing the comments isn't going to make the code do the right
thing, is it?  So I fail to see how comments can be "dangerous" in the
sense that they could make any situation worse.

                                                -- Adam




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:01     ` Georg Bauhaus
  2009-02-24 23:47       ` Hibou57 (Yannick Duchêne)
@ 2009-02-25 22:15       ` Ivan Levashew
  1 sibling, 0 replies; 91+ messages in thread
From: Ivan Levashew @ 2009-02-25 22:15 UTC (permalink / raw)


Georg Bauhaus wrote:
> 
> Second, coding this algorithm in Ada or some other "real"
> language, I *have* to go outside the fundamental type system,
> because it does not have large numbers.  Worse,
> I start waving hands:
> "You know, just assume these magic types I gave you can
> deal with large whole numbers fine. I'm omitting the
> details of how this is possible etc etc."  What you loose,
> then, is what you wanted to add: precise explanation,
> of nothing but the algorithm!
> 

Those who write C and Python samples also wave hands describing every 
limitation of their implementation and implementation language, don't they?

-- 
If you want to get to the top, you have to start at the bottom



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 11:03 Invade wikipedia! Jean-Pierre Rosen
                   ` (3 preceding siblings ...)
  2009-02-24 19:29 ` Martin Krischik
@ 2009-02-25 22:31 ` Ivan Levashew
  2009-02-25 23:07   ` Jeffrey R. Carter
                     ` (3 more replies)
  4 siblings, 4 replies; 91+ messages in thread
From: Ivan Levashew @ 2009-02-25 22:31 UTC (permalink / raw)


Jean-Pierre Rosen wrote:

Just one problem: how should we output Integers? Every mean is broken.
Integer'Image issues a stupid space before positive integers. 
Ada.Integer_IO also outputs stupid spaces. It took me not that long to 
provide Integer'Image wrapper, but I don't want this ugly face of Ada to 
show on every sample that is about to output something.

It would be nice to have an agreement on what non-standard library to 
consider common so that everybody can refer to it as if it was really 
common. Image functions exist in PragmaRC, AdaCL, AWS.Utils, but every 
of these functions can only deal with Naturals last time I checked them. 
What's the hell?

-- 
If you want to get to the top, you have to start at the bottom



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 18:13                     ` Georg Bauhaus
  2009-02-25 18:53                       ` (see below)
  2009-02-25 19:17                       ` Dmitry A. Kazakov
@ 2009-02-25 22:48                       ` Robert A Duff
  2009-02-26  3:21                       ` Hibou57 (Yannick Duchêne)
  3 siblings, 0 replies; 91+ messages in thread
From: Robert A Duff @ 2009-02-25 22:48 UTC (permalink / raw)


Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

> (see below) schrieb:
>> On 25/02/2009 08:59, in article
>> 4013d6a4-f4f4-4d6e-92bd-161687608db9@w9g2000yqa.googlegroups.com, "Hibou57
>> (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote:
>
>>> If comments are dangerous, so the human though which drives the
>>> application developpement (or order it), is as much dangerous.
>> 
>> True, but the compiler checks the human (through their code).
>> It does not check the comments.
>
> All the more we could profit from pre/post assertions
> and invariant type constraints specified by the programmer.
> Perfectly clear, checkable, and international.
>
> Doesn't someone have the ressouces to help Randy Brukardt
> continue his work on these?  Please! :-) :-) :-)

Both ARG and AdaCore are actively working on these things.

The latest GNAT compiler has some support for pre- and postconditions.
No invariants, yet.  Invariants are the most important thing, IMHO,
but it's not easy to figure out the right semantics.  I am currently
pushing for invariants on subtypes (not just types).

- Bob



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 22:31 ` Ivan Levashew
@ 2009-02-25 23:07   ` Jeffrey R. Carter
  2009-02-26  0:44   ` Georg Bauhaus
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 91+ messages in thread
From: Jeffrey R. Carter @ 2009-02-25 23:07 UTC (permalink / raw)


Ivan Levashew wrote:
> 
> It would be nice to have an agreement on what non-standard library to 
> consider common so that everybody can refer to it as if it was really 
> common. Image functions exist in PragmaRC, AdaCL, AWS.Utils, but every 
> of these functions can only deal with Naturals last time I checked them. 
> What's the hell?

The PragmARCs can provide Image functions for any integer type, signed or 
modular. The predefined instantiation is for Integer, since it's the only 
predefined integer type required of all implementations.

-- 
Jeff Carter
"You me on the head hitted."
Never Give a Sucker an Even Break
108



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 22:31 ` Ivan Levashew
  2009-02-25 23:07   ` Jeffrey R. Carter
@ 2009-02-26  0:44   ` Georg Bauhaus
  2009-02-26  8:29   ` Dmitry A. Kazakov
  2009-02-26 10:40   ` Jean-Pierre Rosen
  3 siblings, 0 replies; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-26  0:44 UTC (permalink / raw)


Ivan Levashew wrote:
> Just one problem: how should we output Integers? 

I understand that many integers reflect some measurement,
some amount, etc.  These are typically aligned in columns.
Ada is quite good at making columns. If the Cobol Annex
(sorry, Text_IO.Editing) is supported, it is hard to beat.

Just my ##0.02€



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-24 23:47       ` Hibou57 (Yannick Duchêne)
@ 2009-02-26  0:52         ` Georg Bauhaus
  2009-02-26  3:33           ` Hibou57 (Yannick Duchêne)
  0 siblings, 1 reply; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-26  0:52 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:

>>> If this kind of pseudo code was suffiscient to really and precisely
>>> express algorithms, it would be a real language.
>> Pseudo code of the kind in question is a real language.
>> By analogy, no one writes Turing machine programs in
>> commercial applications[***]. Still, his fictional(!)
>> machine is entirely programmed using "pseudo code"[****].
>> A Turing machine is defined precisely and
>> its languages are real programming languages.
> When I read you, I'm thinking about something like LISP. Is that Ok if
> got this image in mind ?

The gist of it is that there is a sufficiently small
and simple language and machine model to work with.

Maybe SPARK minus the annotation language plus
I/O, recursion, and named pointers is a good one?



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 16:10                   ` (see below)
  2009-02-25 18:13                     ` Georg Bauhaus
@ 2009-02-26  3:20                     ` Hibou57 (Yannick Duchêne)
  1 sibling, 0 replies; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-26  3:20 UTC (permalink / raw)


On 25 fév, 17:10, "(see below)" <yaldni...@blueyonder.co.uk> wrote:
> How much better to have written the code comprehensibly the first time!
>
> Bill Findlay

I missing the road map which could have helped me. It was quite easy
to understand what was doing individual components, but not so quite
easy to understand how all these things were working together (and why
each component was there).

There was a lack of experience, probably, but comments would have
helped.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 18:13                     ` Georg Bauhaus
                                         ` (2 preceding siblings ...)
  2009-02-25 22:48                       ` Robert A Duff
@ 2009-02-26  3:21                       ` Hibou57 (Yannick Duchêne)
  2009-02-26 10:07                         ` Georg Bauhaus
  3 siblings, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-26  3:21 UTC (permalink / raw)


On 25 fév, 19:13, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> (see below) schrieb:

> Doesn't someone have the ressouces to help Randy Brukardt
> continue his work on these?  Please! :-) :-) :-)

Randy is working on SPARK ?



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26  0:52         ` Georg Bauhaus
@ 2009-02-26  3:33           ` Hibou57 (Yannick Duchêne)
  2009-02-26  6:38             ` Hibou57 (Yannick Duchêne)
  0 siblings, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-26  3:33 UTC (permalink / raw)


On 26 fév, 01:52, Georg Bauhaus <rm.tsoh.plus-
bug.bauh...@maps.futureapps.de> wrote:
> Hibou57 (Yannick Duchêne) wrote:
> >>> If this kind of pseudo code was suffiscient to really and precisely
> >>> express algorithms, it would be a real language.
> >> Pseudo code of the kind in question is a real language.
> >> By analogy, no one writes Turing machine programs in
> >> commercial applications[***]. Still, his fictional(!)
> >> machine is entirely programmed using "pseudo code"[****].
> >> A Turing machine is defined precisely and
> >> its languages are real programming languages.
> > When I read you, I'm thinking about something like LISP. Is that Ok if
> > got this image in mind ?
>
> The gist of it is that there is a sufficiently small
> and simple language and machine model to work with.

I like this abstract very much. Thanks for this sentence.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26  3:33           ` Hibou57 (Yannick Duchêne)
@ 2009-02-26  6:38             ` Hibou57 (Yannick Duchêne)
  0 siblings, 0 replies; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-26  6:38 UTC (permalink / raw)


What about comment versionning ?

I will not talk about type checking with comments, but versioning of
comments checked against versioning of the corresponding par of code,
will allow iterative reviews of comments in order to ensure that both
the code is a correct answer to what is stated buy the comments and
that comments has trustable statements about the code.

Versioning could be the comments counterpart of type/signature
checking in codes.

Any way, as there are many langages around there, there will be
undoubtly at least as many possible formalisms for properly useful
comments.

About me, I'm oftenly thinking about something like some kind of
attributes to describe implementation properties/roles (simple nesting
of methods and packages - when avlailable - does not fullfil all of
the possible and useful categorizations of code, whose pieces most of
time belongs to multiple views which does not defines a partition).



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 22:31 ` Ivan Levashew
  2009-02-25 23:07   ` Jeffrey R. Carter
  2009-02-26  0:44   ` Georg Bauhaus
@ 2009-02-26  8:29   ` Dmitry A. Kazakov
  2009-02-26 10:40   ` Jean-Pierre Rosen
  3 siblings, 0 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-26  8:29 UTC (permalink / raw)


On Thu, 26 Feb 2009 04:31:39 +0600, Ivan Levashew wrote:

> Just one problem: how should we output Integers? Every mean is broken.
> Integer'Image issues a stupid space before positive integers. 
> Ada.Integer_IO also outputs stupid spaces. It took me not that long to 
> provide Integer'Image wrapper, but I don't want this ugly face of Ada to 
> show on every sample that is about to output something.

I don't think 'Image output is ugly. What is indeed ugly is that it is not
a primitive operation of the corresponding type. T'Image is just
unacceptable for a language claiming to be an OOPL.

> It would be nice to have an agreement on what non-standard library to 
> consider common so that everybody can refer to it as if it was really 
> common. Image functions exist in PragmaRC, AdaCL, AWS.Utils, but every 
> of these functions can only deal with Naturals last time I checked them. 

Strings_Edit has a right Image function for Integer (and for Float too)

   http://www.dmitry-kazakov.de/ada/strings_edit.htm

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26  3:21                       ` Hibou57 (Yannick Duchêne)
@ 2009-02-26 10:07                         ` Georg Bauhaus
  0 siblings, 0 replies; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-26 10:07 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) schrieb:
> On 25 f�v, 19:13, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
>> (see below) schrieb:
> 
>> Doesn't someone have the ressouces to help Randy Brukardt
>> continue his work on these?  Please! :-) :-) :-)
> 
> Randy is working on SPARK ?

Since Ada is a bit larger a language than SPARK, I'd doubt it.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 22:31 ` Ivan Levashew
                     ` (2 preceding siblings ...)
  2009-02-26  8:29   ` Dmitry A. Kazakov
@ 2009-02-26 10:40   ` Jean-Pierre Rosen
  2009-02-26 13:53     ` Ivan Levashew
  3 siblings, 1 reply; 91+ messages in thread
From: Jean-Pierre Rosen @ 2009-02-26 10:40 UTC (permalink / raw)


Ivan Levashew a �crit :
> Jean-Pierre Rosen wrote:
> 
> Just one problem: how should we output Integers? Every mean is broken.
> Integer'Image issues a stupid space before positive integers.
> Ada.Integer_IO also outputs stupid spaces. It took me not that long to
> provide Integer'Image wrapper, but I don't want this ugly face of Ada to
> show on every sample that is about to output something.
> 
Just use Integer_Text_IO, and forget about the stupid space.
Anyway, most of the time, the space is useful, and we are just showing
examples. Most readers won't effectively compile the example, therefore
they won't notice (tongue slightly in cheek).


-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 10:40   ` Jean-Pierre Rosen
@ 2009-02-26 13:53     ` Ivan Levashew
  2009-02-26 14:13       ` Jean-Pierre Rosen
                         ` (2 more replies)
  0 siblings, 3 replies; 91+ messages in thread
From: Ivan Levashew @ 2009-02-26 13:53 UTC (permalink / raw)


Jean-Pierre Rosen wrote:

> Just use Integer_Text_IO, and forget about the stupid space.

xen:~/just_test OCTAGRAM$ nano aitio.adb
xen:~/just_test OCTAGRAM$ ada_mode
xen:~/just_test OCTAGRAM$ gnatmake aitio.adb
gcc -c aitio.adb
gnatbind -aO./ -C -I- -x aitio.ali
gnatlink aitio.ali -C --GCC=/usr/local/ada-build/friendly/gcc
xen:~/just_test OCTAGRAM$ ./aitio
 >>>          8<<<
xen:~/just_test OCTAGRAM$ cat aitio.adb
with Ada.Text_IO;
with Ada.Integer_Text_IO;

use Ada;

procedure AITIO is

begin
    Text_IO.Put (">>>");
    Integer_Text_IO.Put (8);
    Text_IO.Put_Line ("<<<");
end AITIO;
xen:~/just_test OCTAGRAM$


It's broken either! I know how to fix it:

xen:~/just_test OCTAGRAM$ nano aitio.adb
xen:~/just_test OCTAGRAM$ gnatmake aitio.adb
gcc -c aitio.adb
gnatbind -aO./ -C -I- -x aitio.ali
gnatlink aitio.ali -C --GCC=/usr/local/ada-build/friendly/gcc
xen:~/just_test OCTAGRAM$ ./aitio
 >>>8<<<
xen:~/just_test OCTAGRAM$ cat aitio.adb
with Ada.Text_IO;
with Ada.Integer_Text_IO;

use Ada;

procedure AITIO is

begin
    Text_IO.Put (">>>");
    Integer_Text_IO.Put (8, Width => 0);
    Text_IO.Put_Line ("<<<");
end AITIO;
xen:~/just_test OCTAGRAM$

But, once again, it looks stupid.

> Anyway, most of the time, the space is useful,

Integer'Image (-2) = "-2" -- no space here no matter how useful it is

-- 
If you want to get to the top, you have to start at the bottom



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 13:53     ` Ivan Levashew
@ 2009-02-26 14:13       ` Jean-Pierre Rosen
  2009-02-26 15:42         ` Peter Hermann
  2009-02-26 16:37         ` Adam Beneschan
  2009-02-26 14:20       ` Dmitry A. Kazakov
  2009-02-26 17:44       ` Georg Bauhaus
  2 siblings, 2 replies; 91+ messages in thread
From: Jean-Pierre Rosen @ 2009-02-26 14:13 UTC (permalink / raw)


Ivan Levashew a �crit :
[...]
>    Integer_Text_IO.Put (8, Width => 0);
> [...]
> But, once again, it looks stupid.
The output is the same, and it looks less stupid if you write:
    Integer_Text_IO.Put (8, Width => 1);

> Integer'Image (-2) = "-2" -- no space here no matter how useful it is
> 
The whole idea of text_io was to make well aligned columns, which is
sensible for files (as opposed to user messages on the terminal). The
damn space was simply felt more elegant than a '+' in front of positive
numbers.

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 13:53     ` Ivan Levashew
  2009-02-26 14:13       ` Jean-Pierre Rosen
@ 2009-02-26 14:20       ` Dmitry A. Kazakov
  2009-02-26 17:44       ` Georg Bauhaus
  2 siblings, 0 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-26 14:20 UTC (permalink / raw)


On Thu, 26 Feb 2009 19:53:57 +0600, Ivan Levashew wrote:

> Jean-Pierre Rosen wrote:
> 
>> Anyway, most of the time, the space is useful,
> 
> Integer'Image (-2) = "-2" -- no space here no matter how useful it is

Well, space was not meant to be a delimiter, but a placeholder of sign.
Granted, that does not make much sense because the output width is not
fixed.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 14:13       ` Jean-Pierre Rosen
@ 2009-02-26 15:42         ` Peter Hermann
  2009-02-26 16:37         ` Adam Beneschan
  1 sibling, 0 replies; 91+ messages in thread
From: Peter Hermann @ 2009-02-26 15:42 UTC (permalink / raw)


Jean-Pierre Rosen <rosen@adalog.fr> wrote:
> The whole idea of text_io was to make well aligned columns, which is

OTOH (-:
 1 1 1
 22 22 22
 333 333 333




^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 14:13       ` Jean-Pierre Rosen
  2009-02-26 15:42         ` Peter Hermann
@ 2009-02-26 16:37         ` Adam Beneschan
  2009-02-26 17:57           ` Jean-Pierre Rosen
  1 sibling, 1 reply; 91+ messages in thread
From: Adam Beneschan @ 2009-02-26 16:37 UTC (permalink / raw)


On Feb 26, 6:13 am, Jean-Pierre Rosen <ro...@adalog.fr> wrote:
> Ivan Levashew a écrit :
> [...]>    Integer_Text_IO.Put (8, Width => 0);
> > [...]
> > But, once again, it looks stupid.
>
> The output is the same, and it looks less stupid if you write:
>     Integer_Text_IO.Put (8, Width => 1);
>
> > Integer'Image (-2) = "-2" -- no space here no matter how useful it is
>
> The whole idea of text_io was to make well aligned columns, which is
> sensible for files (as opposed to user messages on the terminal). The
> damn space was simply felt more elegant than a '+' in front of positive
> numbers.

Yeah, but since 'Image doesn't yield a fixed-length string, the
aligned column argument doesn't make a lot of sense.  I can see how it
makes sense for Text_IO, but not for 'Image.

Although people can try to come up with legitimate-sounding reasons
why 'Image was defined the way it was, I think this is just one of
those features that causes language designers to look back and say
"what the #$*&(#@ were we thinking?!?!?"  Unfortunately, they can't go
back and change it now.  And we now have Ada.Fixed_Strings.Trim to
make things a little more tolerable, and other library packages to do
things the way they should have been done in the first place.

                                  -- Adam



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 13:53     ` Ivan Levashew
  2009-02-26 14:13       ` Jean-Pierre Rosen
  2009-02-26 14:20       ` Dmitry A. Kazakov
@ 2009-02-26 17:44       ` Georg Bauhaus
  2009-02-26 18:16         ` Adam Beneschan
  2 siblings, 1 reply; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-26 17:44 UTC (permalink / raw)


Ivan Levashew schrieb:
>    Integer_Text_IO.Put (8);

Integer should not be used in the first place,
and neither in examples ... (What do you mean by
Huh? :-)

When you have numeric types reflecting problem
properties, chances are you instantiate the
proper I/O generic with a suitable subtype.
At that point, you can set Default_Width := 1;

That causes comparative length, just as there
is a useful section at the head of a decent
Cobol program, I should think.
Someone with convincing arguments would have
to explain these efforts for "just some numbers"...



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 16:37         ` Adam Beneschan
@ 2009-02-26 17:57           ` Jean-Pierre Rosen
  0 siblings, 0 replies; 91+ messages in thread
From: Jean-Pierre Rosen @ 2009-02-26 17:57 UTC (permalink / raw)


Adam Beneschan a �crit :

> Yeah, but since 'Image doesn't yield a fixed-length string, the
> aligned column argument doesn't make a lot of sense.  I can see how it
> makes sense for Text_IO, but not for 'Image.
> 
OK, if it hurts, don't scrach it! Use 'Image for debugging purpose, and
Text_IO for the real stuff.

Oh, and there is another good reason to prefer text_io: if you Put a
'image on a fixed line length file, the number (actually the string
representing it) can be wrapped in the middle. If you use a put for your
type and the line is not long enough to hold it, you'll get a clean
New_Line and the number will appear (in full) on the next line.

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 17:44       ` Georg Bauhaus
@ 2009-02-26 18:16         ` Adam Beneschan
  2009-02-27 11:30           ` Georg Bauhaus
  0 siblings, 1 reply; 91+ messages in thread
From: Adam Beneschan @ 2009-02-26 18:16 UTC (permalink / raw)


On Feb 26, 9:44 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
> Ivan Levashew schrieb:
>
> >    Integer_Text_IO.Put (8);
>
> Integer should not be used in the first place,
> and neither in examples ... (What do you mean by
> Huh? :-)

Hmmm... This thread started out with a request that we increase the
visibility of Ada by providing examples for some Wikipedia algorithms
written in Ada.  What better way to get people interested in the
language than by making it seem that you have to define your own
numeric types before you can write any code?  :) :( :-|

                                 -- Adam



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-26 18:16         ` Adam Beneschan
@ 2009-02-27 11:30           ` Georg Bauhaus
  2009-02-27 17:33             ` Dmitry A. Kazakov
  0 siblings, 1 reply; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-27 11:30 UTC (permalink / raw)


Adam Beneschan schrieb:
> On Feb 26, 9:44 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
> wrote:
>> Ivan Levashew schrieb:
>>
>>>    Integer_Text_IO.Put (8);
>> Integer should not be used in the first place,
>> and neither in examples ... (What do you mean by
>> Huh? :-)
> 
> Hmmm... This thread started out with a request that we increase the
> visibility of Ada by providing examples for some Wikipedia algorithms
> written in Ada.  What better way to get people interested in the
> language than by making it seem that you have to define your own
> numeric types before you can write any code?  :) :( :-|

Adding the declarations of suitable number types in an example
algorithm maybe doesn't seem to hurt that much. Taking
http://en.wikipedia.org/wiki/Insertion_sort  as an example,
I tried

   type Mug is (Metal, Plastic, Thermo, Porcelain);
   type Mug_Number is range 1 .. 10;
   type Mug_List is array(Mug_Number) of Mug;

   procedure Insertion_Sort(A: in out Mug_List) is
      j: Mug_Number'Base;
      value: Mug;
   begin
      for i in A'First + 1 .. A'Last loop
           value := A(i);
           j := i-1;
           while j >= A'First and then A(j) > value loop
                A(j+1) := A(j);
                j := j-1;
           end loop;
           A(j+1) := value;
      end loop;
   end Insertion_Sort;

No big changes due to going from Pseudo-Pascal to real Ada,
I think, other than having to explain 'Base.
The "and then" of the shifting loop actually clarifies that
short circuit control is required.

If the Wikipedia example authors could agree on an example
problem space (like Mugs in this case), then even the three
declaractions before Insertion_Sort could be left out.
Instead, a simple with will do, or as custom seems to permit,
visibility of the problem space declarations is always assumed.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-27 11:30           ` Georg Bauhaus
@ 2009-02-27 17:33             ` Dmitry A. Kazakov
  2009-02-27 23:31               ` Georg Bauhaus
                                 ` (3 more replies)
  0 siblings, 4 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-02-27 17:33 UTC (permalink / raw)


On Fri, 27 Feb 2009 12:30:25 +0100, Georg Bauhaus wrote:

> Adding the declarations of suitable number types in an example
> algorithm maybe doesn't seem to hurt that much. Taking
> http://en.wikipedia.org/wiki/Insertion_sort  as an example,
> I tried
> 
>    type Mug is (Metal, Plastic, Thermo, Porcelain);
>    type Mug_Number is range 1 .. 10;
>    type Mug_List is array(Mug_Number) of Mug;
> 
>    procedure Insertion_Sort(A: in out Mug_List) is
>       j: Mug_Number'Base;
>       value: Mug;
>    begin
>       for i in A'First + 1 .. A'Last loop
>            value := A(i);
>            j := i-1;
>            while j >= A'First and then A(j) > value loop
>                 A(j+1) := A(j);
>                 j := j-1;
>            end loop;
>            A(j+1) := value;
>       end loop;
>    end Insertion_Sort;
> 
> No big changes due to going from Pseudo-Pascal to real Ada,
> I think, other than having to explain 'Base.
> The "and then" of the shifting loop actually clarifies that
> short circuit control is required.

You do not need T'Base in this case because it is cleaner and more 
efficient to rewrite it in a form that would always keep all indices within 
the array range:

   procedure Insertion_Sort (A: in out Mug_List) is
   begin
      for I in A'First + 1..A'Last loop
         declare
            Value : constant Mug := A (I);
            J     : Mug_Number   := I - 1;
         begin
            while A (J) > Value loop
               A (J + 1) := A (J);
               exit when J = A'First;
               J := J - 1;
            end loop;
            A (J) := Value;
         end;
      end loop;
   end Insertion_Sort;

Of course an Ada purist would also replace integer index arithmetic with 
I'Succ and I'Pred. But that would likely be too much for wiki brains... 
(:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-27 17:33             ` Dmitry A. Kazakov
@ 2009-02-27 23:31               ` Georg Bauhaus
  2009-02-28  0:31                 ` Jeffrey R. Carter
  2009-02-28  5:26               ` Ivan Levashew
                                 ` (2 subsequent siblings)
  3 siblings, 1 reply; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-27 23:31 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

> You do not need T'Base in this case because it is cleaner and more 
> efficient to rewrite it in a form that would always keep all indices within 
> the array range

If you do this (remove the off-by-one decrement before loop
termination), you end up with two exits from a loop.
Algorithm guys might not find this clean at all...



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-25 19:19                         ` Georg Bauhaus
@ 2009-02-27 23:53                           ` Randy Brukardt
  2009-02-28  6:31                             ` Hibou57 (Yannick Duchêne)
  0 siblings, 1 reply; 91+ messages in thread
From: Randy Brukardt @ 2009-02-27 23:53 UTC (permalink / raw)


"Georg Bauhaus" <rm.dash-bauhaus@futureapps.de> wrote in message 
news:49a599ac$0$30225$9b4e6d93@newsspool1.arcor-online.net...
> (see below) schrieb:
>
>>> All the more we could profit from pre/post assertions
>>> and invariant type constraints specified by the programmer.
>>> Perfectly clear, checkable, and international.
>>>
>>> Doesn't someone have the ressouces to help Randy Brukardt
>>> continue his work on these?  Please! :-) :-) :-)
>>
>> Could I encourage Randy to say something about this?
>> I had not heard of this work before, and it sounds very valuable.
>>
>
> There is a longer thread entitled "contracts in Ada" on the
> Ada Comments mailing list, started by Robert Duff discussing
> "AI95-00288 (and perhaps AI95-00375)" on Jan 10th 2009.
> This is archived, there is a description of a procedure
> for searching the archives in
> http://www.adaic.org/standards/articles/comment.html
> Haven't tried this myself, though.

Actually, it is easier to see that thread by looking in AI05-0145-1 and 
AI05-0146-1. But a word of warning: we've changed those proposals a lot 
based on the discussions at last week's ARG meeting. So you may want to wait 
for the minutes of that meeting and the revised proposals (whenever they'll 
be done) before commenting on them. (In fact, I suspect we'd all appreciate 
it if you did that, because repeating previous discussions is no fun...)

                            Randy.





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-27 23:31               ` Georg Bauhaus
@ 2009-02-28  0:31                 ` Jeffrey R. Carter
  0 siblings, 0 replies; 91+ messages in thread
From: Jeffrey R. Carter @ 2009-02-28  0:31 UTC (permalink / raw)


Georg Bauhaus wrote:
> 
> If you do this (remove the off-by-one decrement before loop
> termination), you end up with two exits from a loop.
> Algorithm guys might not find this clean at all...

The "loop and a half" is a very common paradigm. Pascal, which enforced the 
1-exit-only philosophy (excluding gotos), didn't handle it well. The clearest 
way to express it is with an exit statement, which is why well designed 
SW-engineering languages such as Ada include it.

-- 
Jeff Carter
"I'm particularly glad that these lovely children were
here today to hear that speech. Not only was it authentic
frontier gibberish, it expressed a courage little seen
in this day and age."
Blazing Saddles
88



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-27 17:33             ` Dmitry A. Kazakov
  2009-02-27 23:31               ` Georg Bauhaus
@ 2009-02-28  5:26               ` Ivan Levashew
  2009-02-28  6:27                 ` Hibou57 (Yannick Duchêne)
  2009-02-28  6:40                 ` Jeffrey R. Carter
  2009-03-03 14:16               ` Anders Wirzenius
  2009-03-04 13:20               ` Stuart
  3 siblings, 2 replies; 91+ messages in thread
From: Ivan Levashew @ 2009-02-28  5:26 UTC (permalink / raw)


Dmitry A. Kazakov wrote:
> 
> You do not need T'Base in this case because it is cleaner and more 
> efficient to rewrite it in a form that would always keep all indices within 
> the array range:
> 
>    procedure Insertion_Sort (A: in out Mug_List) is
>    begin
>       for I in A'First + 1..A'Last loop
>          declare
>             Value : constant Mug := A (I);
>             J     : Mug_Number   := I - 1;
>          begin
>             while A (J) > Value loop
>                A (J + 1) := A (J);
>                exit when J = A'First;
>                J := J - 1;
>             end loop;
>             A (J) := Value;
>          end;
>       end loop;
>    end Insertion_Sort;
> 
> Of course an Ada purist would also replace integer index arithmetic with 
> I'Succ and I'Pred. But that would likely be too much for wiki brains... 
> (:-))
> 
By the way, I use to indent 'exit when' the same as surrounding
loop-end-loop e. g.

loop
    Read_Next_Value;
exit when Is_Done;
    Process_Value;
end loop;

-- 
If you want to get to the top, you have to start at the bottom



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-28  5:26               ` Ivan Levashew
@ 2009-02-28  6:27                 ` Hibou57 (Yannick Duchêne)
  2009-02-28  6:40                 ` Jeffrey R. Carter
  1 sibling, 0 replies; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-28  6:27 UTC (permalink / raw)


On 28 fév, 06:26, Ivan Levashew <octag...@bluebottle.com> wrote:
>
> By the way, I use to indent 'exit when' the same as surrounding
> loop-end-loop e. g.
>
> loop
>     Read_Next_Value;
> exit when Is_Done;
>     Process_Value;
> end loop;
>
> --
> If you want to get to the top, you have to start at the bottom

This make the loop structure more visible at first sight. The Ada
"exit" statement is nice in there, beceause it start straight with
"exit" which make it more visible than with any construct like "if ...
then exit"



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-27 23:53                           ` Randy Brukardt
@ 2009-02-28  6:31                             ` Hibou57 (Yannick Duchêne)
  2009-02-28  8:49                               ` Ivan Levashew
  0 siblings, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-28  6:31 UTC (permalink / raw)


On 28 fév, 00:53, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> Actually, it is easier to see that thread by looking in AI05-0145-1 and
> AI05-0146-1. But a word of warning: we've changed those proposals a lot
> based on the discussions at last week's ARG meeting. So you may want to wait
> for the minutes of that meeting and the revised proposals (whenever they'll
> be done) before commenting on them. (In fact, I suspect we'd all appreciate
> it if you did that, because repeating previous discussions is no fun...)
>
>                             Randy.

I've just looked at the "pragma postcondition" and etc. Exactly the
same when we were talking about Eiffel pre/post conditions.

So it is planed for Ada 2015 ?

By the way, I've seen a "It's BAAACCKK!!: In Out parameters for
functions" not far from there



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-28  5:26               ` Ivan Levashew
  2009-02-28  6:27                 ` Hibou57 (Yannick Duchêne)
@ 2009-02-28  6:40                 ` Jeffrey R. Carter
  2009-02-28  7:01                   ` Hibou57 (Yannick Duchêne)
  1 sibling, 1 reply; 91+ messages in thread
From: Jeffrey R. Carter @ 2009-02-28  6:40 UTC (permalink / raw)


Ivan Levashew wrote:
>>
> By the way, I use to indent 'exit when' the same as surrounding
> loop-end-loop e. g.
> 
> loop
>    Read_Next_Value;
> exit when Is_Done;
>    Process_Value;
> end loop;

I understand the thinking behind this, and have considered doing it, but it 
doesn't seem to work well when exiting from a loop other than the innermost loop.

-- 
Jeff Carter
"I'm particularly glad that these lovely children were
here today to hear that speech. Not only was it authentic
frontier gibberish, it expressed a courage little seen
in this day and age."
Blazing Saddles
88



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-28  6:40                 ` Jeffrey R. Carter
@ 2009-02-28  7:01                   ` Hibou57 (Yannick Duchêne)
  2009-02-28 11:45                     ` Georg Bauhaus
  0 siblings, 1 reply; 91+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2009-02-28  7:01 UTC (permalink / raw)


On 28 fév, 07:40, "Jeffrey R. Carter" <spam.jrcarter....@spam.acm.org>
wrote:
> Ivan Levashew wrote:
> I understand the thinking behind this, and have considered doing it, but it
> doesn't seem to work well when exiting from a loop other than the innermost loop.
>
> --
> Jeff Carter

Why so ? Doesn't work well ?
If you have multiple loops nested loop, you may wish to use named
loop, as in

Label1: loop
   ....
   do the stuff
   Label2: loop
      ...
      do the other inner stuff
      ...
   exit Label2 when ConditionA;
      ...
exit Label1 when ConditionB;
      ...
   end loop Label2;
   ...
exit Label1 when ConditionC;
   ...
end loop Label1;


A syntax highlighter make things looks even more clear (ex. "exit" may
be displayed as bold text)



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-28  6:31                             ` Hibou57 (Yannick Duchêne)
@ 2009-02-28  8:49                               ` Ivan Levashew
  0 siblings, 0 replies; 91+ messages in thread
From: Ivan Levashew @ 2009-02-28  8:49 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:
> 
> So it is planed for Ada 2015 ?
> 
...or Ada 2005 R2
http://www.adaic.com/standards/ada1z.html

-- 
If you want to get to the top, you have to start at the bottom



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-28  7:01                   ` Hibou57 (Yannick Duchêne)
@ 2009-02-28 11:45                     ` Georg Bauhaus
  0 siblings, 0 replies; 91+ messages in thread
From: Georg Bauhaus @ 2009-02-28 11:45 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:

> If you have multiple loops nested loop, you may wish to use named
> loop, as in
> 
> Label1: loop
>    ....
>    do the stuff
>    Label2: loop
>       ...
>       do the other inner stuff
>       ...
>    exit Label2 when ConditionA;
>       ...
> exit Label1 when ConditionB;
>       ...
>    end loop Label2;
>    ...

To me, this indentation conveys contradictory information
at this point. I have already switched context to the
outer loop when the indentation of the "exit Label1" is back
to Label1's block level (of loop/end loop) even though
the outdented statement "belongs" to the inner loop.



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-27 17:33             ` Dmitry A. Kazakov
  2009-02-27 23:31               ` Georg Bauhaus
  2009-02-28  5:26               ` Ivan Levashew
@ 2009-03-03 14:16               ` Anders Wirzenius
  2009-03-03 15:34                 ` Dmitry A. Kazakov
  2009-03-04 13:20               ` Stuart
  3 siblings, 1 reply; 91+ messages in thread
From: Anders Wirzenius @ 2009-03-03 14:16 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

>    procedure Insertion_Sort (A: in out Mug_List) is
>    begin
>       for I in A'First + 1..A'Last loop
>          declare
>             Value : constant Mug := A (I);
>             J     : Mug_Number   := I - 1;
>          begin
>             while A (J) > Value loop
>                A (J + 1) := A (J);
>                exit when J = A'First;
>                J := J - 1;
>             end loop;
>             A (J) := Value;
              ^^^^^
How  about    A (J+1) := Value;

>          end;
>       end loop;
>    end Insertion_Sort;
>
> Of course an Ada purist would also replace integer index arithmetic with 
> I'Succ and I'Pred. But that would likely be too much for wiki brains... 
> (:-))

-- 
Anders



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-03-03 14:16               ` Anders Wirzenius
@ 2009-03-03 15:34                 ` Dmitry A. Kazakov
  2009-03-04  5:52                   ` Anders Wirzenius
  2009-03-04 13:31                   ` Stuart
  0 siblings, 2 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-03-03 15:34 UTC (permalink / raw)


On Tue, 03 Mar 2009 14:16:09 GMT, Anders Wirzenius wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>>    procedure Insertion_Sort (A: in out Mug_List) is
>>    begin
>>       for I in A'First + 1..A'Last loop
>>          declare
>>             Value : constant Mug := A (I);
>>             J     : Mug_Number   := I - 1;
>>          begin
>>             while A (J) > Value loop
>>                A (J + 1) := A (J);
>>                exit when J = A'First;
>>                J := J - 1;
>>             end loop;
>>             A (J) := Value;
>               ^^^^^
> How  about    A (J+1) := Value;

J+1 is always greater than A'First. Consider sorting (2, 1). 

>>          end;
>>       end loop;
>>    end Insertion_Sort;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-03-03 15:34                 ` Dmitry A. Kazakov
@ 2009-03-04  5:52                   ` Anders Wirzenius
  2009-03-04  9:19                     ` Dmitry A. Kazakov
  2009-03-04 13:31                   ` Stuart
  1 sibling, 1 reply; 91+ messages in thread
From: Anders Wirzenius @ 2009-03-04  5:52 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On Tue, 03 Mar 2009 14:16:09 GMT, Anders Wirzenius wrote:
>
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>> 
>>>    procedure Insertion_Sort (A: in out Mug_List) is
>>>    begin
>>>       for I in A'First + 1..A'Last loop
>>>          declare
>>>             Value : constant Mug := A (I);
>>>             J     : Mug_Number   := I - 1;
>>>          begin
>>>             while A (J) > Value loop
>>>                A (J + 1) := A (J);
>>>                exit when J = A'First;
>>>                J := J - 1;
>>>             end loop;
>>>             A (J) := Value;
>>               ^^^^^
>> How  about    A (J+1) := Value;
>
> J+1 is always greater than A'First. Consider sorting (2, 1). 
>
>>>          end;
>>>       end loop;
>>>    end Insertion_Sort;

Consider sorting (1,2). Then A (J) < Value and the procedure
jumps directly to A (J) := Value.

How about 

   procedure Insertion_Sort (A: in out Mug_List) is
   begin
      for I in A'First+1 .. A'Last loop
         declare
            Value : constant Mug := A (I);
            J     : Mug_Number   := I;
         begin
            loop
               exit when Value >= A (Mug_Number'Pred (J));
               A (J) := A (Mug_Number'Pred (J));
               J := Mug_Number'Pred (J);
               exit when J = A'First;
            end loop;
            A (J) := Value;
         end;
      end loop;
   end Insertion_Sort;

-- 
Anders



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-03-04  5:52                   ` Anders Wirzenius
@ 2009-03-04  9:19                     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-03-04  9:19 UTC (permalink / raw)


On Wed, 04 Mar 2009 05:52:56 GMT, Anders Wirzenius wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> On Tue, 03 Mar 2009 14:16:09 GMT, Anders Wirzenius wrote:
>>
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>> 
>>>>    procedure Insertion_Sort (A: in out Mug_List) is
>>>>    begin
>>>>       for I in A'First + 1..A'Last loop
>>>>          declare
>>>>             Value : constant Mug := A (I);
>>>>             J     : Mug_Number   := I - 1;
>>>>          begin
>>>>             while A (J) > Value loop
>>>>                A (J + 1) := A (J);
>>>>                exit when J = A'First;
>>>>                J := J - 1;
>>>>             end loop;
>>>>             A (J) := Value;
>>>               ^^^^^
>>> How  about    A (J+1) := Value;
>>
>> J+1 is always greater than A'First. Consider sorting (2, 1). 
>>
>>>>          end;
>>>>       end loop;
>>>>    end Insertion_Sort;
> 
> Consider sorting (1,2). Then A (J) < Value and the procedure
> jumps directly to A (J) := Value.

Yes, the inner loop should start at I: 

   while J > A'First and then A (J - 1) > Value loop
      A (J) := A (J - 1); 
      J := J - 1;
   end loop;
   A (J) := Value;

> How about 
> 
>    procedure Insertion_Sort (A: in out Mug_List) is
>    begin
>       for I in A'First+1 .. A'Last loop
>          declare
>             Value : constant Mug := A (I);
>             J     : Mug_Number   := I;
>          begin
>             loop
>                exit when Value >= A (Mug_Number'Pred (J));
>                A (J) := A (Mug_Number'Pred (J));
>                J := Mug_Number'Pred (J);
>                exit when J = A'First;
>             end loop;
>             A (J) := Value;
>          end;
>       end loop;
>    end Insertion_Sort;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-02-27 17:33             ` Dmitry A. Kazakov
                                 ` (2 preceding siblings ...)
  2009-03-03 14:16               ` Anders Wirzenius
@ 2009-03-04 13:20               ` Stuart
  2009-03-04 13:46                 ` Dmitry A. Kazakov
  3 siblings, 1 reply; 91+ messages in thread
From: Stuart @ 2009-03-04 13:20 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:t0tq29ariugm.aftb8vcp4aeg$.dlg@40tude.net...
> On Fri, 27 Feb 2009 12:30:25 +0100, Georg Bauhaus wrote:
>
>> Adding the declarations of suitable number types in an example
>> algorithm maybe doesn't seem to hurt that much. Taking
>> http://en.wikipedia.org/wiki/Insertion_sort  as an example,
>> I tried
>>
>>    type Mug is (Metal, Plastic, Thermo, Porcelain);
>>    type Mug_Number is range 1 .. 10;
>>    type Mug_List is array(Mug_Number) of Mug;
<snip>

> You do not need T'Base in this case because it is cleaner and more
> efficient to rewrite it in a form that would always keep all indices 
> within
> the array range:
>
>   procedure Insertion_Sort (A: in out Mug_List) is
>   begin
>      for I in A'First + 1..A'Last loop
>         declare
>            Value : constant Mug := A (I);
>            J     : Mug_Number   := I - 1;
>         begin
>            while A (J) > Value loop
>               A (J + 1) := A (J);
>               exit when J = A'First;
>               J := J - 1;
>            end loop;
>            A (J) := Value;
>         end;
>      end loop;
>   end Insertion_Sort;
>
> Of course an Ada purist would also replace integer index arithmetic with
> I'Succ and I'Pred. But that would likely be too much for wiki brains...
> (:-))

I looked at the following:

package Sort is
   type Element is new integer; -- or whatever
   type Element_Number is range 1..10; -- or whatever
   type List is array(Element_Number) of Element;

   procedure Insertion_Sort(X : in out List);
end Sort;

package body Sort is
   procedure Insertion_Sort(X: in out List) is
   begin
      for I in X'First+1..X'Last loop
         declare
            Next_Value_to_Insert : constant Element := X(I);
            Insertion_Point : Element_Number := I;
         begin
            for J in reverse X'first .. I-1 loop
               exit when (Next_Value_to_Insert > X(J));
               X(J+1) := X(J); -- Shift greater values up the sorted list
               Insertion_Point := Insertion_Point - 1;
            end loop;
            A(Insertion_Point) := Next_Value_to_Insert;
         end;
      end loop;
   end Insertion_Sort;
end Sort;

Interestingly when the compiler I was using was set on a strong optimization 
mode it did a lot more loop unrolling in this case than for the other 
example.  I don't know whether this would have translated into any 
performance advantage.
-- 
  Stuart 





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-03-03 15:34                 ` Dmitry A. Kazakov
  2009-03-04  5:52                   ` Anders Wirzenius
@ 2009-03-04 13:31                   ` Stuart
  1 sibling, 0 replies; 91+ messages in thread
From: Stuart @ 2009-03-04 13:31 UTC (permalink / raw)


[Correcting my earlier (canceled) message - Stuart]

Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:t0tq29ariugm.aftb8vcp4aeg$.dlg@40tude.net...
> On Fri, 27 Feb 2009 12:30:25 +0100, Georg Bauhaus wrote:
>
>> Adding the declarations of suitable number types in an example
>> algorithm maybe doesn't seem to hurt that much. Taking
>> http://en.wikipedia.org/wiki/Insertion_sort  as an example,
>> I tried
>>
>>    type Mug is (Metal, Plastic, Thermo, Porcelain);
>>    type Mug_Number is range 1 .. 10;
>>    type Mug_List is array(Mug_Number) of Mug;
<snip>

> You do not need T'Base in this case because it is cleaner and more
> efficient to rewrite it in a form that would always keep all indices
> within
> the array range:
>
>   procedure Insertion_Sort (A: in out Mug_List) is
>   begin
>      for I in A'First + 1..A'Last loop
>         declare
>            Value : constant Mug := A (I);
>            J     : Mug_Number   := I - 1;
>         begin
>            while A (J) > Value loop
>               A (J + 1) := A (J);
>               exit when J = A'First;
>               J := J - 1;
>            end loop;
>            A (J) := Value;
>         end;
>      end loop;
>   end Insertion_Sort;
>
> Of course an Ada purist would also replace integer index arithmetic with
> I'Succ and I'Pred. But that would likely be too much for wiki brains...
> (:-))

I looked at the following:

package Sort is
   type Element is new integer; -- or whatever
   type Element_Number is range 1..10; -- or whatever
   type List is array(Element_Number) of Element;

   procedure Insertion_Sort(X : in out List);
end Sort;

package body Sort is
   procedure Insertion_Sort(X: in out List) is
   begin
      for I in X'First+1..X'Last loop
         declare
            Next_Value_to_Insert : constant Element := X(I);
            Insertion_Point : Element_Number := I;
         begin
            for J in reverse X'first .. I-1 loop
               exit when (Next_Value_to_Insert > X(J));
               X(J+1) := X(J); -- Shift greater values up the sorted list
               Insertion_Point := Insertion_Point - 1;
            end loop;
            X(Insertion_Point) := Next_Value_to_Insert;
         end;
      end loop;
   end Insertion_Sort;
end Sort;

Interestingly when the compiler I was using was set on a strong optimization
mode it did a lot more loop unrolling in this case than for the other
example.  I don't know whether this would have translated into any
performance advantage.
-- 
  Stuart 





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-03-04 13:20               ` Stuart
@ 2009-03-04 13:46                 ` Dmitry A. Kazakov
  2009-03-04 18:41                   ` Stuart
  0 siblings, 1 reply; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-03-04 13:46 UTC (permalink / raw)


On Wed, 4 Mar 2009 13:20:54 -0000, Stuart wrote:

> I looked at the following:
> 
> package Sort is
>    type Element is new integer; -- or whatever
>    type Element_Number is range 1..10; -- or whatever
>    type List is array(Element_Number) of Element;
> 
>    procedure Insertion_Sort(X : in out List);
> end Sort;
> 
> package body Sort is
>    procedure Insertion_Sort(X: in out List) is
>    begin
>       for I in X'First+1..X'Last loop
>          declare
>             Next_Value_to_Insert : constant Element := X(I);
>             Insertion_Point : Element_Number := I;
>          begin
>             for J in reverse X'first .. I-1 loop
>                exit when (Next_Value_to_Insert > X(J));
>                X(J+1) := X(J); -- Shift greater values up the sorted list
>                Insertion_Point := Insertion_Point - 1;
>             end loop;
>             A(Insertion_Point) := Next_Value_to_Insert;
>          end;
>       end loop;
>    end Insertion_Sort;
> end Sort;
> 
> Interestingly when the compiler I was using was set on a strong optimization 
> mode it did a lot more loop unrolling in this case than for the other 
> example.

I think this is because the inner loop became a for-loop. I wonder if it
wouldn't be even more efficient (for integral element types) not to move
any elements while looking after the insertion point. And then move slices
when the insertion point is found:

   A (Insertion_Point + 1..I) := A (Insertion_Point..I - 1);
   A (Insertion_Point) := Next_Value_to_Insert;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-03-04 13:46                 ` Dmitry A. Kazakov
@ 2009-03-04 18:41                   ` Stuart
  2009-03-04 20:46                     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 91+ messages in thread
From: Stuart @ 2009-03-04 18:41 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:srtflu8nsew.hkpkh8pk8o2f.dlg@40tude.net...
> On Wed, 4 Mar 2009 13:20:54 -0000, Stuart wrote:
>
>> I looked at the following:
>>
>> package Sort is
>>    type Element is new integer; -- or whatever
>>    type Element_Number is range 1..10; -- or whatever
>>    type List is array(Element_Number) of Element;
>>
>>    procedure Insertion_Sort(X : in out List);
>> end Sort;
>>
>> package body Sort is
>>    procedure Insertion_Sort(X: in out List) is
>>    begin
>>       for I in X'First+1..X'Last loop
>>          declare
>>             Next_Value_to_Insert : constant Element := X(I);
>>             Insertion_Point : Element_Number := I;
>>          begin
>>             for J in reverse X'first .. I-1 loop
>>                exit when (Next_Value_to_Insert > X(J));

I think I should have made this:
                exit when (Next_Value_to_Insert >= X(J));

>>                X(J+1) := X(J); -- Shift greater values up the sorted list
>>                Insertion_Point := Insertion_Point - 1;
>>             end loop;
>>             A(Insertion_Point) := Next_Value_to_Insert;

I attempted to cancel this version and issue the corrected:
                 X(Insertion_Point) := Next_Value_to_Insert;

>>          end;
>>       end loop;
>>    end Insertion_Sort;
>> end Sort;
>>
>> Interestingly when the compiler I was using was set on a strong 
>> optimization
>> mode it did a lot more loop unrolling in this case than for the other
>> example.
>
> I think this is because the inner loop became a for-loop. I wonder if it
> wouldn't be even more efficient (for integral element types) not to move
> any elements while looking after the insertion point. And then move slices
> when the insertion point is found:
>
>   A (Insertion_Point + 1..I) := A (Insertion_Point..I - 1);
>   A (Insertion_Point) := Next_Value_to_Insert;

I did play with this idea as well - it should offer benfit as the compiler 
could recognize a bulk memory copy and use the highly optimized system 
memcpy.  I was not sure whether it fell outside the spirit of the original 
intention of the website that kicked this thread off, as it looks to be 
changing the algorithm to achieve performance tuning.  Mind you I noticed 
that one of the C examples (for another problem) was significantly optimized 
for a multicore system - and this was presented as the 'C' performace 
figure.  Are the current compilers good at mapping tasks to processor cores?

Regards
-- 
   Stuart
 





^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: Invade wikipedia!
  2009-03-04 18:41                   ` Stuart
@ 2009-03-04 20:46                     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 91+ messages in thread
From: Dmitry A. Kazakov @ 2009-03-04 20:46 UTC (permalink / raw)


On Wed, 4 Mar 2009 18:41:10 -0000, Stuart wrote:

> Mind you I noticed 
> that one of the C examples (for another problem) was significantly optimized 
> for a multicore system - and this was presented as the 'C' performace 
> figure.  Are the current compilers good at mapping tasks to processor cores?

That depends on too many issues. How threads / tasks are related to the
cores. Who is on control of the cores etc.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 91+ messages in thread

end of thread, other threads:[~2009-03-04 20:46 UTC | newest]

Thread overview: 91+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-24 11:03 Invade wikipedia! Jean-Pierre Rosen
2009-02-24 13:40 ` Dmitry A. Kazakov
2009-02-24 14:49   ` (see below)
2009-02-24 15:11     ` Dmitry A. Kazakov
2009-02-24 15:22       ` (see below)
2009-02-24 15:49         ` Dmitry A. Kazakov
2009-02-24 16:32           ` (see below)
2009-02-24 17:31             ` Dmitry A. Kazakov
2009-02-24 14:50   ` Martin
2009-02-24 15:16     ` Dmitry A. Kazakov
2009-02-24 19:48     ` Hibou57 (Yannick Duchêne)
2009-02-24 20:34       ` sjw
2009-02-24 21:27       ` Jeffrey R. Carter
2009-02-24 21:48         ` Hibou57 (Yannick Duchêne)
2009-02-24 22:43           ` Jeffrey R. Carter
2009-02-24 23:03         ` Adam Beneschan
2009-02-24 23:28           ` Martin
2009-02-24 23:33             ` (see below)
2009-02-25  0:08               ` Martin
2009-02-25  0:52                 ` Adam Beneschan
2009-02-25  1:45                 ` (see below)
2009-02-25 16:38                 ` Martin
2009-02-25 21:03                   ` Adam Beneschan
2009-02-25  8:05               ` Jacob Sparre Andersen
2009-02-25  8:59                 ` Hibou57 (Yannick Duchêne)
2009-02-25 16:10                   ` (see below)
2009-02-25 18:13                     ` Georg Bauhaus
2009-02-25 18:53                       ` (see below)
2009-02-25 19:19                         ` Georg Bauhaus
2009-02-27 23:53                           ` Randy Brukardt
2009-02-28  6:31                             ` Hibou57 (Yannick Duchêne)
2009-02-28  8:49                               ` Ivan Levashew
2009-02-25 19:17                       ` Dmitry A. Kazakov
2009-02-25 22:48                       ` Robert A Duff
2009-02-26  3:21                       ` Hibou57 (Yannick Duchêne)
2009-02-26 10:07                         ` Georg Bauhaus
2009-02-26  3:20                     ` Hibou57 (Yannick Duchêne)
2009-02-25 15:57                 ` (see below)
2009-02-25 22:14                 ` Adam Beneschan
2009-02-24 23:53             ` Hibou57 (Yannick Duchêne)
2009-02-25  0:07               ` Martin
2009-02-24 23:02       ` Adam Beneschan
2009-02-24 14:52 ` Peter Hermann
2009-02-24 15:44 ` Georg Bauhaus
2009-02-24 15:53   ` Peter Hermann
2009-02-24 16:18     ` Georg Bauhaus
2009-02-24 16:32   ` Jean-Pierre Rosen
2009-02-24 16:52   ` Adam Beneschan
2009-02-24 18:30     ` Georg Bauhaus
2009-02-24 18:46       ` Adam Beneschan
2009-02-24 19:42   ` Hibou57 (Yannick Duchêne)
2009-02-24 19:59     ` Dmitry A. Kazakov
2009-02-24 20:08       ` Hibou57 (Yannick Duchêne)
2009-02-24 23:01     ` Georg Bauhaus
2009-02-24 23:47       ` Hibou57 (Yannick Duchêne)
2009-02-26  0:52         ` Georg Bauhaus
2009-02-26  3:33           ` Hibou57 (Yannick Duchêne)
2009-02-26  6:38             ` Hibou57 (Yannick Duchêne)
2009-02-25 22:15       ` Ivan Levashew
2009-02-24 19:29 ` Martin Krischik
2009-02-25 22:31 ` Ivan Levashew
2009-02-25 23:07   ` Jeffrey R. Carter
2009-02-26  0:44   ` Georg Bauhaus
2009-02-26  8:29   ` Dmitry A. Kazakov
2009-02-26 10:40   ` Jean-Pierre Rosen
2009-02-26 13:53     ` Ivan Levashew
2009-02-26 14:13       ` Jean-Pierre Rosen
2009-02-26 15:42         ` Peter Hermann
2009-02-26 16:37         ` Adam Beneschan
2009-02-26 17:57           ` Jean-Pierre Rosen
2009-02-26 14:20       ` Dmitry A. Kazakov
2009-02-26 17:44       ` Georg Bauhaus
2009-02-26 18:16         ` Adam Beneschan
2009-02-27 11:30           ` Georg Bauhaus
2009-02-27 17:33             ` Dmitry A. Kazakov
2009-02-27 23:31               ` Georg Bauhaus
2009-02-28  0:31                 ` Jeffrey R. Carter
2009-02-28  5:26               ` Ivan Levashew
2009-02-28  6:27                 ` Hibou57 (Yannick Duchêne)
2009-02-28  6:40                 ` Jeffrey R. Carter
2009-02-28  7:01                   ` Hibou57 (Yannick Duchêne)
2009-02-28 11:45                     ` Georg Bauhaus
2009-03-03 14:16               ` Anders Wirzenius
2009-03-03 15:34                 ` Dmitry A. Kazakov
2009-03-04  5:52                   ` Anders Wirzenius
2009-03-04  9:19                     ` Dmitry A. Kazakov
2009-03-04 13:31                   ` Stuart
2009-03-04 13:20               ` Stuart
2009-03-04 13:46                 ` Dmitry A. Kazakov
2009-03-04 18:41                   ` Stuart
2009-03-04 20:46                     ` Dmitry A. Kazakov

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