[fpc-pascal] Syntax changes suggestions

R0b0t1 r030t1 at gmail.com
Fri Jul 27 16:16:55 CEST 2018


Well, I am also of the opinion that threadvar is kind of a kludge too.
I think part of the aesthetic of Pascal is that it reads fairly close
to English. Creating a lot of new compound words is a bit jarring.

As I just now figured out how to articulate the above, I have what I
think is a more consistent group of proposals. It will prevent needing
to create a lot of special keywords:

var
  c: thread TMyClass;
  d: auto TMyClass;


Or, perhaps even better:

thread var
  c: TMyClass;

managed var
  d: TMyClass;

Cheers,
     R0b0t1


On Thu, Jul 26, 2018 at 10:19 PM, Ryan Joseph
<ryan at thealchemistguild.com> wrote:
>
>
>> On Jul 25, 2018, at 8:05 AM, R0b0t1 <r030t1 at gmail.com> wrote:
>>
>> This looks ugly. It also introduces modifiers to variable
>> declarations. Some features should not be part of the language, they
>> should be built on top of it.
>
>
> Yeah, introducing modifiers to variables is not so great. You could avoid introducing modifiers but using a new section like “scopevar” which is similar to “threadvar” I guess.
>
> scopevar
>   c: TMyClass;
> begin
>   c := TMyClass.Create;
>
> I accomplish this in my code using an auto release pool which empties at the end of every event loop.
>
> var
>   c: TMyClass;
> begin
>   c := TMyClass.Create;
>   c.AutoRelease;
>
> // or
>   c := TMyClass.Instance; // calls Create + AutoRelease in the constructor
>
> That’s not so pretty either, involves extra constructors sometimes (if you want to keep things pretty) and it requires extra infrastructure you need to setup. Jonas told me once this is actually more efficient though since it frees multiple objects all at the same time so it decreases heap fragmentation (I think he meant). This idea is heavily utilized in all of Apple’s Cocoa frameworks so it’s a sound solution.
>
>
> Meh, no free lunch, just food for thought. :)
>
> Regards,
>         Ryan Joseph
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list