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

2013-09-23 Thread Bart
On 9/23/13, Alberto Narduzzi wrote: >>> Are you sure regarding M considering there is no symbol for 5000? Or >>> didn't Romans count to more than 5000 - 1? > > yes I am. as 5000 - 1 would need to be written CMXCIX, which has the > 4-M-in-a-row, that is invalid, as a maximum of three is allowe

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

2013-09-23 Thread Bart
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 invalid character is found (docs say otherwise

[fpc-pascal] function param and TVarRec

2013-09-23 Thread Xiangrong Fang
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): procedure proc(p1: const; p2: const); So that: 1) p1

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

2013-09-23 Thread wkitty42
On Monday, September 23, 2013 7:09 AM, Guillermo Martínez wrote: > Hi, > > I'm receiving some of the messages from this mailing list coding in an > odd format: A block of characters and digits without any sense. For > example, the one I quoted at the end of this mail. Does somebody knows

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

2013-09-23 Thread Alberto Narduzzi
So the question is, what does or should do RomanToInt for invalid input? It is NOT called "CheckValidRoman", so it could be that the result for invalid input is simply undefined. If it is, then all is ok. so, what does "10AT" (or "$10AT" for tht matter) return for HexToDec??? maybe NaN, if the

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

2013-09-23 Thread Martin
On 23/09/2013 22:30, Alberto Narduzzi wrote: What about making an option of it? Anyhow, if the function accepts invalid combinations, what should it return? For some, the answer would be obvious (), but some combinations are indeed ambiguous (M) So that we maybe could accept unambiguous

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

2013-09-23 Thread Alberto Narduzzi
Are you sure regarding M considering there is no symbol for 5000? Or didn't Romans count to more than 5000 - 1? yes I am. as 5000 - 1 would need to be written CMXCIX, which has the 4-M-in-a-row, that is invalid, as a maximum of three is allowed. Yes, probably ancient Romans had no need to

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

2013-09-23 Thread Alberto Narduzzi
What about making an option of it? Anyhow, if the function accepts invalid combinations, what should it return? For some, the answer would be obvious (), but some combinations are indeed ambiguous (M) So that we maybe could accept unambiguous invalid combinations, but I don't see how to a

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

2013-09-23 Thread Alberto Narduzzi
What about making an option of it? If it accepts, then it should apply the subtraction rule: only the (one) numeral left to the other (bigger one) can be subtracted. So IIIM would be III + IM = 3 + 1000-1 = 1002 (and not 1000-3 = 997) There should be no ambiguity there, it's only a pain to watc

Re: [fpc-pascal] FPCUnit test + raise E;

2013-09-23 Thread Marcos Douglas
On Thu, Sep 19, 2013 at 1:44 AM, Sven Barth wrote: > Am 18.09.2013 23:34 schrieb "Marcos Douglas" : > > >> >> On Tue, Sep 17, 2013 at 2:41 PM, Sven Barth >> wrote: >> > On 17.09.2013 17:27, Marcos Douglas wrote: >> >> >> >> On Tue, Sep 17, 2013 at 12:18 PM, Marcos Douglas >> >> wrote: >> >>

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

2013-09-23 Thread Bart
On 9/23/13, Frederic Da Vitoria wrote: > What about making an option of it? It's up to the fpc devels. > Anyhow, if the function accepts invalid combinations, what should it > return? For some, the answer would be obvious (), but some combinations > are indeed ambiguous (M) So that we m

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

2013-09-23 Thread Frederic Da Vitoria
2013/9/23 Bart > The question was: is current behaviour (accepting IIMIIC etc.) a bug or > not. > What about making an option of it? Anyhow, if the function accepts invalid combinations, what should it return? For some, the answer would be obvious (), but some combinations are indeed ambigu

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

2013-09-23 Thread Bart
On 9/23/13, Sven Barth wrote: > Are you sure regarding M considering there is no symbol for 5000? Or > didn't Romans count to more than 5000 - 1? > There are numerous extensions upon the scheme. In later times adding horizontal lines above or under a Roman numeral meant multiply by 1000. I don'

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

