Is anybody coming from Pascal?

Stephen Horne steve at
Sat Jul 21 23:17:21 CEST 2001

On Sat, 21 Jul 2001 07:05:13 +0100, edmund at (Edmund
Strangely) wrote:

>I conclusion, and in reviewing this post, I seem to have been rambling a
>bit (it's a bit late/early in the day) but I'd be interested to get a
>response from anybody else who rates Mr Wirth, and in how any such people
>finding the transition. I'd also be curious to hear from anybody who has
>tried object Pascal.

I've used a number of languages, including both Pascal and Modula 2.
Pascal was also among the first few languages I learned - after
various versions of BASIC, couple of assembler languages, and a
variant of Forth. I even learned Ada before I made significant use of
C or C++, though I worked professionally with C before I worked with
Ada. I first learned Python at a time I was professionally using Ada,
and when I was still learning C++ (my current main language for
professional use).

On the / or div issue, I agree with some things and disagree with
others. I disagree with having separate / and div operators, for
instance, because this is a simple case of operator overloading - when
I use complex numbers, vectors, matrices and so on I don't want to
revert to using functions instead of operators, and I don't want to
learn another set of operator names. Ada is, in many ways, a language
in the Pascal/Modula 2 tradition, and one of the big improvements it
has over Pascal is that it supports operator overloading and drops the
div operator.

OTOH, I do prefer the Ada mod and rem operators to the C % operator
for several reasons...

1.  C does not define whether % is a mod or rem. A mod operator never
returns a negative number, whereas a remainder may give a negative
result. Because this is undefined in the standard, different compilers
do different things with respect to the sign in this case.

The reason for the different definitions is because modulo arithmetic
is arithmetic done in a wraparound range of integers 0..(base-1) and
has not negative numbers, whereas the remainder in division does
logically have a negative result.

2.  The mod and rem names are explicit in what they mean. The %
operator looks like it should be something to do with percentages.

Python has cleaned up the first problem (by defining that % returns
the remainder, which may be negative) but not the second. In fact,
python overloads % with a completely different additional
functionality which IMO can only increase the confusion (plus I think
the % operator is not quite right anyway - the markers in the string
should specify the subscript of the item in the list, as well as the

Also, I'm not happy with the Python definition of integer division,
and of the remainder...

The modulo operator always yields a result with the same sign as its
second operand (or zero)

As far as I'm concerned, this is plain wrong. If I do the following...

quotient = -3 / 2
remainder = -3 % 2

I expect quotient = -1 and remainder = -1

I get quotient = -2 and remainder = 1

Either version maintains the basic remainder law - given...

quotient = a / b
remainder = a % b

You can still rely on...

(quotient * b) + remainder == a

I just think integer division should round towards zero - not strictly

These are small issues though, and issues that vary enough from one
language to the next that any multi-lingual programmer should have the
sense to check before using these facilities.

My overall opinion is that Modula-2 and Ada are excellent languages in
many ways, though Ada programmers tend to have a style based on
pedantic following of rules rather than on what is genuinely readable
- a mindset that comes from the military background, I suppose. Pascal
in its standard form is too simplistic to be a serious general-purpose
language, and single-vendor updates such as Delphi *are* single-vendor
products, irrespective of their success. C and C++ easily defeat Ada
in their ability to express a lot of functionality quickly and
consisely, though they lose on reliability and (with the still common
obfuscation tradition) sometimes on readability.

At first sight, my criticism of Delphi being a single-vendor
non-standard product seems also to apply to Python - but it's not
true. In reality, Python has a single standards authority (Guido van
Rossum) - but you are not limited in the way that single vendor
products limit you. This is because anyone can contribute to the
development. If you really feel it is necessary, you can download the
source and port it to other platforms or add whatever features you
want, and distribute your own alternative implementation. This has
happened a lot - jPython and embedded/stackless Python being the cases
that spring to mind. The Python community is a centre of excellence -
not a cage made of regulations and limitations.

Single vendor products clearly restrict freedom and are therefore
unAmerican ;-) - though I'd much rather keep Borland and dump

More information about the Python-list mailing list