[fpc-pascal] (no subject)

2011-11-14 Thread sider2jp

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: pchar with more than 255 characters

2011-11-14 Thread Rainer Stratmann
Am Sunday 13 November 2011 02:15:07 schrieb leledumbo:
 It works when {$LONGSTRINGS ON} or {$H+} directive exists. I think the
 compiler treats functions receiving array of char (or pointer to it) as
 ShortString when none of the directives above exist.

No it does not work then.
I put already the -Sh- additional compiler arg.

For me it seems like a bug, because in the previous version of FPC (2-2-4.3) 
it works. It seems that the compiler now cuts every constant string in the 
sourcecode to 255 characters.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] parent class as a parameter type

2011-11-14 Thread Sven Barth

On 12.11.2011 22:18, ik wrote:

Since 2.6.0, when you write something like this:

procedure foo(AClass : TStrings);
foo(MyStringList); // Will return an error that TStrings is expected ...

I can not use TStringList as the parameter without casting it to TStrings.
But I do not understand why this limitation added. Can you please
explain it to me ?


It works here with 2.6.0 RC1.

Can it be that you used var or out? Cause than this is expected: 
http://wiki.freepascal.org/User_Changes_2.6.0#Passing_derived_classes_to_var-_and_out-parameters


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compilation time

2011-11-14 Thread Graeme Geldenhuys
On 12/11/2011, Florian Klämpfl florian@ wrote:
 Am 12.11.2011 21:51, schrieb Rainer Stratmann:
 Does more cpu cores mean less compile time?

 No.

Doing a 'make' for the FPC project, multiple cores can be used (via
eg: -j 5 command line parameter on a quad core system). But I think
the multi-core is only used when the makefile process starts compiling
the FCL which is independent of other packages in the FCL. But yes, I
believe you were refering to compiling a single project, so then your
answer is correct. ;-)


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: pchar with more than 255 characters

2011-11-14 Thread Graeme Geldenhuys
On 13/11/2011, leledumbo leledumbo_cool@ wrote:
 I think the
 compiler treats functions receiving array of char (or pointer to it) as
 ShortString when none of the directives above exist.

Indeed, FPC defaults to ShortString if {$H+} is not specified. That is
probably the problem. I really don't know why this is still so (maybe
some performance thing inside the compiler itself). I now simply
specify $H+ in the fpc.cfg file, in case I forget to add it to the
header of a unit.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] parent class as a parameter type

2011-11-14 Thread Graeme Geldenhuys
On 12/11/2011, ik idokan@ wrote:

 Since 2.6.0, when you write something like this:

I think it was even before this.

 procedure foo(AClass : TStrings);
 foo(MyStringList); // Will return an error that TStrings is expected ...

 I can not use TStringList as the parameter without casting it to TStrings.
 But I do not understand why this limitation added. Can you please explain
 it to me ?

I ran into the exact same issue this week, and also can't understand
why this is not allowed any more. It *is* allowed in Delphi (at least
D7). Luckily I could change my code to TStringList to work around the
problem.

So yes, if anybody could please explain what was the logic behind this
crippling change?

The other issue I have is passing a property value via a var or const
parameter. I used this a lot in my code too, and it worked for years
without problems. This again, is supported in Delphi too. I have no
idea why this was changed in FPC either. The work around looks damn
stupid too. Declare a local variable and assign the property to it,
then pass the local variable. In the end it has the same endresult,
but just inconveniences to the developer with these unnecessary local
variables.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] parent class as a parameter type

2011-11-14 Thread cobines
Works for me:

program a;

{$mode objfpc}{$H+}

uses
  Classes;

procedure foo(AClass: TStrings);
begin
end;

var
  sl: TStringList;
begin
  foo(sl);
end.


--
cobines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] parent class as a parameter type

2011-11-14 Thread Jonas Maebe

On 12 Nov 2011, at 22:18, ik wrote:

 Since 2.6.0, when you write something like this:
 
 procedure foo(AClass : TStrings);
 foo(MyStringList); // Will return an error that TStrings is expected ...

Are you certain there is no var or out in front of that parameter?

 I can not use TStringList as the parameter without casting it to TStrings.
 But I do not understand why this limitation added. Can you please explain
 it to me ?

In case of a var/out parameters: 
http://wiki.freepascal.org/User_Changes_2.6.0#Passing_derived_classes_to_var-_and_out-parameters

That page is also linked from the announcement mail and the readme.


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] CloseThread needed? still unclear

2011-11-14 Thread noreply
While testing an updated version of nYume (aservia) I found that the
program is leaking thread handles on Ms Windows. The program uses
BeginThread and EndThread calls.

However, when I add CloseThread() right before EndThread(, the program no
longer leaks handles. So, CloseThread may be needed on Ms Win machines. I
don't think (all) the docs state to call closethread. If CloseThread
should be called on Ms windows, then this makes cross platform threading
difficult since windows requires something different than unix.

I don't know if the object oriented TThread uses CloseThread in it's
backend code and don't know if TThread leaks, I was just trying
beginthread and endthread style.

To find handle leaks, I simply use Windows Task Manager to monitor the
processes, with the Handles column visible. I am also trying some other
tools like DrMemory.

First I thought I would post this to the mailing list to ask you what the
proper way to program with threads is. If we must call closethread on MS
Win machines but not unix machines, then something needs to change to make
the threading in the RTL more cross platform (and all the docs would need
to mention things about closethread if it is needed).

The compiler is 2.4.2 and 2.4.4 that i am using.

The documentation is here:
http://www.freepascal.org/docs-html/prog/progse44.html#x217-2310.2

But there is also more documentation elsewhere, such as the RTL docs.

I guess I could look into Delphi to see how they use closethread. in their
backend somewhere.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] [OT] AI programming challenge includes FreePascal

