[fpc-devel] Pascal Standard, and what we can do.
pascaldragon at googlemail.com
Wed Jul 22 22:29:40 CEST 2015
On 22.07.2015 20:20, Paul van Helden wrote:
> On Wed, Jul 22, 2015 at 7:47 PM, Sven Barth <pascaldragon at googlemail.com
> <mailto:pascaldragon at googlemail.com>> wrote:
> > I'm not a compiler programmer, but it almost seems like laziness that the second case is not possible already? Maybe something is really hard with multi-word operators?
> The compiler is geared towards single word operators (combined with
> their precedence).
> Is it technically infeasible to expand this to two-word operators? SQL
> did it..
Not without reworking quite some parts of the parser.
> > Convenience should be added to this. Take for example type inference. If the compiler can easily figure out the type of a result, why should I have to declare a variable first with the appropriate type? Of course that means to allow var declarations inside the code block. Something I've always wanted to see in Pascal since my brief stint with C++ in the early 90s. The standard argument against is probably "that is unPascallish" or that it is moving away from strong typing. I disagree: if the compiler can figure things out before runtime you still have strong typing. So, for example, I would like to declare something like this anywhere inside a begin..end block:
> > var A := SomeClassInstance.SomeFunction;
> While I agree that type inference /might/ be useful I don't agree
> with inline variable declarations. One of the main points of Pascal
> is declare before use. While this is somewhat violated with Delphi
> compatible generics there one could at least argue that the
> specialized type is implicitly declared by the generic declaration...
> I have never managed to understand why "declare before use" is so
> important to Pascal. I get the bit about strong typing and doing
> everything possible to eliminate errors at compile time, but I still
> don't get why. If this is central to what makes something "Pascal", I
> would love to be pointed to a good explanation. I'm not trying to be a
> pain here. I've been programming in Pascal, full time, for most of my
> life. It has always puzzled me why everything has to be declared first.
Because with that you have specific locations where variables are
declared. You can see with one look (yes, I'm simplifying here) what
variables are used in the function even if you don't have a fancy IDE
that highlights it.
More information about the fpc-devel