‹ BackHN Continuity

Thread

Modern Object Pascal Introduction for Programmers

204 points · 90 comments · birdculture

  1. Lerc · · focus · HN ↗
    I used to have object pascal as my main language, and it has a lot in its favour. But when I go back to it I find two things drag it down.

    Pre definition of variables. I would like to be able to define variables on first assignment and scoped to the begin/end in which that happens, I don't think there is a good remaining argument to keep them above the statements.

    The namespace is cluttered with legacy usage, making the many years of advancement require odd. Combinations of prefixes.

    I still think there is a scope for a light fork that changes the name to distinguish it and starts the RTL afresh using the decades of hindsight and improvements.

    1. cisc · · focus · HN ↗
      > I would like to be able to define variables on first assignment and scoped to the begin/end in which that happens

      Good news! Object Pascal has inline variable declaration with type inference:

      <a href="https:&#x2F;&#x2F;docwiki.embarcadero.com&#x2F;RADStudio&#x2F;Florence&#x2F;en&#x2F;Delphi_Statements#Local_Variable_and_Constants_Declarations" rel="nofollow">https:&#x2F;&#x2F;docwiki.embarcadero.com&#x2F;RADStudio&#x2F;Florence&#x2F;en&#x2F;Delphi...

      <a href="https:&#x2F;&#x2F;blogs.embarcadero.com&#x2F;introducing-inline-variables-in-the-delphi-language&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blogs.embarcadero.com&#x2F;introducing-inline-variables-i...

      1. Lerc · · focus · HN ↗
        Oh excellent, last time I saw it proposed there were, well, ructions.

        Type inference is my preference but I thought that would have been a step too far for some.

        1. djriley · · focus · HN ↗
          It&#x27;s in Delphi, Free Pascal devs are still pretty resistant to the idea and it likely won&#x27;t be coming to fpc any time soon.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.