2011-11-14 Thread Reinier Olislagers
Hi all,

In case you didn't know and are interested, there is an online
artificial intelligence competition [1] that lets you program an ant
colony that fights other colonies.

There's a FreePascal starter kit available as well.

You can test your program against others now; your submission needs to
be in on December 18th.

Just thought I'd let people know... might be nice PR if FPC entries did
well...

Regards,
Reinier

[1] http://aichallenge.org/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Makeskel error or error behind keyboard?

2011-11-14 Thread Reinier Olislagers
Hi list,

Trying to start documenting fpXMLXSDExport:
some other directoryc:\development\fpc\bin\i386-win32\makeskel
--disable-private --emit-class-separator --update --package=fcl
--input=C:\development\Fpc\Source\packages\fcl-db\src\export\fpxmlxsdexport.pp
--output=fpxmlxsdexport.xml
MakeSkel - FPDoc skeleton XML description file generator
Version 2.5.1 [2011/11/14]
(c) 2000 - 2003 Areca Systems GmbH / Sebastian Guenther, s...@freepascal.org

Error while documenting: Expected , or : at token = in file
C:\development\Fpc\Source\packages\fcl-db\src\export\fpxmlxsdexport.pp
at line 70 column 24
Done.

Snippet of the code in question:
  { TCustomXMLXSDExporter }
  TCustomXMLXSDExporter = class(TCustomFileExporter)
  const
DefaultDatasetName = 'Table1';  == this is where it bombs
// Name used for the exported table/dataset if no other name can be
found.
  private
FANode: TDOMNode; //Just a placeholder for a node which can be reused

Am I doing something wrong or is makeskel in error?

(FreePascal fixes_2_6, as of today)

One other thing: looking at the FPC reference guide for constants
(Chapter 2.1), I see this declaration:
constant declaration - identifier - = - expression - hintdirectives -;

However, hintdirectives doesn't seem to be explained later on (did a
search on it in the PDF).
Hintdirectives returns in 11 Using functions and procedures: 11.1
procedure declaration, 11.2 Function declaration

Should the documentation be updated or is it once again a problem
between the chair and the computer?

Thanks,
Reinier
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] parent class as a parameter type

2011-11-14 Thread Felipe Monteiro de Carvalho
On Sun, Nov 13, 2011 at 5:56 PM, Graeme Geldenhuys
graemeg.li...@gmail.com wrote:
 Luckily I could change my code to TStringList to work around the
 problem.

One can type-cast to get around the issue, so then method declarations
don't need to be changed:

foo(TStrings(MyStringList));


-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: pchar with more than 255 characters

2011-11-14 Thread Jonas Maebe

On 13 Nov 2011, at 14:02, Rainer Stratmann wrote:

 Am Sunday 13 November 2011 02:15:07 schrieb leledumbo:
 It works when {$LONGSTRINGS ON} or {$H+} directive exists. I think the
 compiler treats functions receiving array of char (or pointer to it) as
 ShortString when none of the directives above exist.
 
 No it does not work then.
 I put already the -Sh- additional compiler arg.

-Sh- Is the same as {$h-} or {$longstrings off}. You need -Sh (provided that 
there's no {$mode fpc/objfpc/tp/macpas} in the source file, since that will 
disable them again).


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] parent class as a parameter type

2011-11-14 Thread Jonas Maebe

On 13 Nov 2011, at 17:56, Graeme Geldenhuys wrote:

 On 12/11/2011, ik idokan@ wrote:
 
 procedure foo(AClass : TStrings);
 foo(MyStringList); // Will return an error that TStrings is expected ...
 
 I can not use TStringList as the parameter without casting it to TStrings.
 But I do not understand why this limitation added. Can you please explain
 it to me ?
 
 I ran into the exact same issue this week, and also can't understand
 why this is not allowed any more. It *is* allowed in Delphi (at least
 D7).

It's not allowed in Delphi in case of a var/out parameter. It's allowed in both 
FPC and Delphi in case of a value/const parameter.

 The other issue I have is passing a property value via a var or const
 parameter. I used this a lot in my code too, and it worked for years
 without problems. This again, is supported in Delphi too.

No, it is not allowed by Delphi (at least not passing a property to a 
var-parameter; passing it to a const parameter is allowed by both FPC and 
Delphi).


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] pchar with more than 255 characters

2011-11-14 Thread Felipe Monteiro de Carvalho
On Sun, Nov 13, 2011 at 1:39 AM, Rainer Stratmann
rainerstratm...@t-online.de wrote:
 procedure getchars( p : pchar );
 var l : longint;
 begin
  l := length( p );
 end;

You cannot do length in a PChar, it has no length information. I think
this code is probably automatically converting the PChar to a Pascal
String and then after that calling Length in the Pascal String, so
your code is not very efficient.

Pass the length of the PChar in an aditional parameter instead. Or
write a routine which will count until the first #0 of the PChar to
see how many characters it has.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal