[fpc-devel] Pascal Standard, and what we can do.
Sven Barth
pascaldragon at googlemail.com
Wed Jul 22 19:47:53 CEST 2015
Am 22.07.2015 19:25 schrieb "Paul van Helden" <paul at planetgis.co.za>:
>
> 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?
The compiler is geared towards single word operators (combined with their
precedence).
> 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...
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20150722/7f7d55a9/attachment.html>
More information about the fpc-devel
mailing list