Re:Why Pascal is Not My Favorite Programming Language (1981)
by Havoc on Wednesday September 03, 2014 @05:44AM
(#8262195)
> the compiler had better inline assembly than what gcc provides 20 years down the road.
Also...stupidly fast build-times. First time I compiled something on VS I thought the thing had frozen. Nope...just slow.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by hyperpape on Wednesday September 03, 2014 @10:10AM
(#8263040)
Well, it's not just array dimensions as part of the type, it's array dimensions as part of the type and _no generic functions over them_.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by habitue on Wednesday September 03, 2014 @04:19AM
(#8261995)
C also has arrays with dimensions as part of the type. The trick is that the dimension must be determined statically. This is different than vectors in Haskell which allow the size of the vector to be determined (and even vary) dynamically, yet still guarantee memory safety statically (I.e. no runtime cost for bounds checking).
You can think of an array with a static size of 10 as being like shorthand notation for a struct with ten fields (sans padding). It really is no more complicated than that.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by pjmlp on Wednesday September 03, 2014 @07:12AM
(#8262398)
Try to use those arrays as function arguments.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by habitue on Wednesday September 03, 2014 @12:57PM
(#8263987)
I believe that works fine (at least in C). You have to statically put the array size into the function signature, so it will only work on arrays of that size. I was simply pointing out the difference between dependently typed vectors which have the type checker prove you use the vector correctly, and arrays in c and pascal whose sizes are known at compile time. I am agreeing with the author that this makes it hard to create generic array bounds if you don't have the ability to make unbounded arrays (as c does). I was disagreeing with the gp, who was conflating these two different sorts of types.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by pjmlp on Wednesday September 03, 2014 @01:18PM
(#8264115)
So I guess you aren't confortable with the C standard.
Functions don't take arrays size statically in arguments. Whatever you write is ignored.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by habitue on Wednesday September 03, 2014 @06:46PM
(#8265858)
It's been a few years since I've written a lot of C. ufo's sibling comment reminded me of how it acts (the last dimension is ignored).
Anyway, this is completely beside the point of what I was talking about. The point is that a static size is a very different level of type system machinery from a dynamic size.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by pjmlp on Thursday September 04, 2014 @02:25AM
(#8267010)
My point is that although they are static allocated, the moment you pass them as arguments, they are just another pointer.
Which leads to those beautifull security exploits.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by ufo on Wednesday September 03, 2014 @02:02PM
(#8264370)
IIRC, if you have multidimensional arrays only the last dimension is ignored so arr[3][4] is equivalent to arr[3][]. Of course, in the one dimensional case it means that the dimension is ignored.
Re:Why Pascal is Not My Favorite Programming Language (1981)
by sparkie on Wednesday September 03, 2014 @05:40AM
(#8262188)
C++ has also realized that array dimensions as part of the type are the right way forward. It's encouraged that you use std::array and avoid plain old arrays (which can't work in combination with smart pointers, for example).
[For example, in Haskell, they consider it fancy that you can add dimensions to your type signature so the compiler can check if you're not doing something silly.]
Also, I programmed extensively in Pascal using the Borland IDE in the early 90s and it was one of the best IDEs I ever encountered.
As troll bait, let me just throw in this: the compiler had better inline assembly than what gcc provides 20 years down the road.