Re: [fpc-pascal] IRC channel for FreePascal support ?

2023-04-13 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
I'm almost fourteen years on the forum and a few years less on mailing lists 
and I never had a single problem.
I don't attend IRC so I can't say what's wrong there.
OTOH I read Joanna's comments on the forum and they are OK (to the topic; non 
conflict).
 
V.
 
__

Od: "Karl-Michael Schindler via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 13.04.2023 18:49
Předmět: Re: [fpc-pascal] IRC channel for FreePascal support ?



...

All this is completely in line with my past experience with Joanna on #fpc 
during freenode times. I withdrew from the channels completely, because of her 
activities. Therefore, I strongly suggest action regarding her operator status 
of the fpc channel on libera.chat. Alternatively, ask for the removal of the 
“official” status and a corresponding disclaimer or the channel altogether. 
This recent example shows, that her self-centered and dictatorial actions as 
operator harm fpc more than fpc benefits from her activities.

Regards - Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] possible bug in blockwrite

2023-03-05 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
you can use PChar, or string+retype to PChar in blockwrite:
 
 BlockWrite(f1, PChar(s)^, length(s)); 
 
which gives expected result.
V.
__

Od: "Travis Siegel via fpc-pascal" 
Komu: "FPC-Pascal users discussions" 
Datum: 05.03.2023 19:02
Předmět: [fpc-pascal] possible bug in blockwrite



Comments?

I've built in workarounds in my program to solve both of these issues, 
but it'd be nice if I didn't have to do that.



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Dynamic array question

2023-01-12 Thread Vojtěch Čihák via fpc-pascal

Thanks for comprehensive answer. My other code really worked coincidentally.
This code:
 
  SetLength(aArray, 400);
  writeln(PInt64(@aArray[0]-8)^);
 
writes out 399.
 
I'll use more conservative code.
 
V.
__

Od: "Joost van der Sluis via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 12.01.2023 00:22
Předmět: Re: [fpc-pascal] Dynamic array question


Vojtěch Čihák via fpc-pascal schreef op wo 11-01-2023 om 23:38 [+0100]:
> is there a way how to have dynamic array "inside" another dynamic
> array?

Not in the way you want.

You could define an 'array of array', though. Or an array of records
that contain an array.
 
The problem is that you make all kind of assumptions about the memory-
layout of these arrays, which may not always be valid. Code that works
this way might work coincidentally, but may break when switching to
another compiler version or by enabling an optimization. 


So.. you must really, really have a good reason why you should try
this.  And if you do so, don't use dynamic types for tricks like this.
They are not meant to be used as a a way to map directly into a memory
location.

And, in your case, one of the assumptions is wrong. At the start of a
dynamic array it's length is stored. That will destroy your memory-
layout.

And te compiler will try to allocate/deallocate memory for the second
array. One big mess.

You could use a static array for the 'inside' array.

Regards,

Joost.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Dynamic array question

2023-01-11 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
is there a way how to have dynamic array "inside" another dynamic array?
 
program project1;
{$mode objfpc}{$H+}
 
uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes, SysUtils
  { you can add units after this };
 
{$R *.res}
type
  TDynArray = array of Integer;
  PTDynArray = ^TDynArray;
 
var aArray, aNewArray: TDynArray;
    aNewStart: Integer;
begin
  SetLength(aArray, 300);
  writeln('Length of aArray ', length(aArray));
  aNewStart:=100;
  aArray[aNewStart+5]:=42;
  aNewArray:=@aArray[aNewStart];
  aNewArray[5]:=42;
  writeln('Length of aNewArray ', length(aNewArray));
end.      
 
So aNewArray begin at aArray[100] and have length=200 and I could write
NewArray[5]:=42; instead of aArray[aNewStart+5]:=42;
After all, memory is allocated correctly.
Code above gives "Invalid pointer operation" while this code
 
  aNewArray:=PTDynArray(@aArray[aNewStart])^;
 
  aNewArray[5]:=42; 
 
gives "Range check error".
 
Thanks.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Local Type T and generics

2023-01-03 Thread Vojtěch Čihák via fpc-pascal

OK, done: https://gitlab.com/freepascal.org/fpc/source/-/issues/40085
 
Thanks
__

Od: "Sven Barth via fpc-pascal" 
Komu: "FPC-Pascal users discussions" 
Datum: 03.01.2023 22:29
Předmět: Re: [fpc-pascal] Local Type T and generics


Am 31.12.2022 um 14:34 schrieb Vojtěch Čihák via fpc-pascal:

> Is this intended? Or known bug?

It's a bug. Please report with a full example.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Local Type T and generics

2022-12-31 Thread Vojtěch Čihák via fpc-pascal
Hi,
 
I have local type TTempItem, i.e. declared inside method of a generic class.
When I write:
type 
     TTempItem = record
       Item: T;
       Empty: Boolean;
     end;
I got: Identifier not found "T".
 
When I write:
type
     TTempItem = record
       Item: TBaseGList.T;  //name of the class
       Empty: Boolean;
     end;
I got: Generics without  specialization cannot be used as a type for a variable
 
And finally
type TLocalT = T;
     TTempItem = record
       Item: TLocalT;
       Empty: Boolean;
     end;  
^^^ this works.
 
type TLocalT = TBaseGList.T;
     TTempItem = record
       Item: TLocalT;
       Empty: Boolean;
     end;  
^^^ work too.
 
Is this intended? Or known bug?
 
Thanks.
 
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to inline CompareFunc to Sort method in generic abstract class

2022-11-18 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
I specialized my generic abstract class in a different unit with this type:
 
TRec = record
    A: Integer;
    B: Integer;
  end;
 
(A is for sorting, B is for testing of stability, i.e. for MergeSort, TimSort)
 
and compare function, declared with inline; directive:
 
function MyComptFunc(const ARec, BRec: TRec): Integer;
var i, aCnt: Integer;
begin
  aCnt:=CFComplex;
  for i:=0 to aCnt do
    Result:=(BRec.A-ARec.A);
  inc(CFCnt);
  //InterlockedIncrement(CFCnt);
end;              
 
The reason for this complex compare function is that it also measure number of 
comparisons and it can simulate more expensive comparisons (like sorting 
strings).
 
For a while, I added this unit to the second "uses" section (implementation) of 
the other unit, which is impractical, but I had
temporary access to the compare function. I tested again with ShellSort, 
sorting 2'000'000 values takes:
1380ms inlined
1515ms not inlined, ~9% slower
1430ms when compare func. is a parameter ~4% slower
 
I pass variables by value. But you are right, when I shave the function like 
this:
 
function MyComptFunc(const ARec, BRec: TRec): Integer;
begin
  Result:=(BRec.A-ARec.A);
end;
 
the results are:
750ms inlined
950ms not inlined, ~21% slower
835ms when compare func. is a parameter ~10% slower
 
so the gain of inlining is higher for sorting primitive types.
V.__

Od: "Flávio Etrusco via fpc-pascal" 
Komu: "FPC-Pascal users discussions" 
Datum: 18.11.2022 20:45
Předmět: Re: [fpc-pascal] How to inline CompareFunc to Sort method in generic 
abstract class




Em seg., 14 de nov. de 2022 15:26, Vojtěch Čihák via fpc-pascal > escreveu:,What do you mean by "be inlined"? The 
'inline' directive instructs the compiler (or is it the linker? ) to try copying the whole function 
inline, also avoiding the call (stack) setup; you can't do this for this for a general purpose 
method.I'm curious how you got that 6% figure, it seems rather large. Is this comparing the parameter 
vs virtual method approach or comparing a fully inline (no indirect call of any kind) sort function 
to some other option? Are you passing the variables by reference?Best regards,Flávio

--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] How to inline CompareFunc to Sort method in generic abstract class

2022-11-14 Thread Vojtěch Čihák via fpc-pascal
Hi,
 
I wrote a generic abstract class - a list based on dynamic array (i.e. array of 
T;) and this class can be specialized elsewhere with any type (records or 
classes).
Part of the class is sorting. There are more ways how to deliver *compare 
function* to sorting method. I can pass it as a parameter or I can define it 
as: function Compare(A, B: T): Integer; virtual; abstract;. But this way the 
function cannot be inlined.
 
Question: Is there a way how to *inline* compare function to sorting method in 
this general purpose generic abstract class?
 
Thanks.
 
PS: The gain is 6-7%.  
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Program efficiency

2022-11-09 Thread Vojtěch Čihák via fpc-pascal

Sorry, it was copy-paste from github and it broke formatting
 
do {
      v1 = XXH32_round(v1, XXH_get32bits(input)); input += 4;
      v2 = XXH32_round(v2, XXH_get32bits(input)); input += 4;
      v3 = XXH32_round(v3, XXH_get32bits(input)); input += 4;
      v4 = XXH32_round(v4, XXH_get32bits(input)); input += 4;
      } while (input < limit);
 
 repeat
        v1 := cPrime32x1 * RolDWord(v1 + cPrime32x2 * PLongWord(ABuffer)^, 13);
        v2 := cPrime32x1 * RolDWord(v2 + cPrime32x2 * PLongWord(ABuffer+4)^, 
13);
        v3 := cPrime32x1 * RolDWord(v3 + cPrime32x2 * PLongWord(ABuffer+8)^, 
13);
        v4 := cPrime32x1 * RolDWord(v4 + cPrime32x2 * PLongWord(ABuffer+12)^, 
13);
        inc(ABuffer, 16);
until not (ABuffer <= pLimit);       
 
__

Od: "James Richters via fpc-pascal" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 09.11.2022 13:47
Předmět: [fpc-pascal] Program efficiency


I was wondering if breaking up large complicated formulas into smaller
sections that use more variables is less efficient than just the large
formula.

In other words.. is

A:=(B+C/D)-E^F;
G:=H*(I+J);
K:=L+M/N;
O:= A+G-K;

Less efficient than
O:= ((B+C/D)-E^F)+ (H*(I+J))-(L+M/N);

Or does it end up being the same when it's done?

I have a tendency to avoid using variables even though the code would be
infinitely more understandable if it was broken into sections and more
variables were used, but I'm wondering if this is really any more efficient
or if it just seems like it should be... after all storing things in a
variable and reading them out should take some time... but then again the
processor only works on one operation at a time anyway, so the final
assembly code would probably have to store things somewhere and get them
back... so.. is it really faster?

So if I never need the value a second time, is it really better to avoid
variables?

I could  break it up an use comments:
O:= ((B+C/D)-E^F)+   //A
      (H*(I+J))-             //G
      (L+M/N);             //K

This got me thinking, it would be cool if there was some king of utility
that counted clock cycles for you while your program ran..and then I could
just try a sample program both ways and see what the results are...

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Program efficiency

2022-11-09 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
I noticed this too a few years ago when I translated xxHash from C to FPC.
Pushing the code to less lines improved speed so xxHash32 was as fast as in C.
 
do { v1 = XXH32_round(v1, XXH_get32bits(input)); input += 4; v2 = XXH32_round(v2, 
XXH_get32bits(input)); input += 4; v3 = XXH32_round(v3, XXH_get32bits(input)); 
input += 4; v4 = XXH32_round(v4, XXH_get32bits(input)); input += 4; } while (input 
< limit);
 
 
    repeat
        v1 := cPrime32x1 * RolDWord(v1 + cPrime32x2 * PLongWord(ABuffer)^, 13);
        v2 := cPrime32x1 * RolDWord(v2 + cPrime32x2 * PLongWord(ABuffer+4)^, 
13);
        v3 := cPrime32x1 * RolDWord(v3 + cPrime32x2 * PLongWord(ABuffer+8)^, 
13);
        v4 := cPrime32x1 * RolDWord(v4 + cPrime32x2 * PLongWord(ABuffer+12)^, 
13);
        inc(ABuffer, 16);
      until not (ABuffer <= pLimit);       
 
__

Od: "James Richters via fpc-pascal" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 09.11.2022 13:47
Předmět: [fpc-pascal] Program efficiency


I was wondering if breaking up large complicated formulas into smaller
sections that use more variables is less efficient than just the large
formula.

In other words.. is

A:=(B+C/D)-E^F;
G:=H*(I+J);
K:=L+M/N;
O:= A+G-K;

Less efficient than
O:= ((B+C/D)-E^F)+ (H*(I+J))-(L+M/N);


James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem with code aligning (probably)

2022-10-20 Thread Vojtěch Čihák via fpc-pascal

Thanks, although it's not very optimistic.
 
Is there anything else I can try except {$CODEALIGN ...}? For example change 
heap or stack size but I don't know what values should I try since I never 
needed it.
 
BTW, is there chance that these problems will go away with newer hardware, like 
some AM5? New CPUs have at least bigger caches
 
Thanks.
 
__

Od: "Jonas Maebe via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 20.10.2022 08:45
Předmět: Re: [fpc-pascal] Problem with code aligning (probably)


On 20/10/2022 00:24, Vojtěch Čihák via fpc-pascal wrote:


