Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-11

Initialize/Finalize with count, is it possible?

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Max Vlasov

Hi,

I just noticed that fpc when compiling in lazarus didn't allow me to use Initialize/Finalize with the parameter showing the number of records to initialize. Interesting, but I have a huge number of delphi sources using this syntax, something like

        FillChar(Section^, Count*ElementSize, 0);
        Initialize(TNameValueRec(Section^), Count);

This is because I have a variant of "array of" object implementation and it uses support tool, and when the user checks "Record contains strings", this line is appended

Is possible for such syntax to be supported? Probably I'm one of those rare developer using it, and maybe because of this I just have to make some patch by myself, suggesting the result to be committed :). Please let me know if it's possible.

Also, if reporting a bug/feature request is welcome, should I do some changes to this ticket:
http://bugs.freepascal.org/view.php?id=4825&nbn=1
or create a new one?

Thanks in advance,

Max Vlasov

Honza
to Max Vlasov

2010/11/20 Max Vlasov :

Show quoted text 7 lines
        FillChar(Section^, Count*ElementSize, 0);         Initialize(TNameValueRec(Section^), Count); Is possible for such syntax to be supported? Probably I'm one of those rare developer using it, and maybe because of this I just have to make some patch by myself, suggesting the result to be committed :). Please let me know if it's possible.

Why to patch the language when a for loop can do the same as above?

bflm freepascal-bits.blogspot.com
Max Vlasov
to Honza
Honza wrote 16 lines
2010/11/20 Max Vlasov : > FillChar(Section^, Count*ElementSize, 0); > Initialize(TNameValueRec(Section^), Count); > > Is possible for such syntax to be supported? Probably I'm one of those rare > developer using it, and maybe because of this I just have to make some patch > by myself, suggesting the result to be committed :). Please let me know if > it's possible. Why to patch the language when a for loop can do the same as above? --

Honza, I suppose I will go with such change, but one other thought. As you may know, many Delphi developers impressed by Lazarus hope all their existing sources will be fpc-compatible some time. I'm just a little sad that I have to apply this change (sure side effect critical) to about 200 source files with this constructs I have. I'd also multiply it by 2 since there is also the finalize section in the same files:). Anyway, not a big deal, probably some regular expression to come up with

Max

Sven Barth
to Honza: 2010/11/20 Max Vlasov : Why to patch the language when a for loop can do the same as…
Honza wrote 11 lines
2010/11/20 Max Vlasov: > FillChar(Section^, Count*ElementSize, 0); > Initialize(TNameValueRec(Section^), Count); > > Is possible for such syntax to be supported? Probably I'm one of those rare > developer using it, and maybe because of this I just have to make some patch > by myself, suggesting the result to be committed :). Please let me know if > it's possible. Why to patch the language when a for loop can do the same as above?

Two words: Delphi compatibility. (I know that some can't hear/read it anymore ^^)

That said:
@Max: Just report it and if the devs reject it, then you'll need to use a workaround. (And no, you can't edit the bug report you mentioned, cause it's already closed, so you need to create a new one)

Regards,
Sven

Michael Van Canneyt
to Sven Barth
Sven Barth wrote 22 lines
On 20.11.2010 10:07, Honza wrote: > 2010/11/20 Max Vlasov: >> FillChar(Section^, Count*ElementSize, 0); >> Initialize(TNameValueRec(Section^), Count); >> >> Is possible for such syntax to be supported? Probably I'm one of those >> rare >> developer using it, and maybe because of this I just have to make some >> patch >> by myself, suggesting the result to be committed :). Please let me know if >> it's possible. > > Why to patch the language when a for loop can do the same as above? > Two words: Delphi compatibility. (I know that some can't hear/read it anymore ^^) That said: @Max: Just report it and if the devs reject it, then you'll need to use a workaround. (And no, you can't edit the bug report you mentioned, cause it's already closed, so you need to create a new one)

I don't think it will be rejected.

Michael.

Max Vlasov
to Sven Barth: Two words: Delphi compatibility. (I know that some can't hear/read it anymore ^^) That…
Sven Barth wrote 28 lines
On 20.11.2010 10:07, Honza wrote: > 2010/11/20 Max Vlasov: > >> FillChar(Section^, Count*ElementSize, 0); >> Initialize(TNameValueRec(Section^), Count); >> >> Is possible for such syntax to be supported? Probably I'm one of those >> rare >> developer using it, and maybe because of this I just have to make some >> patch >> by myself, suggesting the result to be committed :). Please let me know >> if >> it's possible. >> > > Why to patch the language when a for loop can do the same as above? > > Two words: Delphi compatibility. (I know that some can't hear/read it anymore ^^) That said: @Max: Just report it and if the devs reject it, then you'll need to use a workaround. (And no, you can't edit the bug report you mentioned, cause it's already closed, so you need to create a new one)

Thanks a lot, submitted a new issue:
http://mantis.freepascal.org/view.php?id=17998
It's great to hear that the team takes the delphi compatibility very seriously :)

Max