[fpc-pascal] Re: record byte alignment

2013-09-24 Thread leledumbo
2, according to the docs -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/record-byte-alignment-tp5716788p5716789.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist -

[fpc-pascal] record byte alignment

2013-09-24 Thread Xiangrong Fang
Hi There, I wonder what is the byte alignment of a NON-packed record? Is it always 4-byte, or 4-byte on 32-bit platform, 8-byte or 64-bit platform? Regards, Xiangrong ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.or

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Xiangrong Fang
I know it is same but why no error on the line: for n in sm1.reversed... regards. 在 2013-9-24 下午11:23,"Sven Barth" 写道: > Am 24.09.2013 17:14, schrieb Xiangrong Fang: > > 2013/9/24 Sven Barth > > >> How is PNode declared? What is the exact error? >> >> > PNode is declared inside TTreap generi

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Sven Barth
Am 24.09.2013 17:32, schrieb Xiangrong Fang: I know it is same but why no error on the line: for n in sm1.reversed... n is of type TStringMapper.PNode whereby PNode is declared inside TTreap and thus the type is in reality a TTreapString>. sm1.reversed returns a TTreap which has an enumerator

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Sven Barth
Am 24.09.2013 17:14, schrieb Xiangrong Fang: 2013/9/24 Sven Barth > How is PNode declared? What is the exact error? PNode is declared inside TTreap generic class, the source is here: https://github.com/xrfang/fpcollection/blob/master/src/units/treap.pas

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Xiangrong Fang
2013/9/24 Sven Barth > How is PNode declared? What is the exact error? > > PNode is declared inside TTreap generic class, the source is here: https://github.com/xrfang/fpcollection/blob/master/src/units/treap.pas The exact error is: Error: Incompatible types: got "TStringMapper.TTreap$AnsiStr

Re: [fpc-pascal] does Advanced Record constructor automatically zero all the memory space of that record?

2013-09-24 Thread Sven Barth
Am 24.09.2013 16:40, schrieb Dennis Poon: Sven Barth wrote: does Advanced Record constructor automatically zero all the memory space of that record? No, it does not. Neither in Delphi nor in FPC. Am 24.09.2013 12:36, schrieb Dennis Poon: if not, is there a clean and easy way to initialize th

Re: [fpc-pascal] does Advanced Record constructor automatically zero all the memory space of that record?

2013-09-24 Thread Dennis Poon
Sven Barth wrote: does Advanced Record constructor automatically zero all the memory space of that record? No, it does not. Neither in Delphi nor in FPC. Am 24.09.2013 12:36, schrieb Dennis Poon: if not, is there a clean and easy way to initialize the entire record memory space to zeros e.g.

Re: [fpc-pascal] RTTI Attributes

2013-09-24 Thread Sven Barth
Am 24.09.2013 16:13, schrieb Anthony Walter: I did some google searching which turned up very little so I decided to ask my question here. What is the current status of custom RTTI attributes in fpc trunk? Fot those who don't understand what I am asking about, here is an example. They are not

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Sven Barth
Am 24.09.2013 15:50, schrieb Xiangrong Fang: Hi Sven, 2013/9/23 Xiangrong Fang mailto:xrf...@gmail.com>> Short answer: you can't. The same would happen with normal classes. Long answer: You could add an additional method "Next" to your "TIntTree" which returns a

[fpc-pascal] RTTI Attributes

2013-09-24 Thread Anthony Walter
I did some google searching which turned up very little so I decided to ask my question here. What is the current status of custom RTTI attributes in fpc trunk? Fot those who don't understand what I am asking about, here is an example. type [AttrWithConstructor('Added text value!')] TRecord =

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Xiangrong Fang
Hi Sven, 2013/9/23 Xiangrong Fang > Short answer: you can't. The same would happen with normal classes. >> >> Long answer: You could add an additional method "Next" to your "TIntTree" >> which returns a "TIntTree" and just do "Result := TIntTree(inherited >> Next);" there. >> > I still have pro

Re: [fpc-pascal] Re: Problems reading some of the messages from this mailing list