That's not easy, unfortunately: https://www.youtube.com/watch?v=r-TLSBdHe1A 
<https://www.youtube.com/watch?v=r-TLSBdHe1A>


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem with code aligning (probably)

2022-10-19 Thread Vojtěch Čihák via fpc-pascal

Hi again, I moved directives from
{$CODEALIGN JUMP=2} 
to 


-OaJUMP=2
in Project Options but I still did not found solution.
I observed that when code is - after some change - slower, I can solve it by 
changing -OaJUMP=2 to -OaJUMP=1.
And after next change - if it causes slower code - I can solve it reversely: 
-OaJUMP=1 to -OaJUMP=2.
 
Of course, I'd like some persistent solution.
 
V.
 


__

Od: "Vojtěch Čihák via fpc-pascal" 
Komu: "FPC-Pascal users discussions" 
Datum: 19.10.2022 17:39
Předmět: Re: [fpc-pascal] Problem with code aligning (probably)


 
______

Od: "Vojtěch Čihák via fpc-pascal" 

> Komu: "FPC-Pascal users discussions" 
> Datum: 19.10.2022 15:37
> Předmět: [fpc-pascal] Problem with code aligning (probably)
>
Hi,
...
 
Thanks for help.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>


--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem with code aligning (probably)

2022-10-19 Thread Vojtěch Čihák via fpc-pascal

It seems I have some success with following:
 
{$CODEALIGN LOOP=4}
{$CODEALIGN PROC=4}
{$CODEALIGN CONSTMIN=4}
{$CODEALIGN VARMIN=4}
{$CODEALIGN LOCALMIN=4}
{$CODEALIGN JUMP=4}
 
I expected higher numbers on 64-bit platform. Also, I don't know yet which of 
the numbers affects my problem.
 
__

Od: "Vojtěch Čihák via fpc-pascal" 
Komu: "FPC-Pascal users discussions" 
Datum: 19.10.2022 15:37
Předmět: [fpc-pascal] Problem with code aligning (probably)


Hi,
...
 
Thanks for help.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Problem with code aligning (probably)

2022-10-19 Thread Vojtěch Čihák via fpc-pascal
Hi,
 
I wrote a generic class to test sorting algorithms and also benchmarking them. 
I have following problem:
 
When I change even a single line of code anywhere in that unit, even in an 
unrelated method, all ~40 algorithms become a little slower or a little faster. 
I observed it has two levels of speed: 100% and 90%. Just these values, never 
95%, it is not random.
 
I looked around and found: 
https://www.freepascal.org/docs-html/prog/progsu9.html
 
but still I cannot find which items and what values should I set. (I guess it 
should be LOOP, PROC or JUMP?)
 
My program is Lazarus single window with many buttons which specializes generic 
class of that unit.


I'm still on Core2Duo with 64-bit Linux.
 
Lazarus 2.3.0 (rev main-2_3-2118-gb5858164db) FPC 3.3.1 x86_64-linux-qt
 
Thanks for help.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-12 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
my numbers of Lazarus on Linux, Qt (incl. binaries and *.ppu and *.o files)
 
SVN:
lazarus dir: 2.6 GB (4 files, 1300 dirs)
.svn subdir: 1.6 GB (25000 files, 260 dirs)
 
GIT:
lazarus dir: 1 GB (15000 files, 950 dirs)
.git subdir: 150 MB (60 files, 40 dirs)
 
V.
 
__

Od: "Bo Berglund via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 11.08.2021 23:56
Předmět: Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut 
down?


On Wed, 11 Aug 2021 22:22:54 +0200 (CEST), Michael Van Canneyt via fpc-pascal
 wrote:

># Get sources
>git clone https://gitlab.com/freepascal.org/fpc/source.git 
  $FPCVER
># switch to branch/tag
>cd $FPCVER
>git checkout $FPCTAG
>cd ..

How big a size is the git clone going to pull?

By the looks of it I get the impression that the git clone will download every
single tag/branch/commit etc ever done and then the git checkout activates the
actual tagged file set?
If this is correct then the size on disk will be too big.

...

--
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to use XMLCfg?

2021-08-08 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
Laz2_ are UTF8 versions and they works well.
Create(nil); means that instance has no owner.
(I have Lazarus 2.3.0, it is not on line 165 here).
 
You can try demo at ../examples/xmlstreaming/.. It works here.
 
V.
__

Od: "Abuy via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 07.08.2021 08:53
Předmět: [fpc-pascal] How to use XMLCfg?

Tried Laz2_XMLCfg unit. Result is «Project createxml raised exception 
class 'External SIGSEGV'. In file 
'C:\lazarus\components\lazutils\laz2_xmlcfg.pas' at line 165: 
Create(nil);». I guess it is all because author of this unit for some 
reson calling unexisting constructor from constructor TXMLConfig.Create. 
Does this unit & older XMLCfg actually works?

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC 3.2.2 released

2021-05-27 Thread Vojtěch Čihák via fpc-pascal

Hello and thanks.
 
I downloaded 3.2.2 (tar), I installed it successfully.
I used it to compile the latest 3.3.1 trunk, again successfully.
And I used this 3.3.1 to build the Lazarus 2.1.0 trunk (65138). Also 
successfully.
 
Everything seems be OK.

Vojtěch a.k.a. Blaazen
__

Od: "Marco van de Voort via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 21.05.2021 09:35
Předmět: [fpc-pascal] FPC 3.2.2 released


Hello,

Finally, the Free Pascal 3.2.2 release is available from our servers and 
from sourceforge.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Formatting Question

2021-04-03 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
I tried this (add StrUtils to uses):
 
procedure TForm1.Button1Click(Sender: TObject);
var i, l: Integer;
    aV: Double;
    aF: TFormatSettings;
begin
  aF.DecimalSeparator:='.';
  aF.ThousandSeparator:=' ';
  for i:=-2 to 10 do
    begin
      aV:=pi*power(10, i);
      l:=length(intToStr(trunc(aV)));
      l:=15-l-((l-1) div 3);
      writeln(AddChar(' ', '', l)+FormatFloat('#,##0.##', aV, aF));
    end;
end;
 
Tweak it to your needs, it aligns well to console (up to 999 999 999 999.x) 
here.
 
V.
__

Od: "James Richters via fpc-pascal" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 03.04.2021 17:53
Předmět: [fpc-pascal] Formatting Question

I'm looking for a way to format numerical data in a string so that everything ends up aligned by the decimal point. 
I've been trying to use the Format() function but I don't see how to do what I am looking for... 
then again I don't really understand the format() function, and most of the examples show exponents, which I do not want.


My input variables are all Doubles and I want the result to be padded with spaces before the decimal point if needed and 
trailing zeros to be replaced with spaces so that it always is the same total width and the decimal point is always in the same position.

The string will later be either output to the console or saved into a file.  It 
will only ever be viewed with a fixed width font.

Does anyone have any idea if this can be done with any function included with 
FPC or am I going to write my own function to do this?

James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Access Violation on second compile with FPC Text IDE

2020-11-12 Thread Vojtěch Čihák via fpc-pascal

Hello,
 
look at this bugreport. I reported it as a Lazarus issue but now it looks like 
FPC trunk issue.
 
https://bugs.freepascal.org/view.php?id=37856
 
Vojtech aka Blaazen
__

Od: "C Western via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 12.11.2020 09:30
Předmět: Re: [fpc-pascal] Access Violation on second compile with FPC Text IDE


On 11/11/2020 22:26, James Richters via fpc-pascal wrote:
> I'm suddenly getting an access violation when compiling after a file changed 
with the FPC text IDE:
>
> Recompiling because of I:\Programming\Gcode\Mill\pastep.pas
> sysinit.pp(0) Error: Compilation raised exception internally
> Error: Compiler exited
> Error: Access violation
>
> I haven't changed anything as far as FPC goes, and I'm using the same 
procedure I always have.. I make my edits in notepad++ then go to the text IDE and 
compile it.. it detects which files changed and re-compiles those.. it normally 
works fine, but now I am always getting this.  I restart the text IDE and compile 
it and run it and it's fine.. no problems, I make even a minor change, and try to 
re-compile it and bam I get this access violation error.  Does anyone know what 
this error actually means or how to track it down?
>
Is this with a recent trunk? I have started seeing this recently; an 
interface change in one unit causes a crash when compiling another unit. 
The workaround is to force recompilation of everything, which I do by 
deleting all the compiled files for the program. It is tricky to report 
as a bug, as it is intermittent, and I have only seen it on a large program.


Colin

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPGMapObject duplicate errors

2020-10-01 Thread Vojtěch Čihák via fpc-pascal

I looked to code, it gives error only when map is Sorted=True.
 
function TFPSMap.Add(AKey: Pointer): Integer;
begin
  if Sorted then
  begin
    if Find(AKey, Result) then
      case Duplicates of
        dupIgnore: exit;
        dupError: Error(SDuplicateItem, 0)
      end;
  end else
    Result := Count;
  CopyKey(AKey, inherited Insert(Result));
end;  
 
V.
__

Od: "Ryan Joseph via fpc-pascal" 
Komu: "FPC-Pascal users discussions" 
Datum: 02.10.2020 02:24
Předmět: [fpc-pascal] TFPGMapObject duplicate errors


I expected to get an assertion when I added the duplicate key "foo". What am I 
doing wrong?

type
 TSomeMap = specialize TFPGMapObject;
var
 map: TSomeMap;
begin
 map := TSomeMap.Create(true);
 map.Duplicates := dupError;
 map.Add('foo', TObject.Create);
 map.Add('foo', TObject.Create);

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPObjectlist example

2020-09-08 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
some crippled formatting, so again:
 
However, in your case (records) I would rather use TFPGList from FGL unit:
 
1) add {$modeswitch ADVANCEDRECORDS}
 
2) add FGL to uses
3) define class operator =
test = record    Port :String;    Size :Byte;    Status :Word;    class 
operator = (A,B: test): Boolean;  End; 4) implement itclass operator test.=(A, 
B: test): Boolean;begin  Result:=(A.Port=B.Port) and (A.Size=B.Size);  // and 
...end;   5) define specialized list:
 
  TMyL = specialize TFPGList;
 
6) create it
 
  MyList: TMyL;
 
  ...
 
  MyList:=TMyL.Create;
 
Now you can work with it comfortably
 
MyList[1].Port:='abc';
 
V.
__

Od: "Vojtěch Čihák via fpc-pascal" 
Komu: ja...@productionautomation.net, "FPC-Pascal users discussions" 

Datum: 08.09.2020 16:21
Předmět: Re: [fpc-pascal] TFPObjectlist example


__
> Od: "James Richters via fpc-pascal" 
> Komu: "'FPC-Pascal users discussions'" 
> Datum: 07.09.2020 01:08
> Předmět: [fpc-pascal] TFPObjectlist example
>

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>


--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPObjectlist example

2020-09-08 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
I used TFPObjectList only once, for visual component TECAccordion 
(https://wiki.lazarus.freepascal.org/Eye-Candy_Controls#TECAccordion). Each 
item of list is derived from TWinControl so it is possible to use it even for 
visual components (like TCollection).
 
However, in your case (records) I would rather use TFPGList from FGL unit:
 
1) add {$modeswitch ADVANCEDRECORDS}
2) add FGL to uses3) define class operator =test = record    Port :String;    
Size :Byte;    Status :Word;    class operator = (A,B: test): Boolean;  End; 4) 
implement itclass operator test.=(A, B: test): Boolean;begin  
Result:=(A.Port=B.Port) and (A.Size=B.Size);  // and ...end;   5) define 
specialized list:
  TMyL = specialize TFPGList;
6) create it
  MyList: TMyL;
  ...
  MyList:=TMyL.Create;
 
Now you can work with it comfortably
MyList[1].Port:='abc';
 
V.
__

Od: "James Richters via fpc-pascal" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 07.09.2020 01:08
Předmět: [fpc-pascal] TFPObjectlist example



James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] LongInt and LongWord types

2020-07-09 Thread Vojtěch Čihák via fpc-pascal

I suspect Embarcadero that they often intently design Delphi to be not 
compatible with FPC.
V.
__

Od: "Sven Barth via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 09.07.2020 07:30
Předmět: Re: [fpc-pascal] LongInt and LongWord types