2013-09-23 Thread Bart
On 9/23/13, Alberto Narduzzi wrote: > Thing is: > > 1. in the roman numerals, not all the digits can be subtracted from the > others > 2. no more than three same roman numerals can appear in a row. My implementation is a little more relaxed as to rule 2. It is more often "violated" than rule 1.

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

2013-09-23 Thread Sven Barth
On 23.09.2013 21:17, Alberto Narduzzi wrote: Ooops, I also forgot to mention that only I, X, C and M can appear up to three times in a row. V, L and D does not; they can only once. Are you sure regarding M considering there is no symbol for 5000? Or didn't Romans count to more than 5000 - 1?

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

2013-09-23 Thread Alberto Narduzzi
Ooops, I also forgot to mention that only I, X, C and M can appear up to three times in a row. V, L and D does not; they can only once. Cheers again, A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/

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

2013-09-23 Thread Alberto Narduzzi
Premise: I didn't go through your entire implementation, thou' at first sight looks much better than the current one. I know roman numerals since I was 8 or 9 yo, that makes a quick and dirt result of about 35 years. Thing is: 1. in the roman numerals, not all the digits can be subtracted fr

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

2013-09-23 Thread Bart
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; > else // i = Len-1 = last char we just add

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

2013-09-23 Thread Philippe
I changed the webmail configuration to MIME / 8 bits ... I hope it helps! Philippe On Mon, 23 Sep 2013 15:06:00 +0200, Guillermo Martínez wrote: > From: "Tomas Hajny" > >> That should not be an issue by itself. The more likely reason is probably use of 8-bit message (utf-8) without enco

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Zaher Dirkey
On Mon, Sep 23, 2013 at 4:28 PM, Zaher Dirkey wrote: > ​The idea is simply than needs to use a stream or RTTI, it is like a > record, if looked at an object like as a record but it is inheritable. > ​Compile can now every object body, and do the assigning as record assign. > ​ > That's the featur

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Zaher Dirkey
On Mon, Sep 23, 2013 at 12:58 PM, Graeme Geldenhuys wrote: > > Also be careful about the pitfalls of cloning a class. eg: How you want > to handle more complex cases. eg: Cloning a class with a reference to > another class, or cloning a class with an embedded class (field), etc... > tiOPF's imple

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Graeme Geldenhuys
On 23/09/13 10:46, Michael Van Canneyt wrote: > I've done this several times, it works well for most situations. My I also suggest Zaher takes a look at tiOPF's code to see how they implement class cloning. Also be careful about the pitfalls of cloning a class. eg: How you want to handle more com

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

2013-09-23 Thread Guillermo Martínez
From: "Tomas Hajny" > > That should not be an issue by itself. The more likely reason is > probably use of 8-bit message (utf-8) without encoding in us-ascii > (7-bit) compatible "envelope" - typically MIME Quoted Printable (as > already used for the HTML section, but not for the plain text > ve

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Sven Barth
Am 23.09.2013 14:23, schrieb patspiper: On 23/09/13 14:57, Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Mattias Gaertner wrote: On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael V

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, Frederic Da Vitoria wrote: Yes. But that works only for 'simple' types and still requires you to write code. For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way. Isn't there? Ma

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Frederic Da Vitoria
2013/9/23 Michael Van Canneyt > > On Mon, 23 Sep 2013, Mattias Gaertner wrote: > > On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) >> Michael Van Canneyt wrote: >> >> On Mon, 23 Sep 2013, Zaher Dirkey wrote: >>> >>> On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt < mich...@freepascal.org

Re: [fpc-pascal] Nested comments

2013-09-23 Thread Sven Barth
Am 23.09.2013 14:28, schrieb Juha Manninen: On Mon, Sep 23, 2013 at 3:06 PM, Michael Van Canneyt wrote: Use Delphi mode or TP mode. Thanks, it helped. Actually there already was {$MODE Delphi} in an include file. Apparently it does not work, it must be in every pascal unit. The include needs t

Re: [fpc-pascal] Nested comments

