Re: [fpc-pascal] Const attributes

2017-07-31 Thread Marcos Douglas B. Santos
On Mon, Jul 31, 2017 at 11:28 AM, Felipe Monteiro de Carvalho wrote: > On Mon, Jul 31, 2017 at 2:08 PM, Marcos Douglas B. Santos > wrote: >> But that is the goal to achieve... >> Not because Java, but to restrict the initialization of the attributes. > > I meant that if its trivial to restrict se

Re: [fpc-pascal] Const attributes

2017-07-31 Thread Felipe Monteiro de Carvalho
On Mon, Jul 31, 2017 at 2:08 PM, Marcos Douglas B. Santos wrote: > But that is the goal to achieve... > Not because Java, but to restrict the initialization of the attributes. I meant that if its trivial to restrict setting final fields to constructors, but it might be a lot of work to check and

Re: [fpc-pascal] Const attributes

2017-07-31 Thread Marcos Douglas B. Santos
On Mon, Jul 31, 2017 at 6:25 AM, Felipe Monteiro de Carvalho wrote: > On Sun, Jul 30, 2017 at 10:47 PM, Sven Barth via fpc-pascal > wrote: >> (though if one would restrict the assignments to the constructors itself >> without any methods called by the constructor then we might be able to >> imple

Re: [fpc-pascal] Const attributes

2017-07-31 Thread Felipe Monteiro de Carvalho
On Sun, Jul 30, 2017 at 10:47 PM, Sven Barth via fpc-pascal wrote: > (though if one would restrict the assignments to the constructors itself > without any methods called by the constructor then we might be able to > implement that nevertheless, don't know what Java or other languages > with final

Re: [fpc-pascal] Const attributes

2017-07-30 Thread Marcos Douglas B. Santos
On Sun, Jul 30, 2017 at 5:47 PM, Sven Barth via fpc-pascal wrote: > On 30.07.2017 20:55, Marcos Douglas B. Santos wrote: >> >> I would like to instantiate my attribute only once inside constructor >> and then it will be "const" or "final", I mean, immutable. >> Today it is not possible, right? Any

Re: [fpc-pascal] Const attributes

2017-07-30 Thread Sven Barth via fpc-pascal
On 30.07.2017 20:55, Marcos Douglas B. Santos wrote: > On Sun, Jul 30, 2017 at 1:46 PM, Maciej Izak wrote: >> 2017-07-30 18:37 GMT+02:00 Marcos Douglas B. Santos : >>> >>> 1. Is this by design? >> >> >> Yes. To disallow this you need to use {$J-} directive. > > I know that we can use this "hack"

Re: [fpc-pascal] Const attributes

2017-07-30 Thread Howard Page-Clark via fpc-pascal
On 30/07/17 19:55, Marcos Douglas B. Santos wrote: I would like to instantiate my attribute only once inside constructor and then it will be "const" or "final", I mean, immutable. Today it is not possible, right? Any thoughts to the future? It is not what you are asking for, but you can do this:

Re: [fpc-pascal] Const attributes

2017-07-30 Thread Marcos Douglas B. Santos
On Sun, Jul 30, 2017 at 1:46 PM, Maciej Izak wrote: > 2017-07-30 18:37 GMT+02:00 Marcos Douglas B. Santos : >> >> 1. Is this by design? > > > Yes. To disallow this you need to use {$J-} directive. I know that we can use this "hack" in local functions/methods, but in an attribute... What is the go

Re: [fpc-pascal] Const attributes

2017-07-30 Thread Maciej Izak
2017-07-30 18:37 GMT+02:00 Marcos Douglas B. Santos : > 1. Is this by design? > Yes. To disallow this you need to use {$J-} directive. > 2. Is there a way to declare attributes "final" like Java does? > No for constants. -- Best regards, Maciej Izak __

[fpc-pascal] Const attributes

2017-07-30 Thread Marcos Douglas B. Santos
The following code is compilable. I'm using a private const with type defined and I can change it in the constructor. 1. Is this by design? 2. Is there a way to declare attributes "final" like Java does? === begin === type TFoo = class private const INT: Integer = 0; public construc