An interesting observation

Bruce Adams tortiose_74 at yeah.who.co.uk
Fri Nov 9 17:18:28 PST 2007


Jan Claeys Wrote:

> Op Fri, 09 Nov 2007 08:53:31 -0500, schreef bearophile:
> 
> > Pascal used to have lots of advantages over C, and not just to teach
> > programming (Pascal programs were more reliable. 

What was the source of this alleged better reliability? (I'm guessing harder to write crap code due to syntactic sugar and salt)

> Its modern variants
> > like ObjectPascal have some advantages even over D still, like a better
> > management of division (with slash and div), better automatic type
> > conversion (like the upcasting management I have shown here some time
> > ago), etc.).
>
Presumably we can do almost anything with cast(auto) or 
cast(DuckType) where DuckType is a class with constructors and opImplicitCast for a variety of normal unconvertible types. 
DuckType As opposed to Variant where you want stricter control over what is converted when.

By the way, got a link to the upcasting thread?
 
> Plus the RTTI- & component-based development that made Delphi the first 
> really popular *and* professionally useful RAD IDE...
> 
> 
> -- 
> JanC

I've had a little surf around and I can find nothing which demonstrates any especially clever features that object pascal has. So, leaving aside reflection for which we already expect improvements what do you miss from object pascal that D doesn't (yet) have? Is there anything it could never have?

I can kind of see where your coming from with the div / argument. D like C++ has inherited C's nasty expression casting.

float A, B, C;
C=B/A;                    vs. C = B DIV A;    use integer only division
int x,y;
C=cast(float)(x)/y;    vs.  C = x/y;   use floating division

Using a cast here to express your intent is ugly and wrong. Different function names are a more correct way to express intent. You could roll your own of course (bonus points for conciseness). I wonder if there is any compiler bonus to be had by the distinction though (the hidden rounding in x = A/B for example could catch a noob unawares)? 

One thing I miss from the pascal family is better terminology.
cardinal and integer make much more sense than unsigned int and signed int, not to mention saving typing. I feel a global typedef coming on...

Regards,

Bruce.



More information about the Digitalmars-d mailing list