Am 08.07.2020 um 23:00 schrieb Marcelo Rocha via fpc-pascal:Delphi's LongInt and 
LongWord are 32 bits on Windows, but 64 bits on supported Posix 
platforms(http://docwiki.embarcadero.com/RADStudio/Rio/en/Simple_Types_(Delphi) 
), 
following the conventions from LP64/LLP64. FreePascal declares with the same size for 
all platforms. What's the best way to do portable code: using types clong and culong?
Best declare your own aliases with the help of some ifdefs (clong/culong don't 
exist in Delphi, so you'd have to declare aliases anyway).

FreePascal could emit a warning when compiling a code with Longint/Longword variables, targeting a Posix platform, with {$mode delphi}? 
LongInt and LongWord are the *base* types used by FPC. So *everything* is using them, because Integer and Cardinal are merely aliases. Not to mention that FPC has provided 64-bit support first on Posix platforms way back and for that is was decided to keep the size of LongInt and LongWord the same on all platforms for consistency. This will not be changed and there won't be a warning for that.

What there is, is a remark in the documention (in 
https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1 
 ): 
"Remark In newer Delphi versions, the longint type is platform and CPU dependent. This is 
not so in FPC, where longint is 32-bit on all platforms."

Regards,
Sven


--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPGList and objects

2020-05-28 Thread Vojtěch Čihák via fpc-pascal

There is TFPGObjectList for objects.
 
BTW, is FGL a good choice for generics? Some time ago Marco wrote here that FGL 
is moreless a technology demonstrator and Generics.Collection or other 
libraries should be used instead.
 
Thanks for reply
 
V.
 
__

Od: "Ryan Joseph via fpc-pascal" 
Komu: "FPC-Pascal users discussions" 
Datum: 28.05.2020 09:30
Předmět: [fpc-pascal] TFPGList and objects


Using objects in TFPGList is currently not possible because class operators are 
not supported in objects. I tried using global scope operators but they don't 
seem to work.

/usr/local/lib/fpc/3.3.1/units/x86_64-darwin/rtl/fgl.ppu:fgl.pp:988:50: error: Operator is not 
overloaded: "TInvocation" = "TInvocation"

I wanted it for other reasons but we can consider the patch now to add class 
operators to objects?

https://bugs.freepascal.org/view.php?id=36350 


Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] "Hello world" syscalls

2020-01-06 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
I found this article: https://drewdevault.com/2020/01/04/Slow.html
but FPC is missing, so I wrote simple:
 
program Project1;
begin
  writeln('Hello world!');
end. 
 
$ fpc -O3 -XX Project1.pas
 
$ strace -C ./Project1
 
% time     seconds  usecs/call     calls    errors syscall
-- --- --- - - 
 30.83    0.37          37         1           readlink
 25.83    0.31           8         4           ioctl
 18.33    0.22          22         1           write
 17.50    0.21           5         4           rt_sigaction
  4.17    0.05           5         1           getrlimit
  3.33    0.04           4         1           execve
-- --- --- - - 
100.00    0.000120                    12           total
 
It results in 30kB binary, 12 syscalls total, 6 unique. IMO appropriate.
Has the fact that strings are managed types some relevance here?
 
Thanks, Vojtěch.


(FPC 3.0.4)

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák

Yes, I see now, it was my mistake.
 
Thanks.
__

Od: "Mattias Gaertner via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 11.12.2018 22:35
Předmět: Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast


On Tue, 11 Dec 2018 22:19:11 +0100
Vojtěch Čihák  wrote:

because MyClass is not TMyDescClass

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák

Sorry for noise, this was wrong code and even more it has nothing to do with 
generics.
I can solve it with class helper.
 
V.
 
__

Od: "Vojtěch Čihák" 
Komu: "FPC-Pascal users discussions" 
Datum: 11.12.2018 22:19
Předmět: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast


Hi,
 
why this code gives EInvalidCast at runtime (but compiles well):w
 
program Project1;
{$mode objfpc}{$H+}
 
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fgl
  { you can add units after this };
 
{$R *.res}
type
  TMyClass = class
    procedure Output1;
  end;
 
  TMyList = class (specialize TFPGObjectList)
 
  end;
 
  TMyDescClass = class(TMyClass)
    procedure Output2;
  end;
 
var MyList: TMyList;
    MyClass: TMyClass;
 
procedure TMyClass.Output1;
begin
  WriteLn('Output1');
end;
 
procedure TMyDescClass.Output2;
begin
  WriteLn('Output2');
end;
 
begin
  MyList:=TMyList.Create(True);
  MyClass:=TMyClass.Create;
  MyList.Add(MyClass);
  MyList[0].Output1;
  TMyDescClass(MyList[0]);  // EInvalidCast
  MyList.Free;
end.
 
Thanks for help,
 
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák

I forgot: FreePascal 3.3.1 r.40507
 
V.
__

Od: "Vojtěch Čihák" 
Komu: "FPC-Pascal users discussions" 
Datum: 11.12.2018 22:19
Předmět: [fpc-pascal] Generic (TFPGObjectList) EInvalidCast


Hi,
 
why this code gives EInvalidCast at runtime (but compiles well):w
 
program Project1;
{$mode objfpc}{$H+}
 
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fgl
  { you can add units after this };
 
{$R *.res}
type
  TMyClass = class
    procedure Output1;
  end;
 
  TMyList = class (specialize TFPGObjectList)
 
  end;
 
  TMyDescClass = class(TMyClass)
    procedure Output2;
  end;
 
var MyList: TMyList;
    MyClass: TMyClass;
 
procedure TMyClass.Output1;
begin
  WriteLn('Output1');
end;
 
procedure TMyDescClass.Output2;
begin
  WriteLn('Output2');
end;
 
begin
  MyList:=TMyList.Create(True);
  MyClass:=TMyClass.Create;
  MyList.Add(MyClass);
  MyList[0].Output1;
  TMyDescClass(MyList[0]);  // EInvalidCast
  MyList.Free;
end.
 
Thanks for help,
 
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Generic (TFPGObjectList) EInvalidCast

2018-12-11 Thread Vojtěch Čihák
Hi,
 
why this code gives EInvalidCast at runtime (but compiles well):w
 
program Project1;
{$mode objfpc}{$H+}
 
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fgl
  { you can add units after this };
 
{$R *.res}
type
  TMyClass = class
    procedure Output1;
  end;
 
  TMyList = class (specialize TFPGObjectList)
 
  end;
 
  TMyDescClass = class(TMyClass)
    procedure Output2;
  end;
 
var MyList: TMyList;
    MyClass: TMyClass;
 
procedure TMyClass.Output1;
begin
  WriteLn('Output1');
end;
 
procedure TMyDescClass.Output2;
begin
  WriteLn('Output2');
end;
 
begin
  MyList:=TMyList.Create(True);
  MyClass:=TMyClass.Create;
  MyList.Add(MyClass);
  MyList[0].Output1;
  TMyDescClass(MyList[0]);  // EInvalidCast
  MyList.Free;
end.
 
Thanks for help,
 
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Uniform initialization?

2018-11-13 Thread Vojtěch Čihák

IMO 100% Delphi compatibility was important some 10 years back when Kylix was 
discontinued and peope wanted to port their old Delphi projects to Linux. From 
that time boh FPC and Lazarus are mature enough and everyone who started a new 
project after - let's say - 2008 had to do the decision: Delphi or FPC+Laz.
 
V.
__

Od: "Martin Wynne" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 13.11.2018 11:11
Předmět: Re: [fpc-pascal] Uniform initialization?


Delphi mode is very useful.

It means old code from earlier versions of Delphi (in my case Delphi5) 
can be open-sourced and made available via Lazarus to anyone interested, 
without their needing to get an expensive copy of the latest Delphi.


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

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

Re: [fpc-pascal] Uniform initialization?

2018-11-11 Thread Vojtěch Čihák

Very good.
 
V.
__

Od: "Sven Barth via fpc-pascal" 
Komu: fpc-pascal@lists.freepascal.org
Datum: 11.11.2018 18:22
Předmět: Re: [fpc-pascal] Uniform initialization?


Am 11.11.2018 um 16:03 schrieb tobiasgie...@gmail.com:
> Hello,
>
> Delphi 10.3 is going to support inline variable declarations like this:
> begin
>    var i : Integer := 22;
>    WriteLn(i);
>    end;
>
> I would assume it can also be used with records. For details, please see
> http://blog.marcocantu.com/blog/2018-october-inline-variables-delphi.html 

>
> So maybe that's the route to go.
We've already decided internally that we are *not* going to support this.

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

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

[fpc-pascal] SetLength warnings - request

2018-09-06 Thread Vojtěch Čihák

Hello,
 
even if there's closed issue https://bugs.freepascal.org/view.php?id=34169 I 
would like to ask if it can be reconsidered.
 
The subject is that SetLength now gives warning: Variable "dynamic array" of a 
managed type does not seem to be initialized
in 3.3.1 and 3.1.1 while it doesn't give any warning in stable 3.0.4
 
As a solution is recommended do declaration: var arr: array of widechar = ();
But it means that initialization is in fact done twice. See assembler of 
following code:
 
procedure TForm1.Button1Click(Sender: TObject);
var DA: array of widechar = ();
begin
  SetLength(DA, 10);
  writeln(DA[0]);
end; 
 
unit1.pas:30                              var DA: array of widechar = ();
004696C9 488d1538536600           lea    0x665338(%rip),%rdx        # 
0xacea08 
004696D0 488b3529536600           mov    0x665329(%rip),%rsi        # 
0xacea00 
004696D7 4889e7                   mov    %rsp,%rdi
004696DA e8d199fcff               callq  0x4330b0 
unit1.pas:32                              SetLength(DA, 10);
004696DF 48c74424680a00       movq   $0xa,0x68(%rsp)
004696E8 488d3519536600           lea    0x665319(%rip),%rsi        # 
0xacea08 
004696EF 488d4c2468               lea    0x68(%rsp),%rcx
004696F4 4889e7                   mov    %rsp,%rdi
004696F7 ba0100               mov    $0x1,%edx
004696FC e8df99fcff               callq  0x4330e0 

unit1.pas:33                              writeln(DA[0]);
To avoid warning we now need four extra instructions incl. call to fpc_array_assign, which is 
obviously redundant.As an explanation is written: Setlength uses a var parameter. This is no 
different from other cases of var parameter usage.I disaggre here, because SetLength is not an 
usual procedure, it is fundamental part of compiler. Therefore it deserves some exception.That's 
why I ask for reconsidering and make it behave like in 3.0.4 or change declaration from 
"var" to "out" as it is done in getmem().Thanks, Vojtěch. 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] SetLength warnings - request

2018-09-06 Thread Vojtěch Čihák

Hello,
 
even if there's closed issue https://bugs.freepascal.org/view.php?id=34169 I 
would like to ask if it can be reconsidered.
 
The subject is that SetLength now gives warning: Variable "dynamic array" of a 
managed type does not seem to be initialized
in 3.3.1 and 3.1.1 while it doesn't give any warning in stable 3.0.4
 
As a solution is recommended do declaration: var arr: array of widechar = ();
But it means that initialization is in fact done twice. See assembler of 
following code:
 
procedure TForm1.Button1Click(Sender: TObject);
var DA: array of widechar = ();
begin
  SetLength(DA, 10);
  writeln(DA[0]);
end; 
 
unit1.pas:30                              var DA: array of widechar = ();
004696C9 488d1538536600           lea    0x665338(%rip),%rdx        # 
0xacea08 
004696D0 488b3529536600           mov    0x665329(%rip),%rsi        # 
0xacea00 
004696D7 4889e7                   mov    %rsp,%rdi
004696DA e8d199fcff               callq  0x4330b0 
unit1.pas:32                              SetLength(DA, 10);
004696DF 48c74424680a00       movq   $0xa,0x68(%rsp)
004696E8 488d3519536600           lea    0x665319(%rip),%rsi        # 
0xacea08 
004696EF 488d4c2468               lea    0x68(%rsp),%rcx
004696F4 4889e7                   mov    %rsp,%rdi
004696F7 ba0100               mov    $0x1,%edx
004696FC e8df99fcff               callq  0x4330e0 

unit1.pas:33                              writeln(DA[0]);
To avoid warning we now need four extra instructions incl. call to fpc_array_assign, which is obviously 
redundant.As an explanation is written: "Setlength uses a var parameter. This is no different from other 
cases of var parameter usage."I disaggre here, because SetLength is not an usual procedure, it is 
fundamental part of compiler. Therefore it deserves some exception.That's why I ask for reconsidering and 
make it behave like in 3.0.4 or change declaration from "var" to "out" as it is done in 
getmem().Thanks, Vojtěch. 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Will moving from due core CPU to 6 Core CPU of the same clock speed improve the speed of FPC compiling?

2018-08-06 Thread Vojtěch Čihák

And the gain will be lost after installing Spectre patches, where is measured 
performance loss is 1~3%.
 
V.
__

Od: Martin 
Komu: fpc-pascal@lists.freepascal.org
Datum: 06.08.2018 14:38
Předmět: Re: [fpc-pascal] Will moving from due core CPU to 6 Core CPU of the


On 06/08/2018 11:27, Dennis wrote:
> I have been using Intel i3 Dual Core CPU @3.4 GHz for a few years.
> If I upgrade my computer and CPU to Intel Core i5 6-core @3.6GHz,
> will the speed of FPC compilation improve noticeably?
>
> Since FPC seems to be single threaded, I wonder whether 0.2GHz 
> increase in clock speed will make any noticeable improvement in speed.

Assuming you only change the CPU, and nothing else...

