From: smith@ctron.com (Larry Smith)
Newsgroups: comp.lang.pascal
Subject: Re: NO NUMBERS! (or even SHORT INTS!)
Keywords: arithmetic
Date: 9 Oct 92 17:05:34 GMT
Reply-To: smith@ctron.com
Organization: Cabletron Systems, Inc.

In article <5809@osc.COM>, jgk@osc.COM (Joe Keane) writes:
>In article <1992Sep29.093516.23758@odin.diku.dk> klaus@diku.dk (Klaus Ole
>Kristiansen) writes:
>> count := succ(count)  preferred over count := count + 1

>Your friend is crazy.  You can tell bad programmers because they worry about
>inane things like this.  Who cares!  Any decent compiler will generate
>identical code, so you should use whichever you like better.

Good programmers worry about consistancy and proper use of the language.
Pascal defines a special operator for incrementing scalar types, and it
is _all_ that can increment enumerations.  The question is one of consistancy
between integers and other scalar types.  That you do not worry about such
things says volumes about your style.

>In article <q9kyRB1w165w@burrow.cojones.com> bilbo@burrow.cojones.com (Bill
>Beau) writes:
>>  Inc(count);

>This is hilarious!  It's hard to believe that a compiler would require you to
>call a special function just to increment a number efficiently.  Also, it's
>interesting that the function takes a variable number of arguments.  How would
>you write your own function like this?

You don't.  Neither do you write writeln, readln, or any of the other built-ins
in Pascal.  That's why they are built-in, they require special handling.  Wirth
has been refining the idea to reduce the number of such functions that require
that kind of support, and Oberon has very few (maybe none, I don't have my
reference book handy).

>>However, the trade-off is that not all Pascal compiliers support the inc()
>>procedure thus you lose portability...

>No kidding.  I hope that other Pascal implementors have a bit more sense than
>these folks.  I can't imagine a C compiler telling you to call a function
>instead of using the ++ operator.

If you think there is any difference between Turbo's Inc and C's ++ operator
then you are sadly short on compiler or language design.  Pascal does not
define a plethora of operators, extensions are usually embodied, as is this
one, with functions.  They compile to same thing, the mechanism for invoking
them is just syntax.  C, on the other hand, has loads of operators, and
loads of precedence levels, and a whole lot of ways of doing things that
an optimizer will turn into the same code sequence: i++; i+=1; i = i+1; ++i;
would all result in the same code in one of your precious compilers.  So
why support all those different ways of doing it?  i = i + x is the most
generic, why waste code and effort making the others work?

Don't bother to answer.  I know what they are all for, and I know all the
idioms.  C is a fair programming language in the hands of a very disciplined
professional, but it is not the only programming language, nor are C hacks
the only way to build a system.  Learn what other languages have to offer
and learn why they did it that way before criticising something you don't
understand.

Larry Smith (smith@ctron.com)  No, I don't speak for Cabletron.  Need you ask?
-
Liberty is not the freedom to do whatever we want,
it is the freedom to do whatever we are able.