comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: newbie can't get exceptions to work!
Date: Fri, 06 Apr 2001 23:04:47 GMT
Date: 2001-04-06T23:04:47+00:00	[thread overview]
Message-ID: <Pine.BSF.4.21.0104061524390.5067-100000@shell5.ba.best.com> (raw)
In-Reply-To: <wccsnjlvfex.fsf@world.std.com>

On Fri, 6 Apr 2001, Robert A Duff wrote:
> Brian Rogoff <bpr@shell5.ba.best.com> writes:
> 
> > On Fri, 6 Apr 2001, Robert A Duff wrote:
> > > "Marc A. Criley" <mcqada@earthlink.net> writes:
> > > > I was very pleased with the addition of "use type" to Ada 95, despite
> > > > the opinion of a some that it's an ugly addition that was included
> > > > merely to avoid having to write "renames" clauses for operators.  
> > 
> > Hmmm. I think it's ugly because it was included merely to avoid having to
> > write use clauses. If you're a no-use fanatic, you should be content with
> > not using use clauses, but no, use-phobes thinks it's OK as long as the 
> > infix syntax is used. So the language is butchered to handle this special
> > case. 
> 
> It has nothing to do with "writing".  It has to do with reading.
> 
> I'm neither use-phobe nor use-phile.  I think it depends on the package,
> whether you should say "use" of it.  I take it you're a use-phile, and
> don't really care if the use-phobes have to write unreadable code.

Actually, I'm a use-phobe who believes that absolute rules *never* make 
sense :-). What that means in practice is that I like to write code in a 
use-phobe style, except that there are just always cases where use is
clearer, and when it is, I'd like to use it. And typically, when I do use
it, I heed J.P. Rosen's advice about restricting it's scope. In other
words, be careful using use (and goto, and exceptions, and overloading,
and dynamic dispatch, and ...) because if you aren't careful your code
will become unreadable. 

I don't think use-philes really exist (OK, maybe somewhere there are a
few), but use-phobia is quite a real phenomena. 

What I hate are statements to the effect of "don't think, never use X!". 

>  If
> so, then I suppose you think "use" should be banished, and everything
> should be use-visible by default?

No. I've adopted a style that's very use-phobe phriendly. 
 
> > Why, what's so special about operators?
> 
> Operators are used when the programmer thinks the concise notation of
> operator syntax makes the code more readable than identifier-named
> functions.  Eg, we think that:
> 
>     A + B*C
> 
> is more readable than:
> 
>     Add(A, Multiply(B, C))
> 
> If that's true, it makes no sense at all to ever say:
> 
>     "+"(A, "*"(B, C))
> 
> or:
> 
>     Some_Package."+"(A, Some_Package."*"(B, C))
> 
> Given that the whole point of operators is to use a concise symbol
> instead of an English word, I think one should always use operator
> notation for calls to operator functions.  If you always "use"
> everything, then you can do that.  But I think it makes sense not to
> 'use' a particular package, so you have to say
> Some_Package.Some_Function, but still want to write calls to operators
> using operator notation (infix, etc).

OK, I was sort of being a pain with that question. However, since we're 
redesigning the language :-), the right solution IMO would be to have a 
more precise form of import and export clause than what Ada has, so that 
if you want to use a package you can choose precisely what gets seen.
This way, the use type folks are happy, I'm happy (well, I'm always happy:)
you're happy (yes?), and Niklaus Wirth is vindicated. For example,
something like 

from Some_Package use "+", "-", "*", Some_Function;

...
Some_Package.Some_Other_Function(Some_Function(A + B * C));
...

I think that would be an improvement. The only bummer is use-type folks
would have to specify which operators they want, but there is no danger 
of cut and paste rename issues.

> >... Well, OK, Ada makes them a bit
> > special by not allowing you to define new ones (an annoying restriction
> > IMO) but they are just functions, right?
> 
> I agree that it's an annoying restriction.  The reason, I guess, is that
> if you allowed someone to define an operator "$" or "&^%$$##", you would
> have to worry about the syntax.  What is the precedence of these
> operators?  I think Cecil has a nice solution to the problem.