2013-09-23 Thread Juha Manninen
On Mon, Sep 23, 2013 at 3:06 PM, Michael Van Canneyt wrote: > Use Delphi mode or TP mode. Thanks, it helped. Actually there already was {$MODE Delphi} in an include file. Apparently it does not work, it must be in every pascal unit. This PDF package still does not compile with Lazarus. I will se

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread patspiper
On 23/09/13 14:57, Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Mattias Gaertner wrote: On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt wrote: Var C : TBaseObjectC

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

2013-09-23 Thread Tomas Hajny
On Mon, September 23, 2013 13:22, Sven Barth wrote: > Am 23.09.2013 13:09, schrieb Guillermo Martínez: >> Hi, >> >> I'm receiving some of the messages from this mailing list coding in an >> odd format: A block of characters and digits without any sense. For >> example, the one I quoted at the end

Re: [fpc-pascal] Nested comments

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Juha Manninen wrote: I realized FPC supports nested {} comments by default. SynPdf, a Synopse PDF engine http://synopse.info/fossil/wiki?name=PDF+Engine has '{' characters inside comments but they are not meant as nested

Re: [fpc-pascal] Nested comments

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, Juha Manninen wrote: I realized FPC supports nested {} comments by default. SynPdf, a Synopse PDF engine http://synopse.info/fossil/wiki?name=PDF+Engine has '{' characters inside comments but they are not meant as nested comments. How to turn nested comments off? I did n

[fpc-pascal] Nested comments

2013-09-23 Thread Juha Manninen
I realized FPC supports nested {} comments by default. SynPdf, a Synopse PDF engine http://synopse.info/fossil/wiki?name=PDF+Engine has '{' characters inside comments but they are not meant as nested comments. How to turn nested comments off? I did not find any such option even by using the new

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, Mattias Gaertner wrote: On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt wrote: Var   C : TBaseObjectClass; begin   C:=TBase

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

2013-09-23 Thread Sven Barth
Am 23.09.2013 13:09, schrieb Guillermo Martínez: Hi, I'm receiving some of the messages from this mailing list coding in an odd format: A block of characters and digits without any sense. For example, the one I quoted at the end of this mail. Does somebody knows why? According to my Thunderbi

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

2013-09-23 Thread Guillermo Martínez
Hi, I'm receiving some of the messages from this mailing list coding in an odd format: A block of characters and digits without any sense. For example, the one I quoted at the end of this mail. Does somebody knows why? Thanks, Guillermo "Ñuño" Martínez. > > Message: 5 > Date: Mon, 23 Sep 2013

Re: [fpc-pascal] Re: build a compiler for GO32v2 under Windows 8 (or 7)