2013-09-24 Thread wkitty42
On Tuesday, September 24, 2013 7:26 AM, Guillermo Martínez wrote: > Sorry, Philippe, but I can't read your messages. :( > > > Date: Mon, 23 Sep 2013 10:39:20 -0300 > > From: Philippe > > Subject: Re: [fpc-pascal] Re: Problems reading some of the messages > > fromthis mailing list

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 24/09/2013 14:25, Marco van de Voort wrote: > In our previous episode, Reinier Olislagers said: >>> Because that has an use. The internal FPC compatability, specially in >>> the more fringe areas like this, service no use than fattening maillist >>> archives IMHO. >> >> If you don't see a use f

Re: [fpc-pascal] FPC happily eats wrong parameters

2013-09-24 Thread Mattias Gaertner
On Tue, 24 Sep 2013 14:28:42 +0200 Sven Barth wrote: > Am 24.09.2013 14:17, schrieb Mattias Gaertner: > > Hi, > > > > When calling "fpc -d foo test.pas" there are two mistakes: > > First the -d parameter is missing a value, which fpc silently ignores. > > And second there are two files to compile

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 24/09/2013 14:11, Sven Barth wrote: > Am 24.09.2013 13:47, schrieb Reinier Olislagers: >> On 24/09/2013 13:13, Sven Barth wrote: >>> Am 24.09.2013 11:27, schrieb Reinier Olislagers: On 24/09/2013 11:11, Marco van de Voort wrote: > In our previous episode, Reinier Olislagers said: >>

Re: [fpc-pascal] How to stop a HttpApp via request?

2013-09-24 Thread silvioprog
2013/9/24 Michael Van Canneyt > On Tue, 24 Sep 2013, Graeme Geldenhuys wrote: > >> On 23/09/13 21:03, silvioprog wrote: >> >>> How do I stop the socket before finishing my application? >>> >> >> I've been unsuccessful with that myself, and mentioned it to Michael van >> Canneyt. I tried everythi

Re: [fpc-pascal] How to stop a HttpApp via request?

2013-09-24 Thread silvioprog
2013/9/24 Graeme Geldenhuys > On 23/09/13 21:03, silvioprog wrote: > > How do I stop the socket before finishing my application? > > I've been unsuccessful with that myself, and mentioned it to Michael van > Canneyt. I tried everything I could thing of, and nothing worked. I was > using Windows.

Re: [fpc-pascal] FPC happily eats wrong parameters

2013-09-24 Thread Jonas Maebe
On 24 Sep 2013, at 14:34, Mattias Gaertner wrote: On Tue, 24 Sep 2013 14:23:52 +0200 Jonas Maebe wrote: By design, FPC gives a warning (not a hint) when two file names are specified. You are right, it is a warning. Why not an error? FPC used to silently ignore multiple file names, so I a

Re: [fpc-pascal] FPC happily eats wrong parameters

2013-09-24 Thread Mattias Gaertner
On Tue, 24 Sep 2013 14:23:52 +0200 Jonas Maebe wrote: > > On 24 Sep 2013, at 14:17, Mattias Gaertner wrote: > > > When calling "fpc -d foo test.pas" there are two mistakes: > > First the -d parameter is missing a value, which fpc silently ignores. > > And second there are two files to compile.

Re: [fpc-pascal] FPC happily eats wrong parameters

2013-09-24 Thread Sven Barth
Am 24.09.2013 14:17, schrieb Mattias Gaertner: Hi, When calling "fpc -d foo test.pas" there are two mistakes: First the -d parameter is missing a value, which fpc silently ignores. And second there are two files to compile. FPC ignores that too, gives a hint, but compiles anyway. Design or bug?

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Marco van de Voort
In our previous episode, Reinier Olislagers said: > >> facto behaviour* (return 0 on invalid values) as it is quite sensible > >> for this kind of numbers. > > > > It is non-orthogonal. > What is non-orthogonal? RomanToInt uses 0 to signal error, other xxxtoint functions throw exceptions. > > B

Re: [fpc-pascal] FPC happily eats wrong parameters

2013-09-24 Thread Jonas Maebe
On 24 Sep 2013, at 14:17, Mattias Gaertner wrote: When calling "fpc -d foo test.pas" there are two mistakes: First the -d parameter is missing a value, which fpc silently ignores. And second there are two files to compile. FPC ignores that too, gives a hint, but compiles anyway. Design or bug?

[fpc-pascal] FPC happily eats wrong parameters