Despite that do the math. It's approx 5% diff. So on 60 seconds compile 
time you could in theory save a bit over 3 seconds. (But you will 
probably get less)

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

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

Re: [fpc-pascal] Generics - extending TFPGObjectList

2018-07-26 Thread Vojtěch Čihák

Thanks for reply.
 
Ad 2) I opened issue: https://bugs.freepascal.org/view.php?id=34037
 
Ad 1) Are there any plans for improvement of generic inheritance? Related to my 
example, instead of
 
    generic TFPGObjectListEx = class (specialize TFPGObjectList)
 
I would prefer simplier and more straightforward
 
    generic TFPGObjectListEx = class (TFPGObjectList)
 
which will give programmers possibility to extend classes from FGL without any 
further constraints.
 
What if I fill feature request? :-)
 
Vojtěch
 
__

Od: Sven Barth via fpc-pascal 
Komu: fpc-pascal@lists.freepascal.org
Datum: 26.07.2018 07:04
Předmět: Re: [fpc-pascal] Generics - extending TFPGObjectList


Am 26.07.2018 um 02:31 schrieb Vojtěch Čihák:Hello,
 
I needed to extend TFPGObjectList and I found two wierd things (FPC 3.1.1 
r39507):
 
program project1;
{$mode objfpc}{$H+}
 
uses
  Classes, FGL;
 
type
  TBaseClass = class (TObject)
  end;
 
  TIDClass = class (TBaseClass)
    ID: Integer;
  end;
 
  TNameIDClass = class (TIDClass)
    Name: string;
  end;
 
  generic TFPGObjectListEx = class (specialize 
TFPGObjectList) //1 A
    function GetItemByID(AID: Integer): T;
  end;
 
  TNameIDList = class (specialize TFPGObjectListEx)
 
  end;
 
{$R *.res}
 
function TFPGObjectListEx.GetItemByID(AID: Integer): T;
begin
  {...}
  Result:=nil; //2
end;
 
var NameIDList: TNameIDList;
    NameID: TNameIDClass;
begin
  NameID:=NameIDList.Items[0]; //1 B
end.
 
The demo does not compile because of two errors:
1) project1.lpr(38,21) Error: Incompatible types: got "TBaseClass" expected 
"TNameIDClass" at comment //1 B
It is caused by declaration at //1 A. Class TFPGObjectListEx can be really 
generic only if it is declared like this:
   generic TFPGObjectListEx = class (specialize TFPGObjectList) //1 
A, otherwise you must retype TNameIDClass(Items[0]) and it is against the philosophy of generics. 
Isn't it meaningless? Why there must be specialize to  when in fact it is no 
specialization at all.

You are not overriding the Items property, thus it will still be the Items property 
of TFPGObjectList and thus the compiler will rightfully complain at 
location 1 B. Using generics does not absolve you from usual inheritance problems.

 
2) project1.lpr(32,11) Error: Incompatible types: got "Pointer" expected 
"$gendef4" at comment //2
The line must be changed to
  Result:=T(nil);
which seems bizarre to me, I've never seen retyping "nil". Even more, both TFPGObjectList and 
TFPGObjectListEx are constrained to TObject and to TIDClass so there is safety, TFPGObjectListEx can be only 
specialized with types that have "nil" ( can never be , for example).
Well, no one said that the generics are completely bug free... Especially in 
special situations that involve either Nil or type constraints (or in this case 
both). Please provide a simple example and open a bug report.

Regards,
Sven


--

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

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

[fpc-pascal] Generics - extending TFPGObjectList

2018-07-25 Thread Vojtěch Čihák

Hello,
 
I needed to extend TFPGObjectList and I found two wierd things (FPC 3.1.1 
r39507):
 
program project1;
{$mode objfpc}{$H+}
 
uses
  Classes, FGL;
 
type
  TBaseClass = class (TObject)
  end;
 
  TIDClass = class (TBaseClass)
    ID: Integer;
  end;
 
  TNameIDClass = class (TIDClass)
    Name: string;
  end;
 
  generic TFPGObjectListEx = class (specialize 
TFPGObjectList) //1 A
    function GetItemByID(AID: Integer): T;
  end;
 
  TNameIDList = class (specialize TFPGObjectListEx)
 
  end;
 
{$R *.res}
 
function TFPGObjectListEx.GetItemByID(AID: Integer): T;
begin
  {...}
  Result:=nil; //2
end;
 
var NameIDList: TNameIDList;
    NameID: TNameIDClass;
begin
  NameID:=NameIDList.Items[0]; //1 B
end.
 
The demo does not compile because of two errors:
1) project1.lpr(38,21) Error: Incompatible types: got "TBaseClass" expected 
"TNameIDClass" at comment //1 B
It is caused by declaration at //1 A. Class TFPGObjectListEx can be really 
generic only if it is declared like this:
   generic TFPGObjectListEx = class (specialize TFPGObjectList) //1 
A, otherwise you must retype TNameIDClass(Items[0]) and it is against the philosophy of generics. 
Isn't it meaningless? Why there must be specialize to  when in fact it is no 
specialization at all.
 
2) project1.lpr(32,11) Error: Incompatible types: got "Pointer" expected 
"$gendef4" at comment //2
The line must be changed to
  Result:=T(nil);
which seems bizarre to me, I've never seen retyping "nil". Even more, both TFPGObjectList and 
TFPGObjectListEx are constrained to TObject and to TIDClass so there is safety, TFPGObjectListEx can be only 
specialized with types that have "nil" ( can never be , for example).
 
Thanks,
 
Vojtěch.
 
PS: The demo crashes.

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

Re: [fpc-pascal] Operator overload bug

2018-07-22 Thread Vojtěch Čihák

Hello,
 
you can define type:
 
TIntArray = array of Integer;
 
operator + (left: TMyClass; right: TIntArray): TMyClass; overload;
 
and with retyping it works:
 
c := c + TIntArray([1, 2, 3]);
 
V.
 
 
__

Od: Ben Grasset 
Komu: FPC-Pascal users discussions 
Datum: 23.07.2018 02:16
Předmět: Re: [fpc-pascal] Operator overload bug


I'd say it's a bug in the sense that the compiler assumes something starting with "[" and 
ending with "]" can only possibly be a set in that context.
On Sun, Jul 22, 2018 at 12:10 PM, Ryan Joseph > wrote:
I mentioned this as an aside a while ago but I don’t remember getting a response so I’d like to formally reintroduce the issue. 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


--

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

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

Re: [fpc-pascal] Syntax changes suggestions

2018-07-17 Thread Vojtěch Čihák

Maybe it should be extension of Code Explorer.
 
I did a quick calculation, I have 1680x1050 laptop display and I can see 40 
lines of code in Source Editor, i.e. 39+1 method name for long methods.
If the var block has ~8 lines, then it would remain 31 lines for code, it is 
still accepatable. And I guess programmers have usually bigger displays.
 
V.
 
__

Od: Michael Van Canneyt 
Komu: FPC-Pascal users discussions 
Datum: 17.07.2018 15:34
Předmět: Re: [fpc-pascal] Syntax changes suggestions




On Tue, 17 Jul 2018, Vojtěch Čihák wrote:

> 
If such a thing is implemented, then why not make it as the 'local variables' debug 
dialog, a separate floating window, maybe stay-on-top  ?


If you put it at the top of the source editor, it risks to take a lot of space 
out
of the source editor window, which kind of defeats the purpose, I suppose.

Michael.

--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Syntax changes suggestions

2018-07-17 Thread Vojtěch Čihák

Hi,
 
Lazarus has option "Show Class/Proc Hint" which displays method name (with 
light-green background) as the top line in source editor, only if the method's body is 
longer than number of lines in source editor.
Maybe new option "Show Proc var block" for permanent displaying var block in 
long methods would be enough? Jumps between code and declaration would not be needed.
 
V.
__

Od: Michael Van Canneyt 
Komu: FPC-Pascal users discussions 
Datum: 17.07.2018 12:30
Předmět: Re: [fpc-pascal] Syntax changes suggestions



Exactly: I do scope them. I make small routines.

Reducing scope to 5 lines in a routine of 20 lines is a waste of time.

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

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

Re: [fpc-pascal] Loss of precision when using math.Max()

2018-07-03 Thread Vojtěch Čihák

Hi,
 
I agree with the original topic that overload function Math.Max(Double, Double) 
shoud be chosen instead of Math.Max(Single, Single) when one of parameters is 
Integer.
 
But your criticism make no sense to me. You can as well point that this code:
 
var a, b: Byte;
begin
  a:=5;
  b:=a div 2;
  writeln(b);  // result: 2
end;
 
will not give any warning even if correct result is 2.5.
It is simply absurd because it is not about shooting your own foot. Compiler is 
not a crystal ball, it does what you tell him.
If you need floating point, use floating point types and floating point 
division (my example) and if you need signed results, use signed types (your 
example).
 
Vojtěch
__

Od: Wolf 
Komu: fpc-pascal@lists.freepascal.org
Datum: 03.07.2018 14:33
Předmět: Re: [fpc-pascal] Loss of precision when using math.Max()


On 03/07/2018 11:26, Jim Lee wrote:
 

On 07/02/18 15:13, Wolf wrote:Not so long ago, Florian was proudly bragging about "Pascal 
does not allow you to shoot yourself in the foot 
"
What about this little program:
program Project1;

var a,b: byte;
begin
  a:=1;
  b:=a*(-1);
  writeln(b);    // result: 255
end.
    
The result is obviously correct, given how the variables are declared. But there are no compiler warnings / errors that the assignment b:=a*(-1) is fishy, to put it mildly. And if you are serious about strong typing, it ought to be illegal, with a suitable complaint from the compiler.

Who is shooting whom in the foot?
Wolf


Should the compiler balk at this as well?

program Project1;

var a,b,c: byte;
begin
  a:=5;
  b:=6;
  c:=a-b;
  writeln(c);    // result: 255
end.

Without the implicit conversion of signed/unsigned values, the utility of the 
language is greatly diminished.

-Jim



___fpc-pascal maillist  -  
fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
 


--

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

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

Re: [fpc-pascal] TFPGObjectList error

2018-06-30 Thread Vojtěch Čihák

Hi,
 
this seems to be misleading error message. TFPGObjectList works well for 
objects (classes). When I tried to push record to it, I got the same error 
message. TVec3 is not class, right?
 
Vojtěch
__

Od: Ryan Joseph 
Komu: FPC-Pascal users discussions 
Datum: 01.07.2018 01:55
Předmět: [fpc-pascal] TFPGObjectList error


I’m trying to use TFPGObjectList but I get an error. Is the unit busted? If so 
is there another generic list class in the RTL?

type
TVec3List = specialize TFPGObjectList;
var
list: TVec3List;
begin
list := TVec3List.Create;
list.Add(V3(1,1,1));
list.Free;


/usr/local/lib/fpc/3.1.1/units/x86_64-darwin/rtl/fgl.ppu:fgl.pp:992: error: 14: 
identifier idents no member "Free"
Regards,
Ryan Joseph

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

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

Re: [fpc-pascal] Currency and Int64 casting

2018-05-18 Thread Vojtěch Čihák

Hi,
 
I have
unit1.pas:36                              i:=Int64(c);
0046EEE0 488b45e8                 mov    -0x18(%rbp),%rax
0046EEE4 488945e0                 mov    %rax,-0x20(%rbp)
unit1.pas:38                              writeln(i);
at Level0 andunit1.pas:36                              
i:=Int64(c);0046EECD 4c8b2424                 mov    
(%rsp),%r12unit1.pas:38                              writeln(i);at Level3.I 
just noticed that you wrote you are expecting 1000. You should expect 1 
since currency has four decimals.V.  
__

Od: LacaK 
Komu: fpc-pascal@lists.freepascal.org
Datum: 18.05.2018 07:54
Předmět: Re: [fpc-pascal] Currency and Int64 casting



 
Linux 64-bit Lazarus 1.9.0 r57948M FPC 3.1.1 x86_64-linux-qt gives
 
 1.00E+00 1
What is dissassembly for:
  i:=Int64(c);?

I have for Win32:
test_curr_int64.lpr:19    i1 := Int64(c);
0040158D a100c04200   mov    0x42c000,%eax
00401592 a310c04200   mov    %eax,0x42c010
00401597 a104c04200   mov    0x42c004,%eax
0040159C a314c04200   mov    %eax,0x42c014

and for Win64:
test_curr_int64.lpr:19    i1 := Int64(c);
000115BD 488b0d3caa0300   mov    0x3aa3c(%rip),%rcx    # 
0x10003c000
000115C4 48b84b598638d6c56d34 movabs $0x346dc5d63886594b,%rax
000115CE 48f7e9   imul   %rcx
000115D1 48c1fa0b sar    $0xb,%rdx
000115D5 48c1e93f shr    $0x3f,%rcx
000115D9 4801ca   add    %rcx,%rdx
000115DC 4889152daa0300   mov    %rdx,0x3aa2d(%rip)    # 
0x10003c010