What's the Cecil solution? The OCaml solution is to have precedence and
associativity inherited from the first character of the operator, so 
+. and +/ are like +. Unfortunately OCaml doesn't yet have overloading so 
it really needs this feature. You're probably not surprised to learn that 
in many language communities (Modula-3, ML, Eiffel?) overloading is viewed 
by many the same way that "use" is viewed by many in the Ada world. And I 
respond the same way, sure overloading can make a mess for the reader but 
used well it makes code more readable.

> > > You don't have to say "use" in order to
> > > write "X := Y"; 
> > 
> > ":=" is special. It's not a function, and you can't redefine it, except
> > for very special types. Yes, I know you know all this :-). 
> 
> Yes, I know it, and I know you know it, and I know you know I know it. ;-)

:-)

> I can still gripe about it.

That's the beauty of Usenet. 
 
> It's not just ":=", but also notations like "in", "and then", and "A(I)"
> (I would prefer "A[I]", by the way) 

Thank you, I completely agree. I find the choice of () for array access
makes code far less readable, since my eyes can't distinguish from
function calls. 

> and literal notation.  These are all
> "special" in that you don't need to say "use" to use these notations
> (and also in that you can't redefine them; sigh).  They look like
> operators to me, but Ada says otherwise.

I tell you what, design this next language, and I'm on board. I'm willing
to give up full closures as long as pattern matching and parametric
polymorphism are in the language. Take a look at the Cyclone project as 
an example of a decent looking futuristic systems programming language, 
unfortunately based on C. 

http://cvs.metaprl.org:12000/cvsweb/~checkout~/cyclone/doc/cyc_users_guide.htm

> > > why should you have to write "use" in order to write
> > > "if X = Y ..."?
> > 
> > "=" is also kind of special, right? 
> 
> Unfortunately true.

This is actually a deep problem. SML has it's eqtypes, OCaml has it's
polymorphic comparison primitives. Neither seem satisfactory to me. 

> > Are you proposing that assignment and equality are both special enough
> > that no use is necessary, or are you saying all operators should be exempt 
> > from being use (type)-ed? 
> 
> I meant that all operators should be exempt.  I wasn't speaking
> particularly about ":=" and "=" (and I realize that Ada defines "=" to
> be an operator, but not ":=" or "in", etc).

Well, I think the Wirthian solution is probably better, and has the nice 
property of not treating operators specially. Why didn't Ada have such a 
selective import? 

-- Brian





  reply	other threads:[~2001-04-06 23:04 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-05  3:19 newbie can't get exceptions to work! Jeff Shipman
2001-04-05  4:25 ` Ed Falis
2001-04-05 11:00   ` martin.m.dowie
2001-04-05 14:21     ` Ted Dennison
2001-04-05 17:50       ` Fraser Wilson
2001-04-05  4:34 ` Jeff Shipman
2001-04-05  4:59 ` Wilhelm Spickermann
2001-04-05 14:14   ` Ted Dennison
2001-04-05 16:37     ` Wilhelm Spickermann
2001-04-06 13:09     ` Marc A. Criley
2001-04-06 15:04       ` Ted Dennison
2001-04-06 16:43       ` Robert A Duff
2001-04-06 17:39         ` Ted Dennison
2001-04-06 21:50           ` Robert A Duff
2001-04-06 20:11         ` Brian Rogoff
2001-04-06 22:20           ` Robert A Duff
2001-04-06 23:04             ` Brian Rogoff [this message]
2001-04-07  5:48               ` Jeffrey Carter
2001-04-10  1:29                 ` Robert A Duff
2001-04-07 19:30               ` Robert A Duff
2001-04-07 21:17                 ` Brian Rogoff
2001-04-07 21:25                   ` Ayende Rahien
2001-04-07 22:57                     ` David Starner
2001-04-08 12:10                       ` Ayende Rahien
2001-04-08  2:12                     ` Larry Hazel
2001-04-08 12:12                       ` Ayende Rahien
2001-04-09 16:20                         ` Larry Hazel
2001-04-10  2:38                           ` Ayende Rahien
2001-04-10  3:25                             ` James Rogers
2001-04-08 22:18                       ` Brian Rogoff
2001-04-09 15:14                         ` Ted Dennison
2001-04-09 17:23                           ` Brian Rogoff
2001-04-09 18:23                             ` Laurent Guerby
2001-04-09 19:15                               ` Brian Rogoff
2001-04-10 18:21                                 ` Laurent Guerby
2001-04-10 19:44                                   ` Brian Rogoff
2001-04-11 18:03                                     ` Laurent Guerby
2001-04-11 18:33                                       ` Samuel T. Harris
2001-04-14  0:06                                         ` Robert A Duff
2001-04-12  1:42                                       ` Mike Silva
2001-04-12  2:38                                       ` Brian Rogoff
2001-04-12 23:23                                         ` Laurent Guerby
2001-04-13  2:44                                           ` Brian Rogoff
2001-04-11 13:24                                   ` Ayende Rahien
2001-04-11 13:14                                     ` Mats Karlssohn
2001-04-11 15:08                                       ` Ayende Rahien
2001-04-11 21:42                                       ` Fraser Wilson
2001-04-12 23:55                                         ` Robert A Duff
2001-04-10  2:12                               ` Robert A Duff
2001-04-10  3:47                                 ` Brian Rogoff
2001-04-10 13:40                                 ` Ada keywords (was: Re: newbie can't get exceptions to work!) Marin David Condic
2001-04-10 14:26                                   ` Jean-Pierre Rosen
2001-04-09 20:49                             ` newbie can't get exceptions to work! Ted Dennison
2001-04-09 21:44                               ` Brian Rogoff
2001-04-09 21:59                                 ` Ted Dennison
2001-04-10  2:54                                   ` Ayende Rahien
2001-04-10 14:00                                     ` Ted Dennison
2001-04-10 17:44                                     ` Fraser Wilson
2001-04-10  6:59                               ` Mats Karlssohn
2001-04-10 14:18                                 ` Ted Dennison
2001-04-10 16:27                                   ` Mark Biggar
2001-04-11 11:55                                     ` Mats Karlssohn
2001-04-11 14:34                                       ` Samuel T. Harris
2001-04-11 15:50                                         ` Pat Rogers
2001-04-12  6:27                                         ` Mats Karlssohn
2001-04-11 11:49                                   ` Mats Karlssohn
2001-04-11 15:38                                     ` Robert A Duff
2001-04-13 16:12                             ` Matthew Woodcraft
2001-04-10  1:41                   ` Robert A Duff
2001-04-10  3:03                     ` James Rogers
2001-04-10  3:58                       ` Brian Rogoff
2001-04-10 21:48                         ` Ted Dennison
2001-04-11 15:09                           ` Ayende Rahien
2001-04-11 21:57                             ` James Rogers
2001-04-11 23:13                               ` Brian Rogoff
2001-04-12  6:33                                 ` Mats Karlssohn
2001-04-12 16:38                                   ` Brian Rogoff
2001-04-17  7:04                                     ` Mats Karlssohn
2001-04-17  9:08                                       ` Jean-Pierre Rosen
2001-04-12 15:16                               ` Ted Dennison
2001-04-12 21:22                                 ` James Rogers
2001-04-10  4:26                     ` Brian Rogoff
2001-04-11 15:30                       ` Robert A Duff
2001-04-11 17:33                         ` Brian Rogoff
2001-04-10  1:26               ` Robert A Duff
2001-04-10  2:11                 ` Brian Rogoff
2001-04-14  0:00                   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2001-04-05  5:26 Christoph Grein
replies disabled

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