comp.lang.ada
 help / color / mirror / Atom feed
* Safe C++
@ 2001-09-18 19:45 Richard Riehle
  2001-09-19 14:38 ` Brian Rogoff
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Riehle @ 2001-09-18 19:45 UTC (permalink / raw)


There is an interesting discussion on comp.lang.c++.moderated
in which the topic of a safe C++ is being argued.   Some Ada
enthusiasts might find it amusing.   A couple of posters even
suggested that, instead of trying to make C++ safe, perhaps they
needed a new language design to satisfy the need.   Apparently,
they never heard of Ada.

Richard Riehle
richard@adaworks.com




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

* Re: Safe C++
  2001-09-18 19:45 Safe C++ Richard Riehle
@ 2001-09-19 14:38 ` Brian Rogoff
  2001-09-19 15:52   ` Chad Robert Meiners
                     ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Brian Rogoff @ 2001-09-19 14:38 UTC (permalink / raw)


On Tue, 18 Sep 2001, Richard Riehle wrote:
> There is an interesting discussion on comp.lang.c++.moderated
> in which the topic of a safe C++ is being argued.   Some Ada
> enthusiasts might find it amusing.   A couple of posters even
> suggested that, instead of trying to make C++ safe, perhaps they
> needed a new language design to satisfy the need.   Apparently,
> they never heard of Ada.

Rather than just snipe from the side at people trying to do better, take
a look at

	http://www.cs.cornell.edu/projects/cyclone/

and consider that it certainly has some features which are arguably better
than the Ada alternatives.

Putting my "Ada fan" hat on, I'd say that some of the work on region based
memory management should find it's way into some Ada dialect, maybe even
into the standard. And I really think pattern matching and some other
features of modern (read HM-typed, functional/declarative) languages
should find their way into an Ada successor. If only the Cyclone guys had
started with Ada, or even the SPARK subset!

It's really unfortunate that Ada hasn't spawned lots of research
dialects, like C family languages have.

-- Brian





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

* Re: Safe C++
  2001-09-19 14:38 ` Brian Rogoff
@ 2001-09-19 15:52   ` Chad Robert Meiners
  2001-09-19 17:43     ` Brian Rogoff
  2001-09-20  2:39   ` David Botton
  2001-09-25 14:21   ` Region-based mem mgmt [was: Re: Safe C++] Tucker Taft
  2 siblings, 1 reply; 26+ messages in thread
From: Chad Robert Meiners @ 2001-09-19 15:52 UTC (permalink / raw)




On Wed, 19 Sep 2001, Brian Rogoff wrote:

> On Tue, 18 Sep 2001, Richard Riehle wrote:
> > There is an interesting discussion on comp.lang.c++.moderated
> > in which the topic of a safe C++ is being argued.   Some Ada
> > enthusiasts might find it amusing.   A couple of posters even
> > suggested that, instead of trying to make C++ safe, perhaps they
> > needed a new language design to satisfy the need.   Apparently,
> > they never heard of Ada.
>
> Rather than just snipe from the side at people trying to do better, take
> a look at
>
> 	http://www.cs.cornell.edu/projects/cyclone/
>
> and consider that it certainly has some features which are arguably better
> than the Ada alternatives.

Which features are better than the Ada alternatives?

Cyclone doesn't appear to help reduce the number of pointers that the
programmer has to manage which I consider to be a major drawback with the
language.

> Putting my "Ada fan" hat on, I'd say that some of the work on region based
> memory management should find it's way into some Ada dialect, maybe even
> into the standard. And I really think pattern matching and some other
> features of modern (read HM-typed, functional/declarative) languages
> should find their way into an Ada successor. If only the Cyclone guys had
> started with Ada, or even the SPARK subset!
>
> It's really unfortunate that Ada hasn't spawned lots of research
> dialects, like C family languages have.
>
> -- Brian
>
>
>
- Chad R. Meiners




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

* Re: Safe C++
  2001-09-19 15:52   ` Chad Robert Meiners
@ 2001-09-19 17:43     ` Brian Rogoff
  2001-09-19 21:38       ` Chad R. Meiners
  2001-09-20  2:41       ` Safe C++ David Botton
  0 siblings, 2 replies; 26+ messages in thread
From: Brian Rogoff @ 2001-09-19 17:43 UTC (permalink / raw)


On Wed, 19 Sep 2001, Chad Robert Meiners wrote:
> On Wed, 19 Sep 2001, Brian Rogoff wrote:
> > Rather than just snipe from the side at people trying to do better, take
> > a look at
> >
> > 	http://www.cs.cornell.edu/projects/cyclone/
> >
> > and consider that it certainly has some features which are arguably better
> > than the Ada alternatives.
>
> Which features are better than the Ada alternatives?
                    ^-- arguably

Pattern matching
Parametrically polymorphic functions
Tuples

I think region based memory management is a win too, and could probably be
fit onto Ada without too much disruption.

> Cyclone doesn't appear to help reduce the number of pointers that the
> programmer has to manage which I consider to be a major drawback with the
> language.

