[fpc-devel] Pascal Standard, and what we can do.

Paul van Helden paul at planetgis.co.za
Wed Jul 22 19:24:26 CEST 2015


On Mon, Jul 20, 2015 at 8:39 PM, Marcos Douglas <md at delfire.net> wrote:

> On Mon, Jul 20, 2015 at 3:14 PM, Ralf Quint <freedos.la at gmail.com> wrote:
> > [...] And quite frankly, what I have seen in object oriented code
> > in recent years, I would rather take as a negative example of evolution,
> of
> > ways/things not to go/do...
>
> That is true.
> Many programmers think that coding using object orientation only
> because they use an object-oriented language. They also think that
> using a more "cool" syntax makes your code more "professional".
>
> But some evolutions in a language could be a good thing, as Sven have said.
>
> Yes, so for example we currently have:

if not (X is TSomeClass) then ..
if not (5 in [1,2,3]) then ..

What is wrong with a language evolving to allow (in addition to the above)?:

if X is not TSomeClass then ..
if 5 not in [1,2,3] then ..

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?

I like Pascal because it is more readable than Java, C#, Ruby, Haskell,
etc. IMO the design philosophy should be: "if it is more readable it should
be allowed".

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;

It *looks* like JavaScript's (etc) weak typing but it is not. The compiler
will catch any mischief that may follow with the variable A. We've
eliminated a line of code that needs to be changed if the type of the
function result changes. And to me it still looks very Pascallish..

I can carry on.. tuples can save lots of lines of code while at the same
time making it more readable. How as that not "cool"? :-) (or functional
for that matter!)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20150722/f7cc042f/attachment.html>


More information about the fpc-devel mailing list