L.
__
> Od: LacaK  
> Komu: FPC-Pascal users discussions  

> Datum: 17.05.2018 13:33
> Předmět: [fpc-pascal] Currency and Int64 casting
>
Hi,

consider following program:

var
  c: currency;

begin
  c := 1;
  writeln(c,' ',Int64(c));
  readln;
end.

FPC 3.0.4
On Win32/x86 I get: 1, 1000  (what I am expecting)
On Win64/x86_64 I get: 1, 1

Is is as expected ?

Is there safe way for both platforms how to get 1000 (beside that I can 
use: i: int64 absolute c;)


Thanks

-Laco.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal  


___fpc-pascal maillist  -  
fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
 


--

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

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

Re: [fpc-pascal] Currency and Int64 casting

2018-05-17 Thread Vojtěch Čihák

Hi,
 
Linux 64-bit Lazarus 1.9.0 r57948M FPC 3.1.1 x86_64-linux-qt gives
 
 1.00E+00 1
V.__

Od: LacaK 
Komu: FPC-Pascal users discussions 
Datum: 17.05.2018 13:33
Předmět: [fpc-pascal] Currency and Int64 casting


Hi,

consider following program:

var
  c: currency;

begin
  c := 1;
  writeln(c,' ',Int64(c));
  readln;
end.

FPC 3.0.4
On Win32/x86 I get: 1, 1000  (what I am expecting)
On Win64/x86_64 I get: 1, 1

Is is as expected ?

Is there safe way for both platforms how to get 1000 (beside that I can 
use: i: int64 absolute c;)


Thanks

-Laco.

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

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

Re: [fpc-pascal] Feature announcement: default namespaces

2018-05-06 Thread Vojtěch Čihák

i,
 
LCLIntf, LCLProc, LCLType isn't enough? I will use dotted units only if there 
will be absolutely no other way around.
I believe it can be useful but I don't think it's "must have" (when I don't 
consider Delphi compat.). 
 
V.
__

Od: "Marcos Douglas B. Santos" 
Komu: FPC-Pascal users discussions 
Datum: 06.05.2018 15:34
Předmět: Re: [fpc-pascal] Feature announcement: default namespaces


On Sun, May 6, 2018 at 4:40 AM, Sven Barth via fpc-pascal
 wrote:
> [...]
>
> In FPC we currently don't use dotted unit names much, but maybe that will
> change in the future.

Would be good if all units could be prefixed to make a pattern, like
`fpc.web, fpc.xml, ...` but I know that we need to maintain the
compatibility with Delphi using the same names...
However, Lazarus could do that — we just need a replace in the code.

By the way, good work!

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 

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

Re: [fpc-pascal] Using constants instead of comments

2018-04-18 Thread Vojtěch Čihák

Hi,
 
Why not define?
 
{$DEFINE DEBUG}
 
{$IFDEF DEBUG} Writeln('diagnostic info'); {$ENDIF}
 
V.
 
__

Od: "James Richters" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 18.04.2018 05:06
Předmět: [fpc-pascal] Using constants instead of comments


I have a whole section of diagnostic writeln's in a program, and it's tedious 
to comment them all out/in as needed.   I'm curious if doing something like

Const 
  diagnosticdetail=false;


If diagnosticdetail then Writeln('diagnostic info');

Is the same as 


// Writeln('diagnostic info');

And the Writeln will actually end up being left out of the compiled program 
altogether... since the constant will never allow it to run,  or if not, is 
there a better way to optionally exclude diagnostic information entirely from 
the compiled program?


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

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

Re: [fpc-pascal] Proposal for new Free Pascal logo

2018-03-31 Thread Vojtěch Čihák

Hi,
 
cheetahs have usually more rounded head and rounded ears. And whiskers should 
be curved.
http://news.stlpublicradio.org/post/cheetah-populations-keep-falling-scientists-demand-better-protection#stream/0
Just my 50 cents.
 
V.
 
__

Od: Mr Bee via fpc-pascal 
Komu: FPC-Pascal Users Discussions 
Datum: 30.03.2018 05:52
Předmět: [fpc-pascal] Proposal for new Free Pascal logo


Hi,These days, most modern programming languages have its own logo. The logo becomes a "brand", a unique 
visual identity for the language. It also acts as a "trademark", a recognizable image for the language. 
It also helps the community to have a single visual identity to distinguish them from other programming 
communities. I've seen it with many other communities, such as Swift, Python, Kotlin, etc.Unfortunately, I don't 
see Pascal language –especially Free Pascal– to have a such logo. Yes, I know the FPC's official site got a running 
cheetah (a .gif file) named as logo. But, I don't think an animated picture is appropriate to be used as a logo. A 
logo should be simple, unique, recognizable and "iconizable" image.So, I propose a new logo for Free 
Pascal. It's a simple cheetah's head. The proposed logo in various sizes (for icon) can be looked at here: 
https://pak.lebah.web.id/fpc/  I also attach the logo as a .png file, in case 
someone ca
n't open my website.If this proposal is accepted, perhaps it's time to rework 
the official FPC's website, using the new logo. It's time to make Pascal looks 
more modern, because it looks pretty old today. I also think the Lazarus' logo 
can be made better, but that's another discussion for another time.What do you 
think?Thank you.Regards,–Mr Bee

--

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

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

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Vojtěch Čihák

I only added {$mode objfpc} to be able compile, so I test this code:
 
program Project1;
{$mode objfpc}
 
uses
  SysUtils;
 
type
  IBar = interface
  ['{C22FB8F4-1EC6-42C4-81E4-F2A52CC52258}']
    function Name: string;
  end;
 
  TBar = class(TInterfacedObject, IBar)
  public
    function Name: string;
  end;
 
{ TBar }
 
function TBar.Name: string;
begin
  Result := ClassName;
end;
 
var
  Bar: TBar;
 
begin
  Bar := TBar.Create;
  try
    if Supports(Bar, IBar) then
      Writeln('Bar supports...');
  finally
    //FreeAndNil(Bar);
  end;
 
end.           
 
My FPC is also 3.0.4, on 64-bit Linux.
Compiled with -gh I have no memory leak since this demo is about COM interfaces.
 
V.
__

Od: "Marcos Douglas B. Santos" <m...@delfire.net>
Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Datum: 11.03.2018 16:17
Předmět: Re: [fpc-pascal] Using Supports() I got an AV... bug?


On Sun, Mar 11, 2018 at 11:51 AM, Vojtěch Čihák <vojtech.ci...@atlas.cz> wrote:
> With this modification and -gh it is alright:
>

Only if you declare `Bar` as `IBar` instead of `TBar`. Please, check
your code again.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Vojtěch Čihák

With this modification and -gh it is alright:
 
[v1@nb-msi Interface]$ ./test
Bar supports...
Heap dump by heaptrc unit
7 memory blocks allocated : 875/880
7 memory blocks freed     : 875/880
0 unfreed memory blocks : 0
True heap size : 360448
True free heap : 360448
[v1@nb-msi Interface]$
 
V.
__
> Od: "Marcos Douglas B. Santos" 
> Komu: FPC-Pascal users discussions 
> Datum: 11.03.2018 15:36
> Předmět: Re: [fpc-pascal] Using Supports() I got an AV... bug?
>
===begin===
 Bar := TBar.Create;
 try
   if Supports(Bar, IBar) then
     Writeln(Bar.Name + ' supports...');
 finally
   Bar.Free;  << no Free
 end;
===end===

Are you still seeing an AV?

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 

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

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Vojtěch Čihák

Yes, TBar is TInterfacedObject and is reference counted therefore Free is not 
needed.
Just comment the line //Bar.Free; compile with -gh and you will see no memory 
leak.
 
V.
__

Od: "Marcos Douglas B. Santos" <m...@delfire.net>
Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Datum: 11.03.2018 14:57
Předmět: Re: [fpc-pascal] Using Supports() I got an AV... bug?


On Sun, Mar 11, 2018 at 10:52 AM, Vojtěch Čihák <vojtech.ci...@atlas.cz> wrote:
>
> Hi,
>
> Bar shoud be released by Interface, no need to call Free.

I'm sorry, but `Bar` was defined as `Bar: TBar` so, it's a class not
an interface.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Vojtěch Čihák

Hi,
 
Bar shoud be released by Interface, no need to call Free.

V.
__

Od: "Marcos Douglas B. Santos" 
Komu: FPC-Pascal users discussions 
Datum: 11.03.2018 14:23
Předmět: [fpc-pascal] Using Supports() I got an AV... bug?


The code below should work but I get an AV when the program calls `Bar.Free`.Do 
you know why?Lazarus 1.8.1 r57299 FPC 3.0.4 
i386-win32-win32/win64...Regards,Marcos Douglas

--

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

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

Re: [fpc-pascal] Advanced note: local variable "i" is assigned but never used?

2018-02-20 Thread Vojtěch Čihák

It does not seem to do anything in latest FPC and Lazarus.
 
V.
__

Od: Juha Manninen 
Komu: FPC-Pascal users discussions 
Datum: 20.02.2018 14:34
Předmět: Re: [fpc-pascal] Advanced note: local variable "i" is assigned but


Try with flag -OoDFA

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

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

[fpc-pascal] Advanced note: local variable "i" is assigned but never used?

2018-02-20 Thread Vojtěch Čihák
Hello,
 
would it be possible to do more advanced checking of this note? This code
 
var i: Integer;
begin
  i:=5;
end;        
 
gives Note: Local variable "i" is assigned but never used
 
var i: Integer;
begin
  i:=5;
  writeln('i ', i);
end;        
 
is OK
 
var i: Integer;
begin
  i:=5;
  writeln('i ', i);
  i:=7;
end;       
 
The last example is also accepted. It would be nice to have Note: Local 
variable "i" is assigned but never used too.
 
Thanks,

Vojtěch a.k.a. Blaazen
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Strange issue with TXMLConfig

2018-01-18 Thread Vojtěch Čihák

Hmm, I remember there are two ways how to work with XML: Laz2_xxx and fcl-xml. 
My idea was that you got some wrong TDOMNode in the path.
V.
__

Od: Darius Blaszyk 
Komu: FPC-Pascal users discussions 
Datum: 18.01.2018 20:31
Předmět: Re: [fpc-pascal] Strange issue with TXMLConfig

Hi, I can only say that TDOMNode from Laz2_DOM in trunk has function 

> CompareName.

I'm using FPC 3.0.4 indeed. No dependency to the LCL.

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

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

Re: [fpc-pascal] Strange issue with TXMLConfig

2018-01-17 Thread Vojtěch Čihák

The second TDOMNode from unit DOM (fcl-xml) has that function too, in FPC 3.0.4.
V.
__

Od: Vojtěch Čihák <vojtech.ci...@atlas.cz>
Komu: FPC-Pascal users discussions
Datum: 18.01.2018 00:30
Předmět: Re: [fpc-pascal] Strange issue with TXMLConfig


Hi, I can only say that TDOMNode from Laz2_DOM in trunk has function 
CompareName.
 
V.
__
> Od: Darius Blaszyk <dhkblas...@zeelandnet.nl>
> Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
> Datum: 18.01.2018 00:11
> Předmět: [fpc-pascal] Strange issue with TXMLConfig
>

--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal> 


--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Strange issue with TXMLConfig

2018-01-17 Thread Vojtěch Čihák

Hi, I can only say that TDOMNode from Laz2_DOM in trunk has function 
CompareName.
 
V.
__

Od: Darius Blaszyk 
Komu: FPC-Pascal users discussions 
Datum: 18.01.2018 00:11
Předmět: [fpc-pascal] Strange issue with TXMLConfig


All of a sudden I get a crash in my app trying to read a path from an XML file. 
The crash comes from the function TDOMNamedNodeMap.Find that crashes on this 
line: 

C := TDOMNode(FList.List^[I]).CompareName(name);

The strange thing is that a simplified example app does not crash! In any case 
I'm 100% sure the path exists and either way even if it didn't XMLConfig should 
not crash. The message form the lazarus code inspector is: Type TDOMNODE has no 
component named COMPARENAME.The code also never reaches the CompareName 
function when I set a breakpoint.

I'm at a loss. Is any one capable to understand what is happening?

Rgds, Darius


My code is:

    c := cache.GetValue('filelist/item_1/crc', 0);

The XML is:



  
    
  


The BT is:

An unhandled exception occurred at $000100033BA4:
EAccessViolation: Access violation
  $000100033BA4 line 1783 of fcl-xml/src/dom.pp
  $000100033C75 line 1802 of fcl-xml/src/dom.pp
  $00010003707D line 3159 of fcl-xml/src/dom.pp
  $00010002EC28 line 195 of xmlconf.pp

--

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

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

Re: [fpc-pascal] Publishing indexed property in descendant

2017-12-28 Thread Vojtěch Čihák

Done, https://bugs.freepascal.org/view.php?id=32896
 
V.
__

