Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread leledumbo
> We already have zero based strings in 3.0.0 if {$ZeroBasedStrings On} is > used (it's a local switch). It works with Ansi-, Wide- and > UnicodeString, but not with ShortString. *shocked* so many hidden treasures in FPC... -- View this message in context: http://free-pascal-general.1045716

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread Sven Barth
Am 15.04.2016 18:37 schrieb "Jürgen Hestermann" : > > Another advantage of having 1-based indeces in dyn. arrays > would be that you could store indeces in unsigned integers > while with 0-based indices high() may give -1. Indices in Pascal are always signed. Regards, Sven ___

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread Dmitry Boyarintsev
On Fri, Apr 15, 2016 at 1:19 PM, Jürgen Hestermann < juergen.hesterm...@gmx.de> wrote: > > So why do we need {$ZeroBasedStrings On} at all? ;-) > The same reason as other FPC features - (some of) Delphi code compatibility. thanks, Dmitry ___ fpc-pascal

[fpc-pascal] STATIC can only be used on non-virtual class methods

2016-04-15 Thread silvioprog
Hello, Consider the following code: === test begin === {$MODE DELPHI} TStaticVirtualTest = class sealed(TObject) public class procedure Test; virtual; static; end; class procedure TStaticVirtualTest.Test; begin end; === test end === You can compile it in FPC (trunk), but, when you

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread Jürgen Hestermann
Another advantage of having 1-based indeces in dyn. arrays would be that you could store indeces in unsigned integers while with 0-based indices high() may give -1. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread Jürgen Hestermann
Am 2016-04-15 um 10:26 schrieb Graeme Geldenhuys: >> Is there also a switch >> {$OneBasedDynArrays On} ? >> No more confusion about first and last element index. > You really should be using low() and high() instead. ;-) So why do we need {$ZeroBasedStrings On} at all? ;-) Of course, when you s

Re: [fpc-pascal] Error: Internal error 2014052302 on changing some common units

2016-04-15 Thread Dennis Poon
Sven Barth wrote: Am 15.04.2016 13:40 schrieb "Dennis" >: > > whenever I change the source of a common unit (that is used by many other units), when I compile with lazarus 1.7 +FPC 3.1.1, this error will appear in the messages > "Error: Internal error 20140523

Re: [fpc-pascal] Error: Internal error 2014052302 on changing some common units

2016-04-15 Thread Sven Barth
Am 15.04.2016 13:40 schrieb "Dennis" : > > whenever I change the source of a common unit (that is used by many other units), when I compile with lazarus 1.7 +FPC 3.1.1, this error will appear in the messages > "Error: Internal error 2014052302". Are you sure that you're using the most current vers

Re: [fpc-pascal] A better way?

2016-04-15 Thread Ryan Joseph
> On Apr 15, 2016, at 7:03 PM, Sven Barth wrote: > > Again, you're fighting against design principles of the language. It's just > as if you'd want to have virtual class methods in C++… Agreed. Everyone has their own list of things they want their language to do I guess. Maybe I got spoiled w

Re: [fpc-pascal] A better way?

2016-04-15 Thread Sven Barth
Am 15.04.2016 13:58 schrieb "Ryan Joseph" : > > > > On Apr 15, 2016, at 5:13 PM, Tony Whyman wrote: > > > > unit unitA; > > > > interface > > > > type > > > > class TClassA > > private > > FClassBObject: TObject; > > public > > procedure SomeProc; > > end; > > > > implementation > > > > uses uni

Re: [fpc-pascal] A better way?

