Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-14 Thread Andrew Hall via fpc-pascal
Apologies if already suggested as there are a lot of messages in this thread - but would this meet your needs: tabulatorkindty = (tak_none=-1,tak_left,tak_right,tak_centered,tak_decimal); This ensures -1 is a valid enum value so tabulatorkindty(-1) should not raise a warning (I’ve not tried it

Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Andrew Hall
If you cast your “something” to a typed pointer, the compiler will do the work for you in the usual way: PDouble(something)^ := myDouble; PAnsiString(something)^ := myAnsiString; myRecordStructure := PMyRecordStructure(something)^; Or less elegantly: AnsiString(Pointer(something)^) := myAnsiSt

Re: [fpc-pascal] Memory leak or object destruction?

2011-02-02 Thread Andrew Hall
Interfaces support reference counting. ISomeObject = interface TSomeObject = class(TinterfacedObject, ISomeObject) var MyObj: ISomeObject; Regards, On 02 Feb 11, at 15:22 , Bo Berglund wrote: > Will this create a memory leak or will FPC fnd by reference counting > that nothing references the

Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread Andrew Hall
On 30 Jan 11, at 22:28 , cobines wrote: > it is now a pointer to IBaseInterface, because of implicit QueryInterface? The reference changes because you have explicitly cast (the implementing object) to another interface. > So, I think I can compare interface variables but first I have to > bring

Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread Andrew Hall
A more detailed answer: iDesc holds TDescClass as IDescInterface iBase holds TDescClass as IDescInterface iBaseAsBase holds TBaseClass as IBaseInterface iBase holds the IDescInterface interface because they are compile-time compatible (the same as an ancestor object reference holding an object f

Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread Andrew Hall
Interfaces do not behave like classes. Each each interface implemented/supported by a class is unique - at runtime a "descendent" interface is entirely unrelated to its ancestor. Regards Andrew. On 30 Jan 11, at 20:37 , cobines wrote: > Hello everyone, > > I have attached a program about wh

Re: [fpc-pascal] Is it posible to implement more than one interface in a class defination?

2010-11-14 Thread Andrew Hall
FWIW, both interface delegation ("implements") and "method aliasing" have been supported in FPC for at least 2 years (we first tested/used them in January 2009 with FPC 2.2.2 which was released in August 2008). * We have used method aliasing extensively - it appears to behave the same as Bor

Re: [fpc-pascal] Is it posible to implement more than one interface in a class defination?

2010-11-14 Thread Andrew Hall
I suspect the reason is that the object still has a refCount of 1 when you free it and this code raises the exception: procedure TInterfacedObject.BeforeDestruction; begin if frefcount<>0 then HandleError(204); end; You should never free an interfaced object di

Re: [fpc-pascal] Problem accessing Class Method with abstraction

2010-10-17 Thread Andrew Hall
The reason you cannot call VerifyID's from coGeneric is that the compiler sees coGeneric as a TPersistentClass which does not implement the VerifyIDs method. The following changes will give you the desired result... type TCoreObjectClass = class of TCoreObject; If (coGeneric<>nil) and coGe

Re: [fpc-pascal] casting back a pointer to original type --> variable & value types

2010-05-30 Thread Andrew Hall
On 30 May 10, at 04:00 , spir ☣ wrote: > So, it seems the language knows (at runtime) about the real type of a > *value*. I must declare element, the variable, with type C, since I do not > know anything at coding time. But Pascal correctly calls C1.text, due to > "virtual" & "override" modifie

Re: [fpc-pascal] casting back a pointer to original type

2010-05-29 Thread Andrew Hall
On 29 May 10, at 15:26 , spir ☣ wrote: > I cannot do that. C0 (and all classes) instances need a text method. I also > cannot have 2 methods (one static, one virtual) with different names. It's a > basic feature, always called with the same name. Like getItem for a hierarchy > of collections: ev

Re: [fpc-pascal] question about class

2010-05-14 Thread Andrew Hall
>> Do i need to explicitely name self as param? self is a reserved keyword which represents the reference to the object of context (much the same as using "result" in a function) - it is understood by the compiler and does not need to be specified. >> Is self actually a pointer? If yes, do I nee

Re: [fpc-pascal] constructor as procvar

2010-03-20 Thread Andrew Hall
Hi David, If I'm reading your need correctly... function CopyMyMammal(value: T_Mammal; extraParameters): T_Mammal; begin result := T_Mammal_Class(value.ClassType).Create(withExtraParameters); end; Only confusion is you say you cannot make the type conversion? But the above code is correct and

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Andrew Hall
ly by "assuming" " = 0", " = nil", etc at the end of a global declaration if nothing else has been specified. Regards, Andrew Hall. On 28 Nov 09, at 11:58 , Michael Van Canneyt wrote: >> Global variables (even in the implementation section) are always >>

Re: [fpc-pascal] Interfaces via implements keyword

2009-11-25 Thread Andrew Hall
you to cast to any interface supported by the host class: "I2 := I1.Owner as IIntf2" PS - normally your host class would not support the interface you are using "implements" to achieve... therefore the confusing circumstances of your first example would not normally happen - yo

Re: [fpc-pascal] Interfaces via implements keyword

2009-11-24 Thread Andrew Hall
) requesting "IIntf2", which O does support, so the returned "IIntf2" interface is still implemented by "O". When calling "I2.Print", "O" as the implementing object returns 30. When you comment out "implements", the only object implem

[fpc-pascal] FPC with Firebird SuperServer

2009-01-25 Thread Andrew Hall
required or does the FPC library required modification? 2) Is there other advice the forum can offer (eg. does Classic remain a reasonable choice, is SuperServer support planned, etc). Thank you. Regards, Andrew Hall. smime.p7s Description: S/MIME cryptographic signature __

[fpc-pascal] Decimal Precision Issue with Firebird

2009-01-25 Thread Andrew Hall
is there a workaround? We require a decimal with at least 9 decimal places precision (?perhaps DOUBLE PRECISION) 3) the issue with negative numerics with TSQLQuery being treated as unsigned, described in the bug list as fixed in FPC 231 - has this fix been moved to FPC 224? Thank you. Regards, A