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

Re: [fpc-pascal] Best way to insert bytes into a TBytes variable?

2017-07-30 Thread Sven Barth via fpc-pascal
Am 30.07.2017 12:37 schrieb "Bo Berglund" : > > On Sun, 30 Jul 2017 09:33:59 +0200, Sven Barth via fpc-pascal > wrote: > > >> The application was started back in Delphi7 times when "string" > >> actually meant AnsiString and was a 1-byte per element container. > > > >You could always use RawByteSt

Re: [fpc-pascal] XML: Differences between Delphi and FPC

2017-07-30 Thread Marcos Douglas B. Santos
On Sun, Jul 30, 2017 at 5:06 AM, Michael Van Canneyt wrote: > > > On Sat, 29 Jul 2017, Marcos Douglas B. Santos wrote: > >> FPC/Lazarus always tried stay compatible with Delphi... thus, why the >> FPC XML classes is so different than Delphi classes? > > > Because the FPC classes predate the Delphi

Re: [fpc-pascal] XML: Differences between Delphi and FPC

2017-07-30 Thread Marcos Douglas B. Santos
On Sun, Jul 30, 2017 at 4:30 AM, Sven Barth via fpc-pascal wrote: >> I have a FPC/Lazarus project that will be compatible with Delphi. I >> would like to know whether I need to create wrappers to encapsulate >> the differences between them or there is a simple way to do that. >> >> A 3rd lib could

Re: [fpc-pascal] Best way to insert bytes into a TBytes variable?

2017-07-30 Thread Bo Berglund
On Sun, 30 Jul 2017 09:33:59 +0200, Sven Barth via fpc-pascal wrote: >> The application was started back in Delphi7 times when "string" >> actually meant AnsiString and was a 1-byte per element container. > >You could always use RawByteString or a string with a fixed codepage >instead if plain An

Re: [fpc-pascal] XML: Differences between Delphi and FPC

2017-07-30 Thread Michael Van Canneyt
On Sat, 29 Jul 2017, Marcos Douglas B. Santos wrote: Hi, FPC/Lazarus always tried stay compatible with Delphi... thus, why the FPC XML classes is so different than Delphi classes? Because the FPC classes predate the Delphi classes. They were based directly on the W3 DOM specifications.

Re: [fpc-pascal] BlockWrite of dynamic arrays

2017-07-30 Thread Sven Barth via fpc-pascal
Am 30.07.2017 08:21 schrieb "Bo Berglund" : > 3) Change the BlockWrite command from > BlockWrite(F, Buffer[1], Length(Buffer)); > to > BlockWrite(F, Buffer, Length(Buffer)); > > Note that I would like to *not* specify the index of the first element > of the array so that the same code can work for

Re: [fpc-pascal] Best way to insert bytes into a TBytes variable?

2017-07-30 Thread Sven Barth via fpc-pascal
Am 30.07.2017 08:07 schrieb "Bo Berglund" : > > On Fri, 28 Jul 2017 16:35:05 +0200, Michael Schnell > wrote: > > >On 25.07.2017 10:54, Bo Berglund wrote: > >> so I need to write efficient replacements for certain string functions (Delete, Insert, Copy etc). > >Why do you think the string functio

Re: [fpc-pascal] XML: Differences between Delphi and FPC

2017-07-30 Thread Sven Barth via fpc-pascal
Am 30.07.2017 09:30 schrieb "Sven Barth" : > > Am 30.07.2017 02:01 schrieb "Marcos Douglas B. Santos" : > > > > Hi, > > > > FPC/Lazarus always tried stay compatible with Delphi... thus, why the > > FPC XML classes is so different than Delphi classes? Addendum: FPC's XML library probably also comes

Re: [fpc-pascal] XML: Differences between Delphi and FPC

2017-07-30 Thread Sven Barth via fpc-pascal
Am 30.07.2017 02:01 schrieb "Marcos Douglas B. Santos" : > > Hi, > > FPC/Lazarus always tried stay compatible with Delphi... thus, why the > FPC XML classes is so different than Delphi classes? > > Delphi XML is interface-based. There exists IXMLDocument, IXMLNode and so on. > FPC has just classes.