Od: Michael Van Canneyt <mich...@freepascal.org>
Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Datum: 28.12.2017 16:43
Předmět: Re: [fpc-pascal] Publishing indexed property in descendant




On Thu, 28 Dec 2017, Vojtěch Čihák wrote:

> Hi,
>  
> is this bug?
>  
>  { TCompStreamPers }
>   TCompStreamPers = class(TCustomControl)
>   private
>     function GetItem(AIndex: Integer): TPersItem;
>     procedure SetItem(AIndex: Integer; AValue: TPersItem);
>   protected
>     FItems: TFPObjectList;
>   public
>     constructor Create(AOwner: TComponent); override;
>     destructor Destroy; override;
>   //published
>     property Item[AIndex: Integer]: TPersItem read GetItem write SetItem;
>   end;
>  
>   TCompStreamPers2 = class(TCompStreamPers)
>   published
>     property Item;
>   end;
>          
> If I try to publish property Item in TCompStreamPers, compiler rejects with 
"compstreampers.pas(31,19) Error: This kind of property cannot be published".
>  
> But when I do it in descendant class, compiler is silent. Delphi7 does not allow it: 
"[Error] Unit2.pas(35): Published property 'Item' cannot be of type ARRAY".

It is a bug, please post a bug report.

Michael.

--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Publishing indexed property in descendant

2017-12-28 Thread Vojtěch Čihák
Hi,
 
is this bug?
 
 { TCompStreamPers }
  TCompStreamPers = class(TCustomControl)
  private
    function GetItem(AIndex: Integer): TPersItem;
    procedure SetItem(AIndex: Integer; AValue: TPersItem);
  protected
    FItems: TFPObjectList;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  //published
    property Item[AIndex: Integer]: TPersItem read GetItem write SetItem;
  end;
 
  TCompStreamPers2 = class(TCompStreamPers)
  published
    property Item;
  end;
         
If I try to publish property Item in TCompStreamPers, compiler rejects with 
"compstreampers.pas(31,19) Error: This kind of property cannot be published".
 
But when I do it in descendant class, compiler is silent. Delphi7 does not 
allow it: "[Error] Unit2.pas(35): Published property 'Item' cannot be of type 
ARRAY".
 
Thanks for reply,
 
V. 
 
 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Freepascal Zip with Password?

2017-12-15 Thread Vojtěch Čihák

Hi,
 
Double Commander allows to create zip archives with password but I don't know 
what lib they use.
 
V.
__

Od: "James Richters" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 12.12.2017 17:32
Předmět: [fpc-pascal] Freepascal Zip with Password?


I've been using Zipper http://wiki.freepascal.org/paszlib#TZipper 
 to create zip files with FPC, but 
I don't see how to create one with a password.  Is this possible with Zipper or is 
there another Zip library I can use with FPC to create a password protected zip file? 
 I would rather be able to make my application just create it and not need the user 
to install 7zip or something else.

James

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

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

Re: [fpc-pascal] TFloatHelper.BuildUp() question

2017-12-15 Thread Vojtěch Čihák

Hi,
 
it seems there is something wrong with helpers or Lazarus is fooled from 
directives.
 
When I find procedure TExtendedHelper.BuidUp() in syshelph.inc and hit 
Ctrl+Shift+Up, it takes me to TFLOATHELPER.BuildUp() implementation in 
syshelpf.inc.
And when I hit Alt+Up, it takes me back to declaration in syshelph.inc, but to 
TSingleHelper!
 
I tested 3.0.4 only.
 
V.
__

Od: Bart 
Komu: FPC-Pascal users discussions 
Datum: 15.12.2017 13:36
Předmět: [fpc-pascal] TFloatHelper.BuildUp() question



What am I doing wrong here?

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

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

Re: [fpc-pascal] Math.MinExtended value

2017-12-14 Thread Vojtěch Čihák

Hi, it seems you are right: 
https://en.wikipedia.org/wiki/Extended_precision#Working_range
 
V.
__

Od: Bart 
Komu: FPC-Pascal users discussions 
Datum: 14.12.2017 23:51
Předmět: [fpc-pascal] Math.MinExtended value


Hi,

I was playing a bit with floating point types when I noticed this discrepancy:

From math.pp

{$ifdef FPC_HAS_TYPE_EXTENDED}
   const
     MinExtended  =  3.4e-4932;
     MaxExtended  =  1.1e+4932;
{$endif FPC_HAS_TYPE_EXTENDED}

From fpc reference guide:
Extended 1.9E-4932 .. 1.1E4932

3.64519953188247460253E-4951 seems to be the lowest value I can get
while testing (Win 32 bit).

What's up with that?

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

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

Re: [fpc-pascal] Overloading IN operator

2017-12-12 Thread Vojtěch Čihák

It seems that overloading is possible but compiler does not want to accept 
anonymous array of strings. It works with variable or with anonymous array of 
integers (FPC 3.0.4).
 
V.
__

Od: Fabio Luis Girardi 
Komu: FPC-Pascal users discussions 
Datum: 13.12.2017 02:37
Předmět: [fpc-pascal] Overloading IN operator



Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada 

http://www.pascalscada.com 

--

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

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

Re: [fpc-pascal] OT: what happened with the Lazarus mailing list?

2017-11-25 Thread Vojtěch Čihák

I can confirm. I sent one mail 21-st November to Laz. ML and the second today 
at ~19:30 and they are not in my mailbox.
 
V.
__

Od: Giuliano Colla 
Komu: fpc-pascal@lists.freepascal.org
Datum: 25.11.2017 13:35
Předmět: Re: [fpc-pascal] OT: what happened with the Lazarus mailing list?




Il 25/11/2017 09:29, Lubos Pintes ha scritto:
> I don't know if the problem is somewhere on my side, but the latest 
> message in Lazarus mailing list on gmane.org is from November 17. 

Same here. I'm subscribed to the Lazarus mailing list, but last message 
i got is of nov 17, 10:23.


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

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

Re: [fpc-pascal] Memory Leak's in XMLRead unit

2017-11-07 Thread Vojtěch Čihák

Hi,
if I run the code it writes "Unhandled exception". I tried to add another 
try..except block and it's OK. 
 
program xml_leak_test;
{$mode objfpc}
uses
  heaptrc,
  Classes,
  DOM,
  XMLRead;
var
  XMLDocument: TXMLDocument;
  InvalidStream: TStringStream;
 
const
  INVALID_XML_CONTENT = '<<>>';
 
begin
  SetHeapTraceOutput('heap.trc');
 
  XMLDocument := nil;
  InvalidStream := TStringStream.Create(INVALID_XML_CONTENT);
  try
    try
      ReadXMLFile(XMLDocument, InvalidStream);
    except
 
    end;
  finally
    InvalidStream.Free;
    XMLDocument.Free;
  end;
 
end.
 
Note: when I tried your original code in Lazaur method, it didn't leak at all.
 
V.
__
> Od: African Wild Dog 
> Komu: FPC-Pascal users discussions 
> Datum: 07.11.2017 23:19
> Předmět: [fpc-pascal] Memory Leak's in XMLRead unit
>
Hello,Using ReadXMLFile function from XMLRead unit generates memory leaks when 
trying to read a invalid XML content.

--

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

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

Re: [fpc-pascal] Problem with array of const

2017-10-28 Thread Vojtěch Čihák

Looking to docs: https://www.freepascal.org/docs-html/ref/refsu69.html
I tried writeln(AnsiString(args[0].VAnsiString));
or just writeln(String(args[0].VAnsiString));
which works.
 
V. 
__

Od: Darius Blaszyk 
Komu: FPC-Pascal users discussions 
Datum: 29.10.2017 00:59
Předmět: [fpc-pascal] Problem with array of const


Consider the application below. When I run it I do get the following output:

name
rgname�F&{---C000-0046}

In other words I lose the first character (a) from the arguments supplied and 
the string returns with a lot of garbage. What am I doing wrong here?

Rgds, Darius

program test_args;

procedure test(name: string; args: array of const);
begin
  writeln(name);
  writeln(args[0].VString^);
end;

begin
  test('name', ['arg']);
end.


--

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

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

Re: [fpc-pascal] Overloaded functions

2017-10-28 Thread Vojtěch Čihák

Overloading means that you have functions with the same name but different 
parameter (or param. list). You can have different return type for each 
parameter but you can never have the same parameters.
V.
__

Od: Darius Blaszyk 
Komu: FPC-Pascal users discussions 
Datum: 28.10.2017 22:58
Předmět: [fpc-pascal] Overloaded functions


Hi,

I have a problem with overloaded functions. I defined these functions:
function val_(name: string): string;
function val_(name: string): boolean;
function val_(name: string): integer;
function val_(name: string): double;

var
  res: boolean;
begin
  res := val_(option_variable);
end;

I get the following error: Error: Incompatible types: got "ShortString" expected 
"Boolean". So for some reason the compiler is looking at the first function. The mode is 
objfpc and I turned ansistrings off. I tested by adding the overload modifier but without result. 
What else could I try or do? Or is overloading only allowed for different parameter lists?

Rgds, Darius


--

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

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

Re: [fpc-pascal] where's the glyph?

2017-10-11 Thread Vojtěch Čihák

Hi,
 
TBitBtn has property Kind, setting it to anything else than bkCustom will show 
the glyph (native, from widgetset).
 
With TSpeedButton, you are always on your own.
 
V.
__

Od: pasc...@piments.com
Komu: fpc-pascal@lists.freepascal.org
Datum: 11.10.2017 12:54
Předmět: [fpc-pascal] where's the glyph?


Hi,

LCL provides the usual Delphi equivalent components like TBitBtn and 
TSpeedButton  but there do not seem to be any glyphs to go with them.


Do I really have to make my own or are there some resources I have not 
found ?


Thanks.


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

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

Re: [fpc-pascal] why the 0.5 in the Unix Epoch (for UnixToDateTime function)

2017-08-01 Thread Vojtěch Čihák

Hi,
 
wiki https://en.wikipedia.org/wiki/Julian_day says that "... Julian day number 0 
assigned to the day starting at noon on January 1, 4713 BC, ..."
The noon means 0,5.
 
V.
__

Od: Dennis 
Komu: FPC-Pascal users discussions 
Datum: 01.08.2017 13:14
Předmět: [fpc-pascal] why the 0.5 in the Unix Epoch (for UnixToDateTime 
function)


I just noticed that the definition of the constants have 0.5 in it.
Why?


from dateh.inc
const
   JulianEpoch = TDateTime(-2415018.5);

   UnixEpoch = JulianEpoch + TDateTime(2440587.5);


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

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

Re: [fpc-pascal] why the 0.5 in the Unix Epoch (for UnixToDateTime function)

2017-08-01 Thread Vojtěch Čihák

Hi,
 
wiki https://en.wikipedia.org/wiki/Julian_day says that "... Julian day number 0 
assigned to the day starting at noon on January 1, 4713 BC, ..."
The noon means 0,5.
 
V.
__

Od: Dennis 
Komu: FPC-Pascal users discussions 
Datum: 01.08.2017 13:14
Předmět: [fpc-pascal] why the 0.5 in the Unix Epoch (for UnixToDateTime 
function)


I just noticed that the definition of the constants have 0.5 in it.
Why?


from dateh.inc
const
   JulianEpoch = TDateTime(-2415018.5);

   UnixEpoch = JulianEpoch + TDateTime(2440587.5);


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

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

Re: [fpc-pascal] Fixed record files

2017-07-09 Thread Vojtěch Čihák

Hi,
 
"packed record" is for compatibility. Its guaranteed that inner alignment and size of 
record will be always the same and will not change in future versions of compiler, unlike the plain 
"record".
 
https://www.freepascal.org/docs-html/ref/refsu15.html
 
V.
__

Od: "James Richters" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 09.07.2017 20:12
Předmět: Re: [fpc-pascal] Fixed record files



I don't understand "packed record" could you elaborate?

James

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

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

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-07 Thread Vojtěch Čihák

Hi,
 
there are different informations about *.wav, so maybe there are different 
impementations too.
See:
http://soundfile.sapp.org/doc/WaveFormat/
and
https://blogs.msdn.microsoft.com/dawate/2009/06/23/intro-to-audio-programming-part-2-demystifying-the-wav-format/
 
The first says that 8-bit is unsigned, the second says signed.
The first does not mention floats, the second says 32-bits but only -1.0 to 1.0.
 
V.
 
__

Od: fredvs 
Komu: fpc-pascal@lists.freepascal.org
Datum: 07.03.2017 22:39
Předmět: Re: [fpc-pascal] Adding a array of float in ressource and use it ?


OK, Sven you win (and http://stackoverflow.com  
should follow fpc forum).
But you will not convince me that c does better than fpc, maybe equal but
surely not better. 


Huh, saving a buffer of float into wav file format, with correct header,
--->
loaded by audacity > horrible noise.

loaded by fpc (via uos) > perfet sound.