2013-09-24 Thread Mattias Gaertner
Hi, When calling "fpc -d foo test.pas" there are two mistakes: First the -d parameter is missing a value, which fpc silently ignores. And second there are two files to compile. FPC ignores that too, gives a hint, but compiles anyway. Design or bug? Mattias ___

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Sven Barth
Am 24.09.2013 13:47, schrieb Reinier Olislagers: On 24/09/2013 13:13, Sven Barth wrote: Am 24.09.2013 11:27, schrieb Reinier Olislagers: On 24/09/2013 11:11, Marco van de Voort wrote: In our previous episode, Reinier Olislagers said: Yes, but since the routine probably has low utilisation I c

[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 24/09/2013 13:13, Sven Barth wrote: > Am 24.09.2013 11:27, schrieb Reinier Olislagers: >> On 24/09/2013 11:11, Marco van de Voort wrote: >>> In our previous episode, Reinier Olislagers said: > Yes, but since the routine probably has low utilisation I choose for > structuring all conversi

Re: [fpc-pascal] Re: Problems reading some of the messages from this mailing list

2013-09-24 Thread Sven Barth
Am 24.09.2013 13:26, schrieb Guillermo Martínez: Sorry, Philippe, but I can't read your messages. :( Could you send the complete source code of such a mail to - at best - fpc-other (additionally zipped to avoid any conversion)? So that Tomas or someone else can have a look at it. Regards, Sve

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread DaWorm
Just a guess here, but I would think there have now been more posts in this thread than the total number of programs to use this function. Probably by a wide margin. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/

[fpc-pascal] Re: Problems reading some of the messages from this mailing list

2013-09-24 Thread Guillermo Martínez
Sorry, Philippe, but I can't read your messages. :( > Date: Mon, 23 Sep 2013 10:39:20 -0300 > From: Philippe > Subject: Re: [fpc-pascal] Re: Problems reading some of the messages > fromthis mailing list > To: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; chars

Re: [fpc-pascal] does Advanced Record constructor automatically zero all the memory space of that record?

2013-09-24 Thread Sven Barth
does Advanced Record constructor automatically zero all the memory space of that record? No, it does not. Neither in Delphi nor in FPC. Am 24.09.2013 12:36, schrieb Dennis Poon: if not, is there a clean and easy way to initialize the entire record memory space to zeros e.g. constructor TMyRec

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Sven Barth
Am 24.09.2013 11:27, schrieb Reinier Olislagers: On 24/09/2013 11:11, Marco van de Voort wrote: In our previous episode, Reinier Olislagers said: Yes, but since the routine probably has low utilisation I choose for structuring all conversion routines all the same. I would rather choose for mai

Re: [fpc-pascal] Is it possible to know the data type of a specialized generics class?

2013-09-24 Thread Sven Barth
Am 24.09.2013 11:53, schrieb Xiangrong Fang: But it's not a good idea as you'd still need to convert Data to a TObject (e.g. by using a cast), but that will fail if Data is something else than a pointer-like type... This worked in my TTree class (destructor): if PTypeInfo(TypeInf

[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Lukasz Sokol
On 23/09/13 17:18, Bart wrote: > On 9/23/13, Lukasz Sokol wrote: > >> function TryRomanToInt(AInput:String; out AResult: integer):boolean; >> var i, Len, N, Np1 : integer; > [snip] >> >> >> if N >= Np1 then AResult := AResult + N >> else AResult := AResult - N; >> >> end; >>

Re: [fpc-pascal] does Advanced Record constructor automatically zero all the memory space of that record?

2013-09-24 Thread Dmitry Boyarintsev
If in doubt, why not to use the old-school records and an init-value procedure. thanks, Dmitry On Tuesday, September 24, 2013, Dennis Poon wrote: > ** > if not, is there a clean and easy way to initialize the entire record > memory space to zeros e.g. > > constructor TMyRecord.Create(TheValue :

[fpc-pascal] does Advanced Record constructor automatically zero all the memory space of that record?

2013-09-24 Thread Dennis Poon
if not, is there a clean and easy way to initialize the entire record memory space to zeros e.g. constructor TMyRecord.Create(TheValue : Integer); begin FillChar(self, sizeof(Self), 0); Value := TheVal; end; Is there a Self variable for advanced record methods/constructors ? By the way, is

Re: [fpc-pascal] Socket error messages

2013-09-24 Thread Michael Van Canneyt
On Tue, 24 Sep 2013, Mark Morgan Lloyd wrote: How does one convert from the numeric value returned by SocketError to the name of the error (specifically, to e.g. EsockEINVAL rather than EsysEINVAL, i.e. to be in line with the definition of functions like fpbind)? use the errors unit. (spe

Re: [fpc-pascal] Socket error messages

2013-09-24 Thread Mark Morgan Lloyd
How does one convert from the numeric value returned by SocketError to the name of the error (specifically, to e.g. EsockEINVAL rather than EsysEINVAL, i.e. to be in line with the definition of functions like fpbind)? > use the errors unit. (specific for unix) > > It has a functiun strerror()

Re: [fpc-pascal] Is it possible to know the data type of a specialized generics class?

2013-09-24 Thread Xiangrong Fang
> But it's not a good idea as you'd still need to convert Data to a TObject > (e.g. by using a cast), but that will fail if Data is something else than a > pointer-like type... > > This worked in my TTree class (destructor): if PTypeInfo(TypeInfo(Data))^.Kind = tkObject then TObject(Data).Free;

Re: [fpc-pascal] How to stop a HttpApp via request?

2013-09-24 Thread Michael Van Canneyt
On Tue, 24 Sep 2013, Graeme Geldenhuys wrote: On 23/09/13 21:03, silvioprog wrote: How do I stop the socket before finishing my application? I've been unsuccessful with that myself, and mentioned it to Michael van Canneyt. I tried everything I could thing of, and nothing worked. I was using

Re: [fpc-pascal] How to stop a HttpApp via request?

2013-09-24 Thread Graeme Geldenhuys
On 23/09/13 21:03, silvioprog wrote: > How do I stop the socket before finishing my application? I've been unsuccessful with that myself, and mentioned it to Michael van Canneyt. I tried everything I could thing of, and nothing worked. I was using Windows. I haven't tested under Linux or FreeBSD y

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 24/09/2013 11:11, Marco van de Voort wrote: > In our previous episode, Reinier Olislagers said: >>> >>> Yes, but since the routine probably has low utilisation I choose for >>> structuring all conversion routines all the same. >> I would rather choose for maintaining backward compatiblity, the *

Re: [fpc-pascal] Is it possible to know the data type of a specialized generics class?

2013-09-24 Thread Sven Barth
Am 24.09.2013 11:25, schrieb Sven Barth: Am 24.09.2013 11:19, schrieb Xiangrong Fang: Hi All, say, I have a class TTree; in the destructor of that class, is it possible to know the actual type of T? I want to do things like: generic TTree = class public Data: T; destructor Destroy; overrid

Re: [fpc-pascal] Is it possible to know the data type of a specialized generics class?

2013-09-24 Thread Sven Barth
Am 24.09.2013 11:19, schrieb Xiangrong Fang: Hi All, say, I have a class TTree; in the destructor of that class, is it possible to know the actual type of T? I want to do things like: generic TTree = class public Data: T; destructor Destroy; override; end; destructor TTree.Destroy; begin

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 24/09/2013 11:07, Frederic Da Vitoria wrote: > 2013/9/24 Reinier Olislagers > > > On 24/09/2013 09:09, Marco van de Voort wrote: > > In our previous episode, Bart said: > > Moreover I don't think that first attempts should fixate interfaces >

Re: [fpc-pascal] Socket error messages

2013-09-24 Thread Michael Van Canneyt
On Tue, 24 Sep 2013, Mark Morgan Lloyd wrote: How does one convert from the numeric value returned by SocketError to the name of the error (specifically, to e.g. EsockEINVAL rather than EsysEINVAL, i.e. to be in line with the definition of functions like fpbind)? use the errors unit. (speci

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Sven Barth
Am 24.09.2013 11:07, schrieb Frederic Da Vitoria: 2013/9/24 Reinier Olislagers > On 24/09/2013 09:09, Marco van de Voort wrote: > In our previous episode, Bart said: >>> Raise an exception >> >> This will break existing implementations that

[fpc-pascal] Is it possible to know the data type of a specialized generics class?

2013-09-24 Thread Xiangrong Fang
Hi All, say, I have a class TTree; in the destructor of that class, is it possible to know the actual type of T? I want to do things like: generic TTree = class public Data: T; destructor Destroy; override; end; destructor TTree.Destroy; begin ... ... if Data is TObject then Data.Free; e

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Marco van de Voort
In our previous episode, Reinier Olislagers said: > > > > Yes, but since the routine probably has low utilisation I choose for > > structuring all conversion routines all the same. > I would rather choose for maintaining backward compatiblity, the *de > facto behaviour* (return 0 on invalid values

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Frederic Da Vitoria
2013/9/24 Reinier Olislagers > On 24/09/2013 09:09, Marco van de Voort wrote: > > In our previous episode, Bart said: > >>> Raise an exception > >> > >> This will break existing implementations that either expect IM to be > >> 999, or ABC to be 0 (indicating failure), and that certainly do not >

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Frederic Da Vitoria
2013/9/24 Reinier Olislagers > On 23/09/2013 23:34, Alberto Narduzzi wrote: > >> I don't believe though Romans knew negative numbers. > Well, they could subtract, couldn't they :) > > >> But I'm certainly not an expert on the matter. > > > > never though about, but if the only matter is DEBT, the

[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 23/09/2013 23:34, Alberto Narduzzi wrote: >> I don't believe though Romans knew negative numbers. Well, they could subtract, couldn't they :) >> But I'm certainly not an expert on the matter. > > never though about, but if the only matter is DEBT, then just write > positive numbers under the

[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 24/09/2013 09:09, Marco van de Voort wrote: > In our previous episode, Bart said: >>> Raise an exception >> >> This will break existing implementations that either expect IM to be >> 999, or ABC to be 0 (indicating failure), and that certainly do not >> expect that this function throws an except

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Bart
On 9/24/13, Marco van de Voort wrote: > And let's not beat about the bush: the main reason for the routine is to > show beginning programmers that their homework can be done using a fixed > function :-) LOL Bart ___ fpc-pascal maillist - fpc-pascal@

[fpc-pascal] Socket error messages

2013-09-24 Thread Mark Morgan Lloyd
How does one convert from the numeric value returned by SocketError to the name of the error (specifically, to e.g. EsockEINVAL rather than EsysEINVAL, i.e. to be in line with the definition of functions like fpbind)? I notice that the example for fpconnect at http://lazarus-ccr.sourceforge.n

[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Reinier Olislagers
On 24/09/2013 08:57, Bart wrote: > On 9/23/13, Martin wrote: > >> So the question is, what does or should do RomanToInt for invalid input? > > Probably return 0. > Romans seemed to have no zero at all. > It also will not break backwards compatibility, current > implementatiosn returns zero if an

Re: [fpc-pascal] function param and TVarRec

2013-09-24 Thread Michael Van Canneyt
On Tue, 24 Sep 2013, Xiangrong Fang wrote: Thanks,  this works, sort of.  But does not meet my needs, I will pass in either an int value or an object, but Variant is not compatible with TObject. You could make it so using a custom variant manager or operator overloading, but this requires

Re: [fpc-pascal] function param and TVarRec

2013-09-24 Thread Xiangrong Fang
Thanks, this works, sort of. But does not meet my needs, I will pass in either an int value or an object, but Variant is not compatible with TObject. Alternatively, this also does NOT work: array [0..1] of const; no matter it is a type definition or used as function parameter. This is a trivi

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Marco van de Voort
In our previous episode, Bart said: > > Raise an exception > > This will break existing implementations that either expect IM to be > 999, or ABC to be 0 (indicating failure), and that certainly do not > expect that this function throws an exception at them. Yes, but since the routine probably ha

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Bart
On 9/24/13, Marco van de Voort wrote: > Raise an exception This will break existing implementations that either expect IM to be 999, or ABC to be 0 (indicating failure), and that certainly do not expect that this function throws an exception at them. > and have a try* version to avoid the excep

Re: [fpc-pascal] function param and TVarRec

2013-09-24 Thread Michael Van Canneyt
On Tue, 24 Sep 2013, Xiangrong Fang wrote: Hi There, If you declare this: procedure proc(param: array of const); Then you can pass any type of varaible to param, however, only in an array, such as proc([1, 2]); Is it possible to achieve the effect of the code below (which is wrong): proc

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Bart
On 9/23/13, Alberto Narduzzi wrote: > But IsValidRoman is as good as a solution too, indeed... Trying to determine if it is valid is 90% of calculating the output. Hence my previous approach of TryRomanToInt. It returns FALSE if the string isn't a legal Roman numeral. And it is compliant with ou

Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Marco van de Voort
In our previous episode, Martin said: > > they are not ambiguous, they are simply INVALID. > > So the question is, what does or should do RomanToInt for invalid input? Raise an exception and have a try* version to avoid the exception, just like all other str*to functions.