Ada has advantages here, no doubt, but Cyclone makes the manipulations
much safer than C or C++. It's hardly fair to compare the unsafety of
Cyclone pointers with raw C!

As much as I prefer Ada to C, it's clear that some of these Safer C/C++
variants, especially ones which don't try to follow C++ too much, have a
lot to offer. Ada advocates can start seeming awfully provincial, with
their allergies to anything smacking of C.

Now, if you were to complain that Cyclone is another one of these
miserable flat languages without nested function definitions, I'd cheer
you on. :-)

-- Brian


> > Putting my "Ada fan" hat on, I'd say that some of the work on region based
> > memory management should find it's way into some Ada dialect, maybe even
> > into the standard. And I really think pattern matching and some other
> > features of modern (read HM-typed, functional/declarative) languages
> > should find their way into an Ada successor. If only the Cyclone guys had
> > started with Ada, or even the SPARK subset!
> >
> > It's really unfortunate that Ada hasn't spawned lots of research
> > dialects, like C family languages have.
> >
> > -- Brian
> >
> >
> >
> - Chad R. Meiners
>
>




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

* Re: Safe C++
  2001-09-19 17:43     ` Brian Rogoff
@ 2001-09-19 21:38       ` Chad R. Meiners
  2001-09-20  3:38         ` Brian Rogoff
                           ` (2 more replies)
  2001-09-20  2:41       ` Safe C++ David Botton
  1 sibling, 3 replies; 26+ messages in thread
From: Chad R. Meiners @ 2001-09-19 21:38 UTC (permalink / raw)



"Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
news:20010919102107.L4954-100000@shell5.ba.best.com...
> On Wed, 19 Sep 2001, Chad Robert Meiners wrote:
> > On Wed, 19 Sep 2001, Brian Rogoff wrote:
> > > Rather than just snipe from the side at people trying to do better,
take
> > > a look at
> > >
> > > http://www.cs.cornell.edu/projects/cyclone/
> > >
> > > and consider that it certainly has some features which are arguably
better
> > > than the Ada alternatives.
> >
> > Which features are better than the Ada alternatives?
>                     ^-- arguably
>
> Pattern matching
> Parametrically polymorphic functions
> Tuples

I'll have to trust you or these three since I have never encountered a
situation where I was ever wishing for such functionality.  The examples in
Cyclone's documentation gave me the impression that they are useful to
C programmer because they definitely add value to the C syntax.  I just
don't see how they would add value
to Ada's syntax.  Perhaps if you could tell me why it would be useful to you
to have them incorporate into Ada, I could their the significance of the
value added.

> I think region based memory management is a win too, and could probably be
> fit onto Ada without too much disruption.

I am pretty sure that when an access type falls out of scope in Ada, any
storage pools associated with it may be deallocated.  This seems pretty
close to what regions do?

> > Cyclone doesn't appear to help reduce the number of pointers that the
> > programmer has to manage which I consider to be a major drawback with
the
> > language.
>
> Ada has advantages here, no doubt, but Cyclone makes the manipulations
> much safer than C or C++. It's hardly fair to compare the unsafety of
> Cyclone pointers with raw C!
>
> As much as I prefer Ada to C, it's clear that some of these Safer C/C++
> variants, especially ones which don't try to follow C++ too much, have a
> lot to offer. Ada advocates can start seeming awfully provincial, with
> their allergies to anything smacking of C.

One of the major flaws with deriving something better out of C is that it is
comparable to trying to build a nice boat out of a cheaply built one.  Sure
it is possible to do this but either a) you will end up scraping the boat
and rebuilding it entirely, or you will have to live with a ship that is
inconsistently built after doing a lot of work patching all of the *known*
'design flaws'.  Consistency is very important in a language.  Ada is
wonderfully consistent whereas I have my doubts with these 'Safer C/C++'s.

I don't believe that you will find very many Ada advocates that have an
allergy to anything smacking of C. I have always been under the impression
that people on this newsgroup are open to discuss suggestions for the
language.

> Now, if you were to complain that Cyclone is another one of these
> miserable flat languages without nested function definitions, I'd cheer
> you on. :-)

Although flatness is a burden, it is less so than unnecessary pointers.

> -- Brian
>
>
> > > Putting my "Ada fan" hat on, I'd say that some of the work on region
based
> > > memory management should find it's way into some Ada dialect, maybe
even
> > > into the standard. And I really think pattern matching and some other
> > > features of modern (read HM-typed, functional/declarative) languages
> > > should find their way into an Ada successor. If only the Cyclone guys
had
> > > started with Ada, or even the SPARK subset!
> > >
> > > It's really unfortunate that Ada hasn't spawned lots of research
> > > dialects, like C family languages have.
> > >
> > > -- Brian
> > >
> > >
> > >
> > - Chad R. Meiners
> >
> >
>





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

* Re: Safe C++
  2001-09-19 14:38 ` Brian Rogoff
  2001-09-19 15:52   ` Chad Robert Meiners
@ 2001-09-20  2:39   ` David Botton
  2001-09-20  3:21     ` Brian Rogoff
  2001-09-25 14:21   ` Region-based mem mgmt [was: Re: Safe C++] Tucker Taft
  2 siblings, 1 reply; 26+ messages in thread