But is maybe because wav format accept only in theory data from float.
(and that wav file are (nearly) always encoded from 32 bit integer and
converted into float32).

But that is a other story.

Viva fpc.

Fre;D





-
Many thanks ;-)
--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Adding-a-array-of-float-in-ressource-and-use-it-tp5727765p5727801.html
 

Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 

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

Re: [fpc-pascal] KeyDown routine and Ctrl+Q

2017-02-09 Thread Vojtěch Čihák

Strange. I tested in Linux+Qt and in Delphi7 (under Wine) and both have ssCtrl 
in Shift when I press Ctrl (i.e. Key=17).
 
V.
__

Od: Jürgen Hestermann 
Komu: FPC-Pascal users discussions 
Datum: 09.02.2017 11:52
Předmět: Re: [fpc-pascal] KeyDown routine and Ctrl+Q



BTW:
When Ctrl is pressed, then Shift is empty (which is expected).
Only on the second key Q Shift contains ssCtrl.

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

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

Re: [fpc-pascal] KeyDown routine and Ctrl+Q

2017-02-08 Thread Vojtěch Čihák

Hi,
when you press CTRL+Q you will obtain two OnKeyDown events. The first with 
Key=17 (it is CTRL) and the second with Key=81 (Q). Both events will have 
ssCtrl in Shift.
 
V.
__

Od: Jürgen Hestermann 
Komu: FPC-Pascal users discussions 
Datum: 08.02.2017 22:12
Předmět: [fpc-pascal] KeyDown routine and Ctrl+Q


I use a KEYDOWN routine in my main TFORM to check for the key Ctrl+Q:

-
procedure TForm1.FormKeyDown(Sender : TObject;
                         var Key    : Word;
                             Shift  : TShiftState);
begin // TForm1.FormKeyDown
case key of
   VK_Q :
      begin
      if Shift=[ssCtrl] then
         begin
         
-

But when I type "Ctrl+Q" then "Key" is 17 instead of VK_Q (81).

If I now use 17 to trigger the "Q" key, then it is also triggered
when I just type the Ctrl-key (without any other key)!

This is all a bit weird.
How can I detect that "Ctrl+Q" is pressed without
getting fooled by any other key?

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


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

Re: [fpc-pascal] Array as result in function.

2017-01-21 Thread Vojtěch Čihák

Hi,
 
that's why portaudio.pp declares types like this:
 
PaStream = Pointer;
PPaStream = ^PaStream;
PPPaStream = ^PPaStream;
 
V.
__

Od: Sven Barth 
Komu: fpc-pascal@lists.freepascal.org
Datum: 21.01.2017 12:29
Předmět: Re: [fpc-pascal] Array as result in function.



If the C code however is the one allocating the array (in which case the
type is usually a pointer to a pointer, like "float**" or "^pcfloat" in
Pascal) then you *must not* use a Pascal array, but instead simply pass
in a "pcfloat" variable like this:

some_func(@mypcfloat);

I hope this clears up a few points for mixing C and Pascal arrays.

Regards,
Sven

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


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

Re: [fpc-pascal] Underscores in numerical literals - grouping

2016-11-22 Thread Vojtěch Čihák

To the topic:
 
Currently when I write the line (in Laz. editor):
 
const Num = 123456789;   
 
I can hover the identifier "Num" and I see tooltip:
 
const Num = 123456789
/file/name.pas(x,y)
 
And there is no tooltip when I hover the "123456789".
 
Maybe this is place for improvement.
 
Hovering the "Num" could show
 
const Num = 123 456 789
/file/name.pas(x,y)
 
while hovering the "123456789" could show just
 
123 456 789
 
V.
__

Od: Graeme Geldenhuys 
Komu: FPC-Pascal users discussions 
Datum: 21.11.2016 15:46
Předmět: [fpc-pascal] Underscores in numerical literals - grouping


I don't know about you, but I like this idea implemented in Java 7 and
later.

http://jasdhir.blogspot.co.uk/2016/11/using-underscores-in-literals.html 



I always find it hard to read long numeric literals.

Regards,
 Graeme

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


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

Re: [fpc-pascal] Underscores in numerical literals - grouping

2016-11-21 Thread Vojtěch Čihák

I guess Graeme meant to make non-monospaced font look like monospaced in 
Lazarus editor which currently doesn't work (it looks very ugly).
 
V.
__

Od: Jürgen Hestermann 
Komu: FPC-Pascal users discussions 
Datum: 21.11.2016 17:05
Předmět: Re: [fpc-pascal] Underscores in numerical literals - grouping


Am 2016-11-21 um 15:46 schrieb Graeme Geldenhuys:
> The age old rule
> of programmer source code always being in a mono-spaced font is
> ridiculous for this day and age.
>
Why?
I like monospaced fonts for code very much.

Code is not a novel or a newspaper where you read
a lot of text from top down to the end in a linear manner.
Instead, alignment is very important to make code more readable.
Monospaced fonts make it much easier to align code and
make a lot of things align 'automatically'.

I even align procedure headers like the following where all variables and
all types start at the same column
(which may not be visible in this email if you use proportional fonts ;-).
Please copy it to notepad or into Lazarus Editor in this case):

-
procedure TForm1.FunctionListGetHintSize(Sender : TBaseVirtualTree;
                                         Node   : PVirtualNode;
                                         Column : TColumnIndex;
                                     var R      : TRect);
-

and I align the 'MaskFilter' variable in such a for loop:

-
for i := Low (MaskFilter) to
         High(MaskFilter) do
-

and I like such an aligned declaration

