Sign in Join

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

Mailing lists / lazarus / 2011-11

Are private data not allowed? Why?

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Massimo Soricetti

I would like an explanation on this code (noob question, maybe):

private
   sDati: array[0..3] of string;
   procedure Verifica(var: sDati array of string);

This code returns an error because sDati is already declared. If I move the declaration in public space is OK:

private
   procedure Verifica(var: sDati array of string);
public
   sDati: array[0..3] of string;

why this? Private data are not allowed? Why?

Reply by email

dmitry boyarintsev
to Massimo Soricetti

You probably need to switch Delphi Sytanx mode.
Otherwise you've two different entities in the same scope with the same name, And that causes the conflict.
But it's a good practice to name parameters different from the fields' names.

thanks,
Dmitry

Massimo Soricetti wrote 23 lines
I would like an explanation on this code (noob question, maybe): private ?sDati: array[0..3] of string; ?procedure Verifica(var: sDati array of string); This code returns an error because sDati is already declared. If I move the declaration in public space is OK: private ?procedure Verifica(var: sDati array of string); public ?sDati: array[0..3] of string; why this? Private data are not allowed? Why? -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Massimo Soricetti
to dmitry boyarintsev

Thank you :-)

Show quoted text 8 lines
You probably need to switch Delphi Sytanx mode. Otherwise you've two different entities in the same scope with the same name, And that causes the conflict. But it's a good practice to name parameters different from the fields' names. thanks, Dmitry

Reply by email

Sven Barth
to Massimo Soricetti: I would like an explanation on this code (noob question, maybe): private sDati:…
Massimo Soricetti wrote 16 lines
I would like an explanation on this code (noob question, maybe): private sDati: array[0..3] of string; procedure Verifica(var: sDati array of string); This code returns an error because sDati is already declared. If I move the declaration in public space is OK: private procedure Verifica(var: sDati array of string); public sDati: array[0..3] of string; why this? Private data are not allowed? Why?

In mode "objfpc" duplicate identifiers inside a class are not allowed, to reduce confusion when working with that class.

The interesting point is though: shouldn't your second example fail as well according to that logic?

Regards,
Sven

Reply by email

Dimitri Smits
to Sven Barth
Show quoted text 7 lines
On 13.11.2011 01:46, Massimo Soricetti wrote: > I would like an explanation on this code (noob question, maybe): > > private > sDati: array[0..3] of string; > procedure Verifica(var: sDati array of string); >

I might be wrong here, but shouldn't the colon (":") be after the sDati var parameters name or was that a typo on behalf of the OP?

kind regards,
Dimitri Smits

Reply by email

Sven Barth
to Dimitri Smits
Dimitri Smits wrote 9 lines
> On 13.11.2011 01:46, Massimo Soricetti wrote: >> I would like an explanation on this code (noob question, maybe): >> >> private >> sDati: array[0..3] of string; >> procedure Verifica(var: sDati array of string); >> I might be wrong here, but shouldn't the colon (":") be after the sDati var parameters name or was that a typo on behalf of the OP?

I personally assumed that it was a typo ^^
(and yes, it should be "var sDati: array of String")

Regards,
Sven

Reply by email