2013-09-23 Thread Philippe
sorry ... delayed answer ... I don´t felt very well these days and this subject is a bit difficult for me ... but I will give time this week to read all I received ... and find out a way ... I´ll write later this week any way, I thank you very much all for your help! Philippe On Thu,

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Mattias Gaertner
On Mon, 23 Sep 2013 12:10:41 +0200 Frederic Da Vitoria wrote: > 2013/9/23 Mattias Gaertner > > > On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) > > Michael Van Canneyt wrote: > > > > > > > > > > > On Mon, 23 Sep 2013, Zaher Dirkey wrote: > > > > > > > > > > > On Mon, Sep 23, 2013 at 10:02 AM, Micha

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Mattias Gaertner
On Mon, 23 Sep 2013 13:13:27 +0300 Zaher Dirkey wrote: > On Mon, Sep 23, 2013 at 12:57 PM, Mattias Gaertner < > nc-gaert...@netcologne.de> wrote: > > > type > > TMyClass = class(TPersistent) > > private > >type > > TMyClassVars = record > >a,b,c: string; > > end; > > pri

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Zaher Dirkey
On Mon, Sep 23, 2013 at 12:57 PM, Mattias Gaertner < nc-gaert...@netcologne.de> wrote: > type > TMyClass = class(TPersistent) > private >type > TMyClassVars = record >a,b,c: string; > end; > private >F: TMyClassVars; > public >procedure Assign(Source: TPersistent)

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Frederic Da Vitoria
2013/9/23 Mattias Gaertner > On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) > Michael Van Canneyt wrote: > > > > > > > On Mon, 23 Sep 2013, Zaher Dirkey wrote: > > > > > > > > On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt < > mich...@freepascal.org> wrote: > > > Var > > > C : TB

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Mattias Gaertner
On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt wrote: > > > On Mon, 23 Sep 2013, Zaher Dirkey wrote: > > > > > On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt > > wrote: > > Var > >   C : TBaseObjectClass; > > begin > >   C:=TBaseObjectClass(Clas

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 12:46 PM, Michael Van Canneyt wrote: There is no such safe mechanism. The best you can do is make the properties published, and write an RTTI lookup routine that copies all Published values. I've done this

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Zaher Dirkey
On Mon, Sep 23, 2013 at 12:46 PM, Michael Van Canneyt < mich...@freepascal.org> wrote: > There is no such safe mechanism. > > The best you can do is make the properties published, and write an RTTI > lookup routine that copies all Published values. > I've done this several times, it works well for

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt wrote: Var   C : TBaseObjectClass; begin   C:=TBaseObjectClass(ClassType);   Result:=C.Create; end; ​Yes, that help me, thanks. Now about assigning I must re

[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-23 Thread Lukasz Sokol
On 20/09/13 19:49, Bart wrote: > On 9/20/13, Reinier Olislagers wrote: > >> The question however becomes "what is the >> algorithm for deciding invalid characters" which IMO will become a mess >> very quickly. Much better to just consider the entire input as invalid. >> > > Here's my implementat

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Zaher Dirkey
On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt < mich...@freepascal.org> wrote: > Var > C : TBaseObjectClass; > begin > C:=TBaseObjectClass(ClassType)**; > Result:=C.Create; > end; > ​Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy

Re: [fpc-pascal] bridging an C++ shared library statically

2013-09-23 Thread Sven Barth
Am 23.09.2013 10:53, schrieb Michael Schnell: On 09/21/2013 04:04 PM, Xiangrong Fang wrote: Hi All, I need to use a C++ so file in FreePascal AFAIK, you only can use C++ libraries in Pascal, if the functions for the mutual interface are "flat" C function (i. e. ANSI C functions not using an

Re: [fpc-pascal] bridging an C++ shared library statically

2013-09-23 Thread Michael Schnell
On 09/21/2013 04:04 PM, Xiangrong Fang wrote: Hi All, I need to use a C++ so file in FreePascal AFAIK, you only can use C++ libraries in Pascal, if the functions for the mutual interface are "flat" C function (i. e. ANSI C functions not using any C++ classes). Of course, on top of this in bo

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

2013-09-23 Thread 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. > > Why are you subclassing in this case anyway? > Thanks, I wi

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

2013-09-23 Thread Sven Barth
Am 23.09.2013 09:10 schrieb "Xiangrong Fang" : > > Hi All, > > I wrote a TTree generic class, the code is here: > > https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas > > While using this class, I encountered the following problem: > > program project1; > {$mode objfpc}{$H+} > us

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, patspiper wrote: On 23/09/13 10:02, Michael Van Canneyt wrote: This is wrong. You are typecasting a class reference to an object instance. The following works: {$mode objfpc} Type TBaseObject = class(TObject) public constructor Create; virtual; function Clone

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread patspiper
On 23/09/13 10:02, Michael Van Canneyt wrote: This is wrong. You are typecasting a class reference to an object instance. The following works: {$mode objfpc} Type TBaseObject = class(TObject) public constructor Create; virtual; function Clone:TBaseObject; end; TBaseObjectClass

[fpc-pascal] Incompatible type for generics?

2013-09-23 Thread Xiangrong Fang
Hi All, I wrote a TTree generic class, the code is here: https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas While using this class, I encountered the following problem: program project1; {$mode objfpc}{$H+} uses tree; type TIntTree = class(specialize TTree) end; var ti

Re: [fpc-pascal] Clone a instance of object

2013-09-23 Thread Michael Van Canneyt
On Mon, 23 Sep 2013, Zaher Dirkey wrote: Hi, I have objects (classes) derived from base one TBaseObject = class(TObject) public    constructor Create; virtual;    function Clone:TBaseObject; end; TMyObject = class(TBaseObject)    my fields here end; o1, o2:TmyObject; o1  already created; o