-
function  FileCompareName     (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareDate     (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareSize     (Datei1,Datei2 : PFileTyp) : SizeInt;
function  DirCompareFilesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareBytesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInDir     (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInBranch  (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirName       (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareFilesInBranch(Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareBytesInBranch(Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInDir    (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirName      (Dir1,Dir2 : PTreeTyp) : SizeInt;
-

much more than a non-aligned:

-
function  FileCompareName (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareDate (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareSize (Datei1,Datei2 : PFileTyp) : SizeInt;
function  DirCompareFilesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareBytesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInDir (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirName (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareFilesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareBytesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInDir (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirName (Dir1,Dir2 : PTreeTyp) : SizeInt;
-

You can see imeditately that many functions have the same parameters and all 
result in a SizeInt.
In the non-aligned version this is harder to spot.

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


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

Re: [fpc-pascal] Using for-loop index variable after loop

2016-10-10 Thread Vojtěch Čihák

Hi, if you mean this:
 
function CategoryIndexOf(Name: String): Integer;
  var
    i: Integer;
  begin
    for i:= lstCategory.Items.Count-1 downto 0 do begin
      if lstCategory.Items[i] = Name
      then Break;
    end;
    Result := i;
    if (i = lstCategory.Items.IndexOf(cActionListEditorUnknownCategory))
       and (i = lstCategory.Items.IndexOf(cActionListEditorAllCategory))
    then Result := 0;
  end;
 
It can IMO cause random and hardly reproducible bugs.
 
V.
__

Od: Juha Manninen 
Komu: FPC-Pascal users discussions 
Datum: 10.10.2016 12:16
Předmět: [fpc-pascal] Using for-loop index variable after loop


I have always avoided using a for-loop index variable after the loop.
I thought its value can be unpredictable in some situations when the
compiler reuses its register or memory etc.

I noticed the ActionListEditor in Lazarus sources has code that uses it after 
the loop.

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


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

Re: [fpc-pascal] Type helper for array

2016-06-10 Thread Vojtěch Čihák

@ But the question is whether he want to set the array to empty or if he wants 
to clear the array's contents without changing the size.
 
The second is right but it was not the point. "Clear" is just one example of 
several methods I want to encalupsate into TBuffer.
I decided use the type helper now. Another solution is class:
 
TBuffer = class
  Data: array of Single;
  procedure Create(ASize: Integer);
  procedure Clear;
end;
 
So I would call aBuffer.Data[3]:=5; instead of aBuffer[3]:=5;.
Thanks
__

Od: Sven Barth 
Komu: FPC-Pascal users discussions 
Datum: 10.06.2016 08:03
Předmět: Re: [fpc-pascal] Type helper for array


Am 10.06.2016 07:36 schrieb "Jürgen Hestermann" >:
>
> Am 2016-06-09 um 20:18 schrieb Sven Barth:
>
> > Am 09.06.2016 17:57 schrieb "Vojtech Cihák" >:
> > > aBuffer.Clear;
> > > Is it possible to do this without helper?
> >
> > You can always set the array to Nil
>
> IMO SetLength(aBuffer,0) would the most natural way to clear the array.
*shrugs* That's also a way. Bit the question is whether he want to set the 
array to empty or if he wants to clear the array's contents without changing 
the size.
Regards,
Sven


--

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

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

[fpc-pascal] Type helper for array

2016-06-09 Thread Vojtěch Čihák
Hello,
 
I've got following declaration:
...
{$modeswitch typehelpers}
 
interface
 
uses
  Classes, SysUtils;
 
type
  TBuffer = array of Single;
 
  { TBufferHelper }
  TBufferHelper = type helper for TBuffer
    procedure Clear;
  end;
...
var aBuffer: TBuffer;
...
And I can do:
aBuffer[3]:=5;
aBuffer.Clear;
 
Is it possible to do this without helper? Since it's IMO silly to have helper 
in the same unit as the original declaration. Helpers are usually used where 
extending of the original type is not possible, aren't they?
 
Thanks,  V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Class vs Object type

2016-04-06 Thread Vojtěch Čihák

How can I do it?
 
When I try do:
 
TMyObj = object(TObject)
 
compiler tells me:
 
Error: The mix of different kind of objects (class, object, interface, etc) 
isn't allowed
 
Thanks
 
V.
__

Od: Tomas Hajny 
Komu: "FPC-Pascal users discussions" 
Datum: 06.04.2016 14:07
Předmět: Re: [fpc-pascal] Class vs Object type


On Wed, April 6, 2016 13:26, Michael Van Canneyt wrote:

On Wed, 6 Apr 2016, Graeme Geldenhuys wrote:


True. Note that objects descended from TObject are automatically zeroed
out as well as soon as one calls the constructor Init.

Tomas


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


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

Re: [fpc-pascal] Class constructor called unconditionally

2016-03-31 Thread Vojtěch Čihák

I meant Delphi optimization but I'm mistaking since they have it documented.
 
B.
__

Od: silvioprog <silviop...@gmail.com>
Komu: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
Datum: 31.03.2016 16:17
Předmět: Re: [fpc-pascal] Class constructor called unconditionally


On Thu, Mar 31, 2016 at 10:58 AM, Vojtěch Čihák <vojtech.ci...@atlas.cz 
<vojtech.ci...@atlas.cz>> wrote:
IMO compilers should be dogmatic otherwise one cannot rely on them. This looks 
to me like advocating wrong optimization.
 
Blaazen
Thanks for reply Vojtěch, but are you referring to Delphi or FPC optimization?I think that FPC should keep the Delphi class constructor behaviour in MODE DELPHI, allowing the programmers to port Delphi libraries to FPC, but ...-- 
Silvio Clécio


--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

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

Re: [fpc-pascal] Class constructor called unconditionally

2016-03-31 Thread Vojtěch Čihák

IMO compilers should be dogmatic otherwise one cannot rely on them. This looks 
to me like advocating wrong optimization.
 
Blaazen
__

Od: silvioprog 
Komu: "FPC-Pascal users discussions" 
Datum: 31.03.2016 15:33
Předmět: [fpc-pascal] Class constructor called unconditionally

 As long as you don't use the class anywhere outside the class itself, the compiler takes this as the class not used at all and hence won't call the class constructor. So I guess you have to use the intialization section instead of tweaking the code to fool the compiler. Take the pragmatic approach instead of the dogmatic one. It will be more readable anyway.-- 
Silvio Clécio


--

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


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

Re: [fpc-pascal] Possible bug in Numeric test

2016-02-24 Thread Vojtěch Čihák

Oh, I didn't catch it. So there must be some checking for E in the string - at 
least on the first place - because strings 'E' and '1E' returns FALSE. 
__

Od: Nitorami 
Komu: 
Datum: 24.02.2016 22:22
Předmět: Re: [fpc-pascal] Possible bug in Numeric test


Steve probably means "when passed 'E1' or 'E2' etc."
Indeed IsNum ('E1') interprets it as zero and delivers TRUE.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Possible-bug-in-Numeric-test-tp5724297p5724319.html
 

Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


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

Re: [fpc-pascal] Possible bug in Numeric test

2016-02-24 Thread Vojtěch Čihák

I tried your function in FPC 3.0.0 in mode ObjFPC and it returns False for 
string 'E1/E2/etc'.
 
V.
__

Od: steveg 
Komu: "FPC-Pascal users discussions" 
Datum: 24.02.2016 00:57
Předmět: [fpc-pascal] Possible bug in Numeric test


Not sure if this is considered a bug or not :)

I have found this function returns TRUE if passed 'E1/E2/etc'
I am guessing it is seeing the 'E' as exponent


function IsNum( const sSrc :string ) :boolean;
var
  Code :integer;
  Num :real = 0;
begin
  Num := Num;
  Val(sSrc, Num, Code);
  Exit( Code = 0 );
end;

Thanks - SteveG
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


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

Re: [fpc-pascal] Compiler Mode?

2016-02-24 Thread Vojtěch Čihák

Assigning static class methods to procedure variables in ObjFPC would be very 
nice feature.
 
V.
__

Od: Sven Barth 
Komu: "FPC-Pascal users discussions" 
Datum: 24.02.2016 17:22
Předmět: Re: [fpc-pascal] Compiler Mode?

* Unlogical approach for static; modifier (I can't use static methods as 
callback in objfpc... the main reason of introducing static in Delphi is 
callback for api...)

AFAIK that's a general problem we currently have with static and not just 
restricted to mode ObjFPC. At least in my opinion the assignment of such 
methods to normal procedure variables should be possible no matter which mode 
is selected.
 
Regards,
Sven


--

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


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

Re: [fpc-pascal] Happy tickets benchmark

2016-02-14 Thread Vojtěch Čihák

Does FPC generate different code for Intel (like Core i7) and AMD (like Phenom 
or so) when taget architecture is set to x86_64, i.e. are there any CPU 
manufacturer specific optimizations ?
 
Thanks for reply,
 
V.
__

Od: Florian Klaempfl 
Komu: "FPC-Pascal users discussions" 
Datum: 14.02.2016 12:57
Předmět: Re: [fpc-pascal] Happy tickets benchmark


Am 14.02.2016 um 12:47 schrieb Giuliano Colla:

Il 14/02/2016 11:12, Graeme Geldenhuys ha scritto:

But then, I think such non-realword tests don't prove much.


Except that the implementation of inc(something) should be given a look,
as it's always been sold as faster than something:=something+1


 So for a all-purpose compiler this
makes little sense. If your application really depends on this, rewrite
the hotspots in C and use the icc to compile it. It knows about these
detais.

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


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

Re: [fpc-pascal] Happy tickets benchmark

2016-02-13 Thread Vojtěch Čihák

Hi,
 
64-bit Linux, Core2Duo@2GHz, FPC3.0.0:
 
Pascal: 440 ms
C:  163ms
Delphi )*: 515ms
 
)* Delphi7, personal edition, under wine, command: wine happyd7.exe
__

Od: Serguei TARASSOV 
Komu: 
Datum: 13.02.2016 11:44
Předmět: [fpc-pascal] Happy tickets benchmark


Hello,

Here is my little brute-force test for FPC, C and C# compilers.
http://arbinada.com/main/en/node/1532 

The results are not so good with FPC but I cannot use Delphi to compare 
on Linux.


Could anyone make the series on Windows with FPC, Delphi and MS .Net?
The test of FPC 3.0 and any other comments are welcome.

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


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

Re: [fpc-pascal] Happy tickets benchmark

2016-02-13 Thread Vojtěch Čihák

Thanks, but assembler links are wrong, all seem to point to test.c.
 
V. aka Blaazen
 
__

Od: leledumbo 
Komu: 
Datum: 13.02.2016 18:43
Předmět: Re: [fpc-pascal] Happy tickets benchmark


Here's a test from my machine (Manjaro Linux x86_64 KDE desktop kernel 4.4.1
Core i5-4200u):


Below is the produced assembly from fpc, gcc and clang (no idea how to get
one for mono):
test.s
>  
test.s
>  
test.s
>  

I hope they can be optimizers' / code generator writers' reference to
improve our compiler.

Anyway, I've tried changing the for loop into while since Pascal's for isn't
a syntactic sugar for while as in C's for, but apparently that didn't change
anything so the emitted code is already as best as it can.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Happy-tickets-benchmark-tp5724109p5724116.html
 

Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


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

Re: [fpc-pascal] Happy tickets benchmark

2016-02-13 Thread Vojtěch Čihák

I can confirm, Inc(); is slower. Change decreased time from 440 to 390 ms.
 
Quick test (empty project in Laz.):
unit1.pas:35                              inc(TicketsCount);
0046DB18 4883c001                 add    $0x1,%rax
unit1.pas:36                              TicketsCount+=1;
0046DB1C 488d4001                 lea    0x1(%rax),%rax
unit1.pas:37                              TicketsCount:=TicketsCount+1;
0046DB20 488d5801                 lea    0x1(%rax),%rbx
__

Od: Paulo Costa 
Komu: 
Datum: 13.02.2016 22:00
Předmět: Re: [fpc-pascal] Happy tickets benchmark


On 13-Feb-16 10:44, Serguei TARASSOV wrote:

Could anyone make the series on Windows with FPC, Delphi and MS .Net?
The test of FPC 3.0 and any other comments are welcome.


On my PC with Windows 8.1, fpc 2.6.4 32bits, when I changed the line:
inc(TicketsCount);
to:
TicketsCount := TicketsCount + 1;

the results improved from:
C:\tmp\tests>HappyTickets.exe
Found 4816030 tickets. Elapsed time, msec: 323

to

C:\tmp\tests>HappyTickets.exe
Found 4816030 tickets. Elapsed time, msec: 262


Paulo Costa
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


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

Re: [fpc-pascal] Please someone explain this to me

2016-02-09 Thread Vojtěch Čihák

There exists IDE directive
{%MainUnit ***.pas}
and include files should contain it. But I don't know if there are more units 
containing the same include file.
 
V.
__

Od: Anthony Walter 
Komu: "FPC-Pascal users discussions" 
Datum: 10.02.2016 00:06
Předmět: [fpc-pascal] Please someone explain this to me


I really don't like the include files with Lazarus and Free Pascal for the following 
reason:How the  am I supposed to know which file is including an include 
file?Often times I am trying to find a function or class or some other identifier and 
I search files on disk for the name. Then it turns out the identifier is in some 
include file. Often the include file doesn't have any information to which unit it 
belongs and I am then forced to search further for other files which reference the 
include file. It's a mess.In this issue 
http://mantis.freepascal.org/view.php?id=29599 
 Juha is asking how I was able 
to compile my patch without using the dynlibs unit. Sure enough I am not using the 
dynlibs unit, but on my system it compiles. When I control click the LoadLibrary 
identifier in my Unity patch, Lazarus brings up an include file with LoadLibtary 
declared, but I have no idea which unit is including it (remember I'm not using uni
t dynlibs).So my question is, how do the rest of you deal with include files and locating 
the unit including them? And also can this system for including files be better 
implemented, for example by some IDE feature to figure this out for you and displaying 
the "owning" units.

--

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


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

Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-04 Thread Vojtěch Čihák

Hi,
I personally think that there's no place for democracy in compiler development. 
It would lead to bloat. Although majority of people considered it useful, it 
was not very pascalish.
Trunk is place for experiments and this one is over.
 
V.
__

Od: Sven Barth 
Komu: "FPC-Pascal users discussions" 
Datum: 04.02.2016 20:25
Předmět: [fpc-pascal] IfThen() intrinsic removed


Hello together!

The IfThen() intrinsic has been removed again. There will be *no*
replacement in the foreseeable future. This is not up for discussion.

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


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

Re: [fpc-pascal] Parameter evaluation order

2016-02-02 Thread Vojtěch Čihák

It is guaranted for boolean operators with short-evaluation (if you mean this).
See: http://www.freepascal.org/docs-html/ref/refsu48.html#x150-17200012.8.3
 
V.
__

Od: Andreas Berger 
Komu: 
Datum: 02.02.2016 13:57
Předmět: Re: [fpc-pascal] Parameter evaluation order



On Tue 02/02/2016 10:41, Jonas Maebe wrote:


Andreas Berger wrote on Tue, 02 Feb 2016:


On Tue 02/02/2016 09:27, Jonas Maebe wrote:




It also may have problems when compiling with the Delphi "NextGen" 
compiler: http://stackoverflow.com/a/11010685 


Like Graeme said "I guess I have been lucky"! I have all printed 
documentation for the versions I bought from TP1 to Delphi 7, and it was 
always guaranteed. This sucks!!!


Andreas

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


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

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-01-31 Thread Vojtěch Čihák

Hi,
 
what is difference in produced assembler between ifthen(); and classic if - 
then - else?

Thanks, V.
__

Od: Sven Barth 
Komu: "FPC-Pascal users discussions" 
Datum: 31.01.2016 15:43
Předmět: [fpc-pascal] New feature: IfThen() intrinsic


Hello together!

I've finally come around to add a feature that many people have asked
for throughout the years: an inline if that works like the if-statement
in that it only evaluates that expression that is indeed returned.

After the discussion last year about the inline-if I've decided to add
it as an intrinsic function instead of an extension of the language.
Like all intrinsics it's part of the System unit and "declared" like this:

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


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

Re: [fpc-pascal] ideU version 1.0.0.

2015-12-26 Thread Vojtěch Čihák

Hello Fred,
just for curiosity, your mails (on fpc-pascal) sometimes appear "Fred van Stappen" and 
sometimes "fredvs". Why? Do you have more accounts?
 
Blaazen
__

Od: fredvs 
Komu: 
Datum: 26.12.2015 10:55
Předmět: Re: [fpc-pascal] ideU version 1.0.0.



Fre;D

-
Many thanks ;-)
--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/ideU-version-1-0-0-tp5723468p5723480.html
 

Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 


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

Re: [fpc-pascal] $B and $BOOLEVAL

2015-12-13 Thread Vojtěch Čihák

Thanks, I was not clear.
 
{$B+} and {$B-} works but {$B ON} and {$B OFF} does not. So the docs is wrong 
(or there's bug).
{$BOOLEVAL } works with +/-/ON/OFF.
Compiler is recently released 3.0.0.
__

Od: "Florian Klämpfl" <flor...@freepascal.org>
Komu: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
Datum: 13.12.2015 20:11
Předmět: Re: [fpc-pascal] $B and $BOOLEVAL


Am 13.12.2015 um 19:17 schrieb Vojtěch Čihák:

 
Hi,
 
when I use {$B} I get " Warning: Illegal compiler directive "$B"' ". 


Of course. You omitted on/off +/-

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
<http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

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

[fpc-pascal] $B and $BOOLEVAL

2015-12-13 Thread Vojtěch Čihák
 
Hi,
 
when I use {$B} I get " Warning: Illegal compiler directive "$B"' ". When I use 
$BOOLEVAL everything is OK.
It does not correspond with docs: 
http://www.freepascal.org/docs-html/3.0.0/prog/progsu4.html
 
Should I report?
V.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Initialization of variables used in nested methods

2015-05-13 Thread Vojtěch Čihák

Hi,
 
I have question about initialization of variables used in nested methods.
 
This code gives warning: Variable a does not seem to be initialized.
 
procedure TForm1.Demo;
var a: Integer;
 
 { procedure ProcNested;
  begin
    a:=1;
  end; }
 
begin
  writeln('a: ', a);
end;       
 
When I uncomment the nested procedure, warning is away although it is never 
called.
Should I report it?
 
Thanks, V.

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

Re: [fpc-pascal] TDomNode to text and/or document

2014-09-22 Thread Vojtěch Čihák

Hi,
 
this is working code:
 
...
if not assigned(XMLDoc) then XMLDoc:=TXMLDocument.Create;
  with XMLDoc do
    begin
      if not assigned(DocumentElement) then
        begin
          aNode:=CreateElement(cRoot);
          AppendChild(aNode); 
        end;  
      if ASchemeNode='' then ASchemeNode:=cScheme;
      aNode:=DocumentElement.FindNode(ASchemeNode); 
      if not assigned(aNode) then
        begin
          aNode:=CreateElement(ASchemeNode);
          DocumentElement.AppendChild(aNode);
        end;  
   ...
end;  
 
so simply you have to create DocumentElement (i.e. root node) and append 
children there.
 
Vojtěch 
__

Od: Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com
Komu: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
Datum: 22.09.2014 12:38
Předmět: [fpc-pascal] TDomNode to text and/or document


Hello,

I have a TDomNode (laz2_dom, but I guess it should be the same for all
implementations).

Is it possible to get a TXMLDocument from it? I tried:

 lDoc := TXMLDocument.Create;
 try
   lDoc.AppendChild(ANode);

but it crashes =(

Is it possible to get the full text of this node? something like:

svg bla blasub itemetc etc etc/subitem/svg

TextContent doesn't help at all here.

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

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

Re: [fpc-pascal] with statement using mulltiple objects

2014-09-14 Thread Vojtěch Čihák

Hi,
 
once I came to troubles with with:
 
procedure TForm1.StringGrid1SelectEditor(Sender: TObject; aCol, aRow: Integer; 
var Editor: TWinControl);
begin
  with StringGrid1 do
    begin
      ...
      Editor:= ...;
      ...
    end;
end; 

because Editor is also public property of TStringGrid. Here would be solution to rename 
parameter to AEditor.
 
Vojtěch
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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