2016-04-15 Thread Sven Barth
Am 15.04.2016 11:22 schrieb "Dennis" : > > >> > You could describe it as typecast done in the var clause of a method. The right hand identifier is not restricted to function parameters. >> >> While it works using "absolute" for a public API is rather unsafe (I'd only use that in private methods). I

Re: [fpc-pascal] A better way?

2016-04-15 Thread Ryan Joseph
> On Apr 15, 2016, at 5:13 PM, Tony Whyman > wrote: > > unit unitA; > > interface > > type > > class TClassA > private > FClassBObject: TObject; > public > procedure SomeProc; > end; > > implementation > > uses unitB; > > procedure TClassA.SomeProc; > var aClassBObject: TClassB absolute

[fpc-pascal] Error: Internal error 2014052302 on changing some common units

2016-04-15 Thread Dennis
whenever I change the source of a common unit (that is used by many other units), when I compile with lazarus 1.7 +FPC 3.1.1, this error will appear in the messages "Error: Internal error 2014052302". What is that? Normally, I just go to Menu -> Run-Build and this message will disappear but t

Re: [fpc-pascal] A better way?

2016-04-15 Thread Ryan Joseph
> On Apr 15, 2016, at 6:26 PM, Ryan Joseph wrote: > > I remember trying to doing pre-parser type things using macros but the think > the conclusion is they don’t work by just replace text like in C. > > I’m trying an example like this but getting errors and even crashing the > compiler (seg f

Re: [fpc-pascal] A better way?

2016-04-15 Thread Ryan Joseph
> On Apr 15, 2016, at 5:34 PM, Tony Whyman > wrote: > > Just remembered, FPC also supports macros - see > http://www.freepascal.org/docs-html/prog/progse5.html > > I haven't tested it, but you should be able to do > > {$MACRO On} > > {$DEFINE aClassBObject:=TClassB(FClassBObject) } > > and

Re: [fpc-pascal] A better way?

2016-04-15 Thread Tony Whyman
Just remembered, FPC also supports macros - see http://www.freepascal.org/docs-html/prog/progse5.html I haven't tested it, but you should be able to do {$MACRO On} {$DEFINE aClassBObject:=TClassB(FClassBObject) } and then use aClassBObject instead of the coercion. On 15/04/16 11:13, Tony Why

Re: [fpc-pascal] A better way?

2016-04-15 Thread Tony Whyman
On 15/04/16 10:00, Ryan Joseph wrote: So, a common scenario is a member variable being declared as TObject then having to typecast it every time I need to access one of it’s methods. Declaring another variable in each function instead of typecasting is perhaps more work but maybe I’m not get

Re: [fpc-pascal] A better way?

2016-04-15 Thread Ryan Joseph
> On Apr 15, 2016, at 3:56 PM, Sven Barth wrote: > > *shudders* Before we introduce such syntax I'd prefer to get the formal class > types that were added for Objective Pascal working with Object Pascal as well > (which would be exactly what you want just with a more sane syntax). I agree 100

Re: [fpc-pascal] A better way?

2016-04-15 Thread Ryan Joseph
> On Apr 15, 2016, at 3:46 PM, Tony Whyman > wrote: > > You could describe it as typecast done in the var clause of a method. The > right hand identifier is not restricted to function parameters. I’m not understanding how this would work. I’ve read that the keyword (I’ve never heard about u

Re: [fpc-pascal] A better way?

2016-04-15 Thread Dennis
> You could describe it as typecast done in the var clause of a method. The right hand identifier is not restricted to function parameters. While it works using "absolute" for a public API is rather unsafe (I'd only use that in private methods). In those cases the "as" operator should he us

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread Sven Barth
Am 15.04.2016 10:47 schrieb "Graeme Geldenhuys" < mailingli...@geldenhuys.co.uk>: > > Is there also a switch > > {$OneBasedDynArrays On} ? > > No more confusion about first and last element index. > > You really should be using low() and high() instead. ;-) Definitely (and they also work for stri

Re: [fpc-pascal] A better way?

2016-04-15 Thread Sven Barth
Am 15.04.2016 08:46 schrieb "Ryan Joseph" : > Does this look like more work than using $includes? Maybe I need to seriously considering reorganizing my projects to work like this but it just feels wrong for some reason. > > = > > unit Globals; > interface > > type > HCla

Re: [fpc-pascal] A better way?

2016-04-15 Thread Sven Barth
Am 15.04.2016 10:46 schrieb "Tony Whyman" : > > Ryan, > > If you want to get rid of (ugly) typecasts then maybe you should investigate the "absolute" keyword. You get a lot of examples in the LCL. For example, here's one I chose at random: > > function TGtk2WidgetSet.RawImage_CreateBitmaps(const AR

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread Graeme Geldenhuys
On 2016-04-15 07:24, Jürgen Hestermann wrote: > Though I will not use it. Neither would I. I don't see the need for it. > Is there also a switch > {$OneBasedDynArrays On} ? > No more confusion about first and last element index. You really should be using low() and high() instead. ;-) Regard

Re: [fpc-pascal] A better way?

2016-04-15 Thread Tony Whyman
Ryan, If you want to get rid of (ugly) typecasts then maybe you should investigate the "absolute" keyword. You get a lot of examples in the LCL. For example, here's one I chose at random: function TGtk2WidgetSet.RawImage_CreateBitmaps(const ARawImage: TRawImage; out ABitmap, AMask: HBitma

Re: [fpc-pascal] A better way?

2016-04-15 Thread Graeme Geldenhuys
On 2016-04-15 07:15, Ryan Joseph wrote: > Sure you could put those all in file for this example but in the real > world there may be dozens of TClassB subclasses which would make the > unit 10,000’s of lines long and impossible to navigate. Big units have never been a problem to navigate for me. Y

Re: [fpc-pascal] FPC 3 regression: cannot use TStringList for UTF-8 data any more?

2016-04-15 Thread Graeme Geldenhuys
On 2016-04-14 09:16, Michael Schnell wrote: > For a test I did result := StringCodePage('äü'); If you as a programmer knows the unit is saved in UTF-8 encoding, then add {$codepage utf8} to the top of the unit. That tells the compiler how to interpret string constants in that unit (without the n