From: David Botton @ 2001-09-20  2:39 UTC (permalink / raw)
  To: comp.lang.ada

Take a look at the __numerous__ pattern matching options offered in the
GNAT.* packages. There is everything from a Spitbol implementation to Unix
style patterns matching.

> into the standard. And I really think pattern matching

David Botton





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

* Re: Safe C++
  2001-09-19 17:43     ` Brian Rogoff
  2001-09-19 21:38       ` Chad R. Meiners
@ 2001-09-20  2:41       ` David Botton
  1 sibling, 0 replies; 26+ messages in thread
From: David Botton @ 2001-09-20  2:41 UTC (permalink / raw)
  To: comp.lang.ada

> Tuples

When would I want to use tuples and what advantages do they give me over
what I already have?

David Botton





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

* Re: Safe C++
  2001-09-20  2:39   ` David Botton
@ 2001-09-20  3:21     ` Brian Rogoff
  2001-09-20 12:43       ` David Botton
  0 siblings, 1 reply; 26+ messages in thread
From: Brian Rogoff @ 2001-09-20  3:21 UTC (permalink / raw)


Take a look at the numerous languages that have pattern matching (Haskell,
SML, OCaml, Erlang, Mercury, Prolog, Clean, Hope ...) and then explain to
me just what you're talking about. I'll give you a hint: if you say
generics to someone who thinks Ada and say generics to someone who thinks
Common Lisp or Dylan they will be thinking different things. You're
thinking about an almost altogether different thing.

-- Brian

On Wed, 19 Sep 2001, David Botton wrote:

> Take a look at the __numerous__ pattern matching options offered in the
> GNAT.* packages. There is everything from a Spitbol implementation to Unix
> style patterns matching.
>
> > into the standard. And I really think pattern matching
>
> David Botton
>
>
>




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

* Re: Safe C++
  2001-09-19 21:38       ` Chad R. Meiners
@ 2001-09-20  3:38         ` Brian Rogoff
  2001-09-20 11:52           ` Pat Rogers
  2001-09-20  8:22         ` Colin Paul Gloster
  2001-09-20 11:37         ` Parametrically polymorphic operations (Was: Safe C++) Jacob Sparre Andersen
  2 siblings, 1 reply; 26+ messages in thread
From: Brian Rogoff @ 2001-09-20  3:38 UTC (permalink / raw)


On Wed, 19 Sep 2001, Chad R. Meiners wrote:
> "Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
> > Pattern matching
> > Parametrically polymorphic functions
> > Tuples
>
> I'll have to trust you or these three since I have never encountered a
> situation where I was ever wishing for such functionality.

I used and liked Ada, compared with C, but there aren't too many things
about Ada (overloading is the big one) I miss compared with ML.

About the only thing I can do is suggest that you learn some modern
functional language, so you'll at least have a basis to compare. Nope,
I don't feel like writing a long enough description of why they're good;
it's been done many times, if you have the patience to read a long posting
you should have the patience to read "Why Functional Programming Matters"
by Hughes or "Critique of Standard ML" by Appel. My pet language is OCaml,
which is an ML but not the (obsolete) version of SML crtitiqued by Appel.

-- Brian





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

* Re: Safe C++
  2001-09-19 21:38       ` Chad R. Meiners
  2001-09-20  3:38         ` Brian Rogoff
@ 2001-09-20  8:22         ` Colin Paul Gloster
  2001-09-20 13:45           ` Chad R. Meiners
  2001-09-20 11:37         ` Parametrically polymorphic operations (Was: Safe C++) Jacob Sparre Andersen
  2 siblings, 1 reply; 26+ messages in thread
From: Colin Paul Gloster @ 2001-09-20  8:22 UTC (permalink / raw)


In article news:9ob2u6$2r4l$1@msunews.cl.msu.edu Chad R. Meiners wrote:
"[..]

I don't believe that you will find very many Ada advocates that have an
allergy to anything smacking of C. I have always been under the impression
that people on this newsgroup [..]"

I do not dispute that there are masters active on this newsgroup who have
solid experience to back their reservations. It is no secret though that
there are Ada advocates who strongly hate C. Not only C family languages,
but non-Ada languages. Of course someone who recommends Ada does not 
necessarily hate other languages but if you think that we do not
have such people you are mistaken.

Should you check the news:comp.realtime FAQ posting
(e.g. news:realtime-computing/faq_999165253@rtfm.mit.edu ,
"Comp.realtime: Frequently Asked Questions (FAQs)", 30 Aug 2001 09:55:25
GMT, Version: 3.4 (May 1998), also available at
HTTP://WWW.FAQs.org/faqs/realtime-computing/faq/ ) you can find:

"[..]
IV- POLEMIC TOPICS
[..]
    Which programming language should I use to develop a Real-Time System?
[..] it would be much better to use a higher level [than assembly]
programming language. Most of them will fit. The Ada Community will always
try to convince you their language is the best to use in any cases. Here is
not the news group to argue about this [..]".

Looking back through older posts in the Ada advocacy forum Team Ada one
could find furious frustration against C; C++; and Java.



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

* Parametrically polymorphic operations (Was: Safe C++)
  2001-09-19 21:38       ` Chad R. Meiners
  2001-09-20  3:38         ` Brian Rogoff
  2001-09-20  8:22         ` Colin Paul Gloster
@ 2001-09-20 11:37         ` Jacob Sparre Andersen
  2001-09-20 11:41           ` Lutz Donnerhacke
                             ` (3 more replies)
  2 siblings, 4 replies; 26+ messages in thread
From: Jacob Sparre Andersen @ 2001-09-20 11:37 UTC (permalink / raw)


Chad:

> "Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
[...]
> > Parametrically polymorphic functions

> I'll have to trust you or these three since I have never encountered a
> situation where I was ever wishing for such functionality.

While working on libraries for matrix operations and unit
safe types, I have certainly wanted something very similar
to parametrically polymorphic functions. It would make it
possible to have more extensive compile time checks, than
what is possible with Ada as it is defined today.

An example:

   type Matrix (Left, Right : Positive) is private;

   function "*" (Left  : in Matrix;
                 Right : in Matrix (Height => Left.Width))
     return Matrix (Width  => Right.Width,
                    Height => Left.Height);

(I hope the intention is clear although the syntax isn't
defined)

This would tell the compiler a few things, which would allow
it to
flag type mismatches already at compile time.

The current Ada specification forces us to move these checks
into the body of the functions and procedures.

Jacob
-- 
"an OS that is almost, but not quite, entirely unlike
Windows"



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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-20 11:37         ` Parametrically polymorphic operations (Was: Safe C++) Jacob Sparre Andersen
@ 2001-09-20 11:41           ` Lutz Donnerhacke
  2001-09-20 12:27             ` Jacob Sparre Andersen
  2001-09-20 15:49           ` Brian Rogoff
                             ` (2 subsequent siblings)
  3 siblings, 1 reply; 26+ messages in thread
From: Lutz Donnerhacke @ 2001-09-20 11:41 UTC (permalink / raw)


* Jacob Sparre Andersen wrote:
>The current Ada specification forces us to move these checks
>into the body of the functions and procedures.

Use Anna.

-- 
   Mailbox der letzten vier Wochen kommentarlos in den Orkus getreten.
   Wichtige Anfragen bitte nochmal senden. Unter Angabe von Msg-ID oder
   markanten Suchworten, kann ich die Mails jedoch heraussuchen.



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

* Re: Safe C++
  2001-09-20  3:38         ` Brian Rogoff
@ 2001-09-20 11:52           ` Pat Rogers
  2001-09-20 16:01             ` Brian Rogoff
  0 siblings, 1 reply; 26+ messages in thread
From: Pat Rogers @ 2001-09-20 11:52 UTC (permalink / raw)


"Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
news:20010919202331.R6489-100000@shell5.ba.best.com...
> On Wed, 19 Sep 2001, Chad R. Meiners wrote:
> > "Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
> > > Pattern matching
> > > Parametrically polymorphic functions
> > > Tuples
> >
> > I'll have to trust you or these three since I have never encountered a
> > situation where I was ever wishing for such functionality.
>
> I used and liked Ada, compared with C, but there aren't too many things
> about Ada (overloading is the big one) I miss compared with ML.

What is the concurrency support?






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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-20 11:41           ` Lutz Donnerhacke
@ 2001-09-20 12:27             ` Jacob Sparre Andersen
  0 siblings, 0 replies; 26+ messages in thread
From: Jacob Sparre Andersen @ 2001-09-20 12:27 UTC (permalink / raw)


Lutz:

> * Jacob Sparre Andersen wrote:
> >The current Ada specification forces us to move these checks
> >into the body of the functions and procedures.
> 
> Use Anna.

"Anna" = "Annotated Ada" (it seems)

Why shouldn't this feature be included in Ada?

Jacob (who will take a look at Anna)
-- 
I �vrigt er DVD-formatet ulovligt i alle WTO-medlemslande.



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

* Re: Safe C++
  2001-09-20  3:21     ` Brian Rogoff
@ 2001-09-20 12:43       ` David Botton
  0 siblings, 0 replies; 26+ messages in thread
From: David Botton @ 2001-09-20 12:43 UTC (permalink / raw)
  To: comp.lang.ada

Sorry, I realized after I already sent the message......

David Botton

----- Original Message ----- 
From: "Brian Rogoff" <bpr@shell5.ba.best.com>


> Take a look at the numerous languages that have pattern matching




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

* Re: Safe C++
  2001-09-20  8:22         ` Colin Paul Gloster
@ 2001-09-20 13:45           ` Chad R. Meiners
  2001-09-20 21:03             ` codesavvy
  0 siblings, 1 reply; 26+ messages in thread
From: Chad R. Meiners @ 2001-09-20 13:45 UTC (permalink / raw)


I never said they didn't exist.  I stated that they are a small minority.

> I don't believe that you will find very many Ada advocates that have an
> allergy to anything smacking of C. I have always been under the impression
> that people on this newsgroup [..]"
>
> I do not dispute that there are masters active on this newsgroup who have
> solid experience to back their reservations. It is no secret though that
> there are Ada advocates who strongly hate C. Not only C family languages,
> but non-Ada languages. Of course someone who recommends Ada does not
> necessarily hate other languages but if you think that we do not
> have such people you are mistaken.
>
> Should you check the news:comp.realtime FAQ posting
> (e.g. news:realtime-computing/faq_999165253@rtfm.mit.edu ,
> "Comp.realtime: Frequently Asked Questions (FAQs)", 30 Aug 2001 09:55:25
> GMT, Version: 3.4 (May 1998), also available at
> HTTP://WWW.FAQs.org/faqs/realtime-computing/faq/ ) you can find:
>
> "[..]
> IV- POLEMIC TOPICS
> [..]
>     Which programming language should I use to develop a Real-Time System?
> [..] it would be much better to use a higher level [than assembly]
> programming language. Most of them will fit. The Ada Community will always
> try to convince you their language is the best to use in any cases. Here
is
> not the news group to argue about this [..]".
>
> Looking back through older posts in the Ada advocacy forum Team Ada one
> could find furious frustration against C; C++; and Java.





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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-20 11:37         ` Parametrically polymorphic operations (Was: Safe C++) Jacob Sparre Andersen
  2001-09-20 11:41           ` Lutz Donnerhacke
@ 2001-09-20 15:49           ` Brian Rogoff
  2001-09-21  9:24             ` Jacob Sparre Andersen
  2001-09-20 16:22           ` Dmitry A. Kazakov
  2001-09-21 16:08           ` Wes Groleau
  3 siblings, 1 reply; 26+ messages in thread
From: Brian Rogoff @ 2001-09-20 15:49 UTC (permalink / raw)


On Thu, 20 Sep 2001, Jacob Sparre Andersen wrote:
> Chad:
> > "Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
> [...]
> > > Parametrically polymorphic functions
>
> > I'll have to trust you or these three since I have never encountered a
> > situation where I was ever wishing for such functionality.
>
> While working on libraries for matrix operations and unit
> safe types, I have certainly wanted something very similar
> to parametrically polymorphic functions. It would make it
> possible to have more extensive compile time checks, than
> what is possible with Ada as it is defined today.
>
> An example:
>
>    type Matrix (Left, Right : Positive) is private;
>
>    function "*" (Left  : in Matrix;
>                  Right : in Matrix (Height => Left.Width))
>      return Matrix (Width  => Right.Width,
>                     Height => Left.Height);
>
> (I hope the intention is clear although the syntax isn't
> defined)

That you want to multiply an M x N and a N x K matrix and have it type
check at compile time and produce an M X K matrix?

I only very recently learned how to do this in ML (look for a posting by
Matthias Blume on comp.lang.ml replying to one of mine in the last year)
and I have to say it was a bit surprising. I guess it shouldn't have been;
one of the ideas in the technique is the same as used to create a type
safe printf library (printer combinators) and is just generally useful.
I don't know if it's really appropriate to post it here since it's a fair
bit (~200 lines) of non-Ada code :-).

> This would tell the compiler a few things, which would allow
> it to flag type mismatches already at compile time.

With the technique I mention, there is no question of the compiler being
"allowed" to flag the mismatch. The dimensions are moved into the type
system so the type checker rejects it! Just like with the printer
combinators.

-- Brian




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

* Re: Safe C++
  2001-09-20 11:52           ` Pat Rogers
@ 2001-09-20 16:01             ` Brian Rogoff
  0 siblings, 0 replies; 26+ messages in thread
From: Brian Rogoff @ 2001-09-20 16:01 UTC (permalink / raw)


On Thu, 20 Sep 2001, Pat Rogers wrote:
> "Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
> news:20010919202331.R6489-100000@shell5.ba.best.com...
> > On Wed, 19 Sep 2001, Chad R. Meiners wrote:
> > > "Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
> > > > Pattern matching
> > > > Parametrically polymorphic functions
> > > > Tuples
> > >
> > > I'll have to trust you or these three since I have never encountered a
> > > situation where I was ever wishing for such functionality.
> >
> > I used and liked Ada, compared with C, but there aren't too many things
> > about Ada (overloading is the big one) I miss compared with ML.
>
> What is the concurrency support?

That's another one (mostly) for Ada. OCaml has a decent threads library,
and SML/NJ supports a Concurrent ML extension (there's a book by that name
too which you can read) and has Scheme style call/cc. I don't know much
about the other SMLs.

I certainly wasn't knocking Ada, I'm pointing out that there are core
language extensions which would (IMO of course) make Ada a much better
language. Some of those extensions are being tried in Cyclone. One of the
goals of Cyclone no doubt is to become successful, so they are starting
from C, rather than Ada. I think it's unfortunate that there aren't such
projects for Ada. Personally, I think pattern matching on algebraic data
types is one of the biggest advantages of modern languages, since that
feature combines brevity, readability, and typability, and is very much in
the spirit of Ada. Much more so than tagged types and OO!

-- Brian





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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-20 11:37         ` Parametrically polymorphic operations (Was: Safe C++) Jacob Sparre Andersen
  2001-09-20 11:41           ` Lutz Donnerhacke
  2001-09-20 15:49           ` Brian Rogoff
@ 2001-09-20 16:22           ` Dmitry A. Kazakov
  2001-09-21 16:08           ` Wes Groleau
  3 siblings, 0 replies; 26+ messages in thread
From: Dmitry A. Kazakov @ 2001-09-20 16:22 UTC (permalink / raw)


On Thu, 20 Sep 2001 13:37:57 +0200, Jacob Sparre Andersen
<sparre@nbi.dk> wrote:

>Chad:
>
>> "Brian Rogoff" <bpr@shell5.ba.best.com> wrote in message
>[...]
>> > Parametrically polymorphic functions
>
>> I'll have to trust you or these three since I have never encountered a
>> situation where I was ever wishing for such functionality.
>
>While working on libraries for matrix operations and unit
>safe types, I have certainly wanted something very similar
>to parametrically polymorphic functions. It would make it
>possible to have more extensive compile time checks, than
>what is possible with Ada as it is defined today.
>
>An example:
>
>   type Matrix (Left, Right : Positive) is private;
>
>   function "*" (Left  : in Matrix;
>                 Right : in Matrix (Height => Left.Width))
>     return Matrix (Width  => Right.Width,
>                    Height => Left.Height);
>
>(I hope the intention is clear although the syntax isn't
>defined)
>
>This would tell the compiler a few things, which would allow
>it to
>flag type mismatches already at compile time.
>
>The current Ada specification forces us to move these checks
>into the body of the functions and procedures.

It is more than that. Same problem appears with implementation of
measurement units [and many other cases].

The actual problem is that a type has some parameters [better to call
them discriminants] that are statically known. These parameters are
involved in some expressions with are also static. One should somehow
separate these expressions from the implementation of the subroutine
body and force them evaluated at compile time. The question is how?
(:-))

Then I would argue that it is not parametric polymorphism, because
there is no need to provide parameters for the body. There is also no
need to have distinct types for matrices of different size [or for
each measurement unit etc]. One need to only "distill" the static part
from the body.

Regards,
Dmitry Kazakov



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

* Re: Safe C++
  2001-09-20 13:45           ` Chad R. Meiners
@ 2001-09-20 21:03             ` codesavvy
  0 siblings, 0 replies; 26+ messages in thread
From: codesavvy @ 2001-09-20 21:03 UTC (permalink / raw)


"Chad R. Meiners" <meinersc@cse.msu.edu> wrote in message news:<9ocqn1$js5$1@msunews.cl.msu.edu>...
> I never said they didn't exist.  I stated that they are a small minority.
> 

Don't mind him he's always got some axe to grind and thus isn't too
interested in having a meaningful dialog.

> > I don't believe that you will find very many Ada advocates that have an
> > allergy to anything smacking of C. I have always been under the impression
> > that people on this newsgroup [..]"
> >
> > I do not dispute that there are masters active on this newsgroup who have
> > solid experience to back their reservations. It is no secret though that
> > there are Ada advocates who strongly hate C. Not only C family languages,
> > but non-Ada languages. Of course someone who recommends Ada does not
> > necessarily hate other languages but if you think that we do not
> > have such people you are mistaken.
> >
> > Should you check the news:comp.realtime FAQ posting
> > (e.g. news:realtime-computing/faq_999165253@rtfm.mit.edu ,
> > "Comp.realtime: Frequently Asked Questions (FAQs)", 30 Aug 2001 09:55:25
> > GMT, Version: 3.4 (May 1998), also available at
> > HTTP://WWW.FAQs.org/faqs/realtime-computing/faq/ ) you can find:
> >
> > "[..]
> > IV- POLEMIC TOPICS
> > [..]
> >     Which programming language should I use to develop a Real-Time System?
> > [..] it would be much better to use a higher level [than assembly]
> > programming language. Most of them will fit. The Ada Community will always
> > try to convince you their language is the best to use in any cases. Here
>  is
> > not the news group to argue about this [..]".
> >
> > Looking back through older posts in the Ada advocacy forum Team Ada one
> > could find furious frustration against C; C++; and Java.



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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-20 15:49           ` Brian Rogoff
@ 2001-09-21  9:24             ` Jacob Sparre Andersen
  0 siblings, 0 replies; 26+ messages in thread
From: Jacob Sparre Andersen @ 2001-09-21  9:24 UTC (permalink / raw)


Brian:

> >    type Matrix (Left, Right : Positive) is private;
> >
> >    function "*" (Left  : in Matrix;
> >                  Right : in Matrix (Height => Left.Width))
> >      return Matrix (Width  => Right.Width,
> >                     Height => Left.Height);
> >
> > (I hope the intention is clear although the syntax isn't
> > defined)
> 
> That you want to multiply an M x N and a N x K matrix and have it type
> check at compile time and produce an M X K matrix?

Exactly.

Jacob
-- 
http://jacob.sparre.dk/Jacob/edb/digitale_nyheder
           Om redakt�rens opgave p� internetnyhedstjenester.



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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-20 11:37         ` Parametrically polymorphic operations (Was: Safe C++) Jacob Sparre Andersen
                             ` (2 preceding siblings ...)
  2001-09-20 16:22           ` Dmitry A. Kazakov
@ 2001-09-21 16:08           ` Wes Groleau
  2001-09-21 17:13             ` Jacob Sparre Andersen
  3 siblings, 1 reply; 26+ messages in thread
From: Wes Groleau @ 2001-09-21 16:08 UTC (permalink / raw)




Jacob Sparre Andersen wrote:
> safe types, I have certainly wanted something very similar
> to parametrically polymorphic functions. It would make it
> possible to have more extensive compile time checks, than
> what is possible with Ada as it is defined today.
> 
> An example:
> 
>    type Matrix (Left, Right : Positive) is private;
> 
>    function "*" (Left  : in Matrix;
>                  Right : in Matrix (Height => Left.Width))
>      return Matrix (Width  => Right.Width,
>                     Height => Left.Height);

Where are you going to put the result?

If the implementation is reasonable, constraint_error
will be raised when the constraints on the left side don't
the constraints on the result.

And if the constraints are static on both, many compilers
will detect it at compile time.

-- 
Wes Groleau
http://freepages.rootsweb.com/~wgroleau



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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-21 16:08           ` Wes Groleau
@ 2001-09-21 17:13             ` Jacob Sparre Andersen
  2001-09-21 18:43               ` Wes Groleau
  0 siblings, 1 reply; 26+ messages in thread
From: Jacob Sparre Andersen @ 2001-09-21 17:13 UTC (permalink / raw)


Wes:

> Jacob Sparre Andersen wrote:
> > safe types, I have certainly wanted something very similar
> > to parametrically polymorphic functions. It would make it
> > possible to have more extensive compile time checks, than
> > what is possible with Ada as it is defined today.
> >
> > An example:
> >
> >    type Matrix (Left, Right : Positive) is private;

Nobody seems to have noticed, but the type should of course
have been declared as:

   type Matrix (Width, Height : Positive) is private;

> >
> >    function "*" (Left  : in Matrix;
> >                  Right : in Matrix (Height => Left.Width))
> >      return Matrix (Width  => Right.Width,
> >                     Height => Left.Height);
> 
> Where are you going to put the result?

For example in:

   Result : Matrix (Width => 4, Height => 4);

> If the implementation is reasonable, constraint_error
> will be raised when the constraints on the left side don't
> the constraints on the result.

The implementation of my favourite Ada compiler or the
implementation of function "*"?

The problem is that the constaints on the result can not be
expressed in the specification of "*". You have to put them
in the implementation of "*". GNAT may not be a reasonable
implementation of an Ada compiler, but it is the one I use
most of the time, and I have not been able to get it to
complain about mismatches in the dimensions of matrices,
when doing matrix multiplications. I would appreciate it, if
you could explain us how to write a matrix multiplication
function, which allows some of the existing Ada compilers to
complain about mismatches in matrix dimensions at compile
time.

> And if the constraints are static on both, many compilers
> will detect it at compile time.

Would you care to mention one or two examples?

Jacob
-- 
ACRONYM: A Contrived Reduction Of Nomenclature Yielding
Mnemonics



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

* Re: Parametrically polymorphic operations (Was: Safe C++)
  2001-09-21 17:13             ` Jacob Sparre Andersen
@ 2001-09-21 18:43               ` Wes Groleau
  0 siblings, 0 replies; 26+ messages in thread
From: Wes Groleau @ 2001-09-21 18:43 UTC (permalink / raw)




Jacob Sparre Andersen wrote:
>
> For example in:
> 
>    Result : Matrix (Width => 4, Height => 4);
> 
> > If the implementation is reasonable, constraint_error
> > will be raised when the constraints on the left side don't
> > the constraints on the result.
> 
> The implementation of my favourite Ada compiler or the
> implementation of function "*"?

Any conforming compiler.  To continue your example:

  Result := Matrix_A * Matrix_B;

If the function returns a four by five matrix, constraint_error
results.  This is of course at RUN-TIME though.  However, IF the
compiler is able to determine at compile time that this WILL be
the case it is allowed to issue a warning and many will.  However,
it is rare that this can be determined at compile time.

For that reason, your extension would be very useful in a minority
of cases, where the bounds of all three matrices are known and
the body of "*" is not.  This is a big enough minority that
I'd like to see it evaluated for the next revision.  But there
may be other good reasons for avoiding it.

You may be able to do such a thing statically in Eiffel.

-- 
Wes Groleau
http://freepages.rootsweb.com/~wgroleau



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

* Region-based mem mgmt [was: Re: Safe C++]
  2001-09-19 14:38 ` Brian Rogoff
  2001-09-19 15:52   ` Chad Robert Meiners
  2001-09-20  2:39   ` David Botton
@ 2001-09-25 14:21   ` Tucker Taft
  2001-09-25 14:46     ` Tucker Taft
  2 siblings, 1 reply; 26+ messages in thread
From: Tucker Taft @ 2001-09-25 14:21 UTC (permalink / raw)


Brian Rogoff wrote:
> ...
> Rather than just snipe from the side at people trying to do better, take
> a look at
> 
>         http://www.cs.cornell.edu/projects/cyclone/
> 
> and consider that it certainly has some features which are arguably better
> than the Ada alternatives.
> 
> Putting my "Ada fan" hat on, I'd say that some of the work on region based
> memory management should find it's way into some Ada dialect, maybe even
> into the standard... 

I agree that we should look closely at "region-based memory management"
for Ada 200X.  It is essentially the same thing as mark/release heap
management, but with guaranteed safety.  That makes it ideal for
Ada -- provably safe and simple/efficient at run-time.

I like the ease of use provided by garbage collection, but it is
difficult to prove the safety of a general purpose garbage collector
("prove" in the sense of FAA-style certification), and it is certainly
not simple nor terribly efficient at run-time, especially when compared
with mark/release heap management.

> -- Brian

-- 
-Tucker Taft   stt@avercom.net   http://www.avercom.net
Chief Technology Officer, AverCom Corporation (A Titan Company) 
Bedford, MA  USA (AverCom was formerly the Commercial Division of AverStar:
http://www.averstar.com/~stt)



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

* Re: Region-based mem mgmt [was: Re: Safe C++]
  2001-09-25 14:21   ` Region-based mem mgmt [was: Re: Safe C++] Tucker Taft
@ 2001-09-25 14:46     ` Tucker Taft
  0 siblings, 0 replies; 26+ messages in thread
From: Tucker Taft @ 2001-09-25 14:46 UTC (permalink / raw)


Tucker Taft wrote:

> ...
> I agree that we should look closely at "region-based memory management"
> for Ada 200X.  It is essentially the same thing as mark/release heap
> management, but with guaranteed safety.  That makes it ideal for
> Ada -- provably safe and simple/efficient at run-time.

Note that region-based memory management is similar to local
access types (collections) in Ada, but can be more flexible, in that
the region can be (implicitly) passed as a parameter to a function,
with allocation from the appropriate region being performed
inside the function.  This is similar to what can be accomplished
by passing an access type into a generic, but doesn't have
some of the issues associated with generic instantiation.

We have been talking about "universal" or "anonymous" access
types a bit already for Ada 200X.  This might be the right
place to insert region-based memory management as well.
-- 
-Tucker Taft   stt@avercom.net   http://www.avercom.net
Chief Technology Officer, AverCom Corporation (A Titan Company) 
Bedford, MA  USA (AverCom was formerly the Commercial Division of AverStar:
http://www.averstar.com/~stt)



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

end of thread, other threads:[~2001-09-25 14:46 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-18 19:45 Safe C++ Richard Riehle
2001-09-19 14:38 ` Brian Rogoff
2001-09-19 15:52   ` Chad Robert Meiners
2001-09-19 17:43     ` Brian Rogoff
2001-09-19 21:38       ` Chad R. Meiners
2001-09-20  3:38         ` Brian Rogoff
2001-09-20 11:52           ` Pat Rogers
2001-09-20 16:01             ` Brian Rogoff
2001-09-20  8:22         ` Colin Paul Gloster
2001-09-20 13:45           ` Chad R. Meiners
2001-09-20 21:03             ` codesavvy
2001-09-20 11:37         ` Parametrically polymorphic operations (Was: Safe C++) Jacob Sparre Andersen
2001-09-20 11:41           ` Lutz Donnerhacke
2001-09-20 12:27             ` Jacob Sparre Andersen
2001-09-20 15:49           ` Brian Rogoff
2001-09-21  9:24             ` Jacob Sparre Andersen
2001-09-20 16:22           ` Dmitry A. Kazakov
2001-09-21 16:08           ` Wes Groleau
2001-09-21 17:13             ` Jacob Sparre Andersen
2001-09-21 18:43               ` Wes Groleau
2001-09-20  2:41       ` Safe C++ David Botton
2001-09-20  2:39   ` David Botton
2001-09-20  3:21     ` Brian Rogoff
2001-09-20 12:43       ` David Botton
2001-09-25 14:21   ` Region-based mem mgmt [was: Re: Safe C++] Tucker Taft
2001-09-25 14:46     ` Tucker Taft

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