Re: [fpc-pascal] Compiler hangs while generating debug information

2018-01-11 Thread Sven Barth via fpc-pascal
Am 11.01.2018 18:47 schrieb "Nitorami" :

Any opinions ?


You can try to minimize your source by removing parts to see what might
cause the problem.
Alternatively you can debug the compiler in Lazarus.

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

Re: [fpc-pascal] issue when enabling -O2

2018-01-11 Thread Matias Vara
After fixing the assembler code and other issues, e.g., interruption
handlers were not restoring all registers, I observed an speed up of ~12%
with -O2 when running a simple webserver example. That's very impresive!

Thanks for you help, Matias.

2018-01-10 18:19 GMT+01:00 Matias Vara :

>
> 2018-01-10 18:09 GMT+01:00 Karoly Balogh (Charlie/SGR) <
> char...@scenergy.dfmk.hu>:
>
>> Hi,
>>
>> On Wed, 10 Jan 2018, Matias Vara wrote:
>>
>> > BTW, this only applies to inline assembler functions rigth? In the case
>> > of normal procedures that contains a block asm end; there is no problem,
>> > Am I right?
>>
>> No, it applies to *ALL* assembler code. Also inline blocks. The only
>> difference is, for blocks you can hint the compiler which registers you
>> use, so the compiler can also tailor code which improves the interaction
>> with your assembler code:
>>
>> https://www.freepascal.org/docs-html/ref/refse87.html
>>
>> This is not true for pure assembler functions tho', for performance
>> reasons among others.
>>
>> Charlie
>>
>
> This is very interesting.
>
> Thanks a lot.
>
>
>
>> ___
>> 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] can inherited simply replace inherited method(param1, param2, param3)?

2018-01-11 Thread Graeme Geldenhuys

On 2018-01-11 16:35, Dennis wrote:

are the 2 below equivalent?


Yes they are. Lazarus IDE auto implements the later, and Delphi IDE the 
first. What is again annoying about Delphi IDE is that it chooses to 
generate "inherited;" lines, but then can't allow you to code navigate 
(Ctrl+LeftClick). You have to manually fix the generated code like your 
second example before Delphi IDE can code navigate to the parent 
implementation.


Yet another reason why Lazarus IDE is so much better than Delphi XE onwards.

Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Compiler hangs while generating debug information

2018-01-11 Thread Nitorami
I encountered an odd problem, however reliably reproducible under both
windows 7 and 10, 32bit, with FPC 3.0.2 and 3.0.4. (NOT with Lazarus 1.6.4
which uses FPC 3.0.2 but 64bit)

When compiling my program with debug info using fpc -B -g, the compiler
hangs just before generating the exe file. It seems to get into an endless
loop while assembling the debug information. When compiling without debug
info, or in dwarf format (fpc -B -gw), the issue does not appear, and the
code compiles properly. 

The individual units also compile ok. The issue only appears when compiling
the entire program, or at least the highest level unit.

"Hangs" means no reaction for >5 minutes while normally the code compiles in
2 seconds.

I am not using generics.

The issue does not depend on any compiler settings, except debug information
/ format. 

My source code is correct and working properly when compiled with nodebug;
it just happens to throw the compiler into an endless loop by some remote
combination of factors. The freeze may disappear or reoccur when changing
parts of the code but the causal factors are entirely intransparent to me,
and I did not manage to strip the program down to a small piece of code
which still causes the problem.

Personally I can use nodebug as workaround, that's fine, but I think the
issue should be fixed in the compiler. I am uncertain whether I should
submit this as a bug report; I would have to submit all source code as far
as necessary to reproduce the problem, in case anybody is willing to look
into it. It is approx. 8 units with 4000 lines of code. I don't think one
would have to understand the code, it is rather an issue of running the
compiler in a debugging environment while it tries to compile. That is
beyond my own skills.
Any opinions ?





--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] can inherited simply replace inherited method(param1, param2, param3)?

2018-01-11 Thread Mattias Gaertner
On Fri, 12 Jan 2018 00:35:30 +0800
Dennis  wrote:

> are the 2 below equivalent?
> 
> procedure Method(param1, param2 : integer);
> begin
>inherited;
> end;
> 
> 
> 
> procedure Method(param1, param2 : integer);
> begin
>inherited Method(param1, param2);
>   end;

Yes.

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

[fpc-pascal] can inherited simply replace inherited method(param1, param2, param3)?

2018-01-11 Thread Dennis

are the 2 below equivalent?

procedure Method(param1, param2 : integer);
begin
  inherited;
end;



procedure Method(param1, param2 : integer);
begin
  inherited Method(param1, param2);
 end;

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

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Sven Barth via fpc-pascal
Am 11.01.2018 13:33 schrieb "Mattias Gaertner" :

On Wed, 10 Jan 2018 11:40:48 -0700 (MST)
warleyalex via fpc-pascal  wrote:

>[...]
> · Add(item [,...]) / Push(item [,...]) : increases Length by one and adds
one or more item at the end of the array, can also add arrays
(concatenation).
>
> · Clear() : empties the array (equivalent to SetLength(0))
>
> · Copy(startIndex[, count]) : creates a new dynamic array containing
count items from startIndex, if count isn't specified, copies to the end of
the array.
> [...]

There are the usual Pascal array functions, like setlength, copy, insert,
delete and concat.

You can also type cast the array to JSArray from unit js, which gives you
all the JS functions.

And when eventually type helpers are implemented, functions can be added to
Pascal arrays.


The problem with helper types is that you can't add them for all array
types at once, but only for a specific one (and even then  - at least in
Delphi and FPC - you can't use "array of X", but need to use an explicit
array type).

Especially with the concept of type helpers already existing it makes sense
to think about "built in methods" for arrays...

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

[fpc-pascal] PAS2JS: JSON suggestion

2018-01-11 Thread warleyalex via fpc-pascal
IMHO, theTJSJSONexternal class definition is incorrect.
Currently, we have class function, if you want to use the stringify method,
use this wierd way:TJSJSON.stringify( jsObject);
I think code that don't have mutual dependencies should be separate in
units:
unit ECMA.Json;interface{$mode objfpc}{$modeswitch externalclass}type 
TKeyValueProcessor = function (Key: String; Value: JSValue): JSValue;  
JJSON = class external name 'JSON'  publicfunction parse(Text: String):
JSValue; overload;function parse(Text: String; Reviver:
TKeyValueProcessor): JSValue; overload;function stringify(const Value:
JSValue): String; overload;function stringify(const Value: JSValue;
Replacer: TKeyValueProcessor): String; overload;function stringify(const
Value: JSValue; Replacer: TKeyValueProcessor; Space: String): String;
overload;  end;var  JSON: JJSON; external name 'JSON';implementationend.
and use like this: JSON.stringify( JsonObject );




--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Mattias Gaertner
On Wed, 10 Jan 2018 11:40:48 -0700 (MST)
warleyalex via fpc-pascal  wrote:

>[...]
> · Add(item [,...]) / Push(item [,...]) : increases Length by one and adds one 
> or more item at the end of the array, can also add arrays (concatenation).  
> 
> · Clear() : empties the array (equivalent to SetLength(0))  
> 
> · Copy(startIndex[, count]) : creates a new dynamic array containing count 
> items from startIndex, if count isn't specified, copies to the end of the 
> array.  
> [...]

There are the usual Pascal array functions, like setlength, copy, insert, 
delete and concat.

You can also type cast the array to JSArray from unit js, which gives you all 
the JS functions.

And when eventually type helpers are implemented, functions can be added to 
Pascal arrays.

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

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Mattias Gaertner
On Wed, 10 Jan 2018 11:40:48 -0700 (MST)
warleyalex via fpc-pascal  wrote:

> Since it's missing the Pas2JS specific forum, I don't know if here is correct
> place to post things about "Pas2JS".

Hopefully there will be one soon.

 
> I'm using it a lot and it's very promising. I came across with issue when
> dealing with array of records. 
> 
> I would like to convert this little piece of DWScript code to Pas2JS,
> unfortunately, I couldn't find a way how to push an array of record. For
> instance:
> type 
>   JC = record 
>  id : integer; external 'id'; 
>  name : string; external 'name'; 
>  age : integer; external 'age'; 
>   end; 

Why the 'external' modifiers?

> ...using JS object instead of function for record...
> I believe it will be nice if PAS2JS could generate similar code,

It's on the todo list.


> I don't know,I believe it will achieves better performance using
> ordinary arrays, at least.

And it is useful for many JS functions expecting an enumerable
object.


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

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Michael Van Canneyt



On Thu, 11 Jan 2018, Mattias Gaertner wrote:


On Thu, 11 Jan 2018 11:44:30 +0100
Sven Barth via fpc-pascal  wrote:


Am 11.01.2018 08:16 schrieb "warleyalex via fpc-pascal" <
fpc-pascal@lists.freepascal.org>:

Anyway, what I couldn't find is the built-in kind of *pseudo-methods for
the record data type*, set of operations, for inserting, removing, sorting
and otherwise manipulate the content, for instance:

Don't you mean "pseudo-methods for the array data type"?

In addition to *Low*, *High*, *Length* and *Count*,

I suppose that the standard Pascal way of using SetLength() is used to add
elements. Maybe also the "+" operator (not know if that already got
implemented for arrays; in FPC it is still missing for now). Also it could
be that Insert(), Delete(), Concat() and Concat()  already support arrays
as well in addition to strings (like FPC itself does).


From the pas2js docs:
"Supported features of dynamic arrays: SetLength(), Length(),
equal/notequal nil, low(), high(), assigned(), concat(), copy(),
insert(), delete(), multi dimensional, array of record."

https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/utils/pas2js/docs/translation.html?view=co#array


Hm. I should read this document more often :)

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

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Michael Van Canneyt



On Thu, 11 Jan 2018, warleyalex via fpc-pascal wrote:


Thanks a lot for the feedback.
it worked as expected! The solution was:
/* in DWScript world */var recA : JA;recB : JB;recC : JC;for var
k:=0 to 2 do begin  recC.id := k;  recC.name := 'abc'+IntToStr(k);  recC.age
:= 10+k;  recB.field1 := 'rec'+ IntToStr(k);  recB.params.Add(recC);
recA.fields.Add(recB);end;/* in Pas2JS world */var recA : JA;recB : JB;
recC : JC;k:Integer;beginfor k:=0 to 2 do begin  recC.id := k;
recC.name := 'abc'+IntToStr(k);  recC.age := 10+k;  recB.field1 := 'rec'+
IntToStr(k);  TJSArray(recB.params).push(recC);
TJSArray(recA.fields).push(recB);end;
Take a look at this array of record example, in Smart Pascal world, as long
as the datatypes match (e.g. field params is a array of record), we have the
pseudo methods functionality "built-in" for all arrays, for instance. Pas2JS
could have this high level functionality as well. Using the Pas2JS approach
with external classes interfaces it looks so powerful :)



In due course, array methods will be added, to get on par with FPC/Delphi.

But we have no plans to copy smart pascal extensions.

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

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Mattias Gaertner
On Thu, 11 Jan 2018 11:44:30 +0100
Sven Barth via fpc-pascal  wrote:

> Am 11.01.2018 08:16 schrieb "warleyalex via fpc-pascal" <
> fpc-pascal@lists.freepascal.org>:
> 
> Anyway, what I couldn't find is the built-in kind of *pseudo-methods for
> the record data type*, set of operations, for inserting, removing, sorting
> and otherwise manipulate the content, for instance:
> 
> Don't you mean "pseudo-methods for the array data type"?
> 
> In addition to *Low*, *High*, *Length* and *Count*,
> 
> I suppose that the standard Pascal way of using SetLength() is used to add
> elements. Maybe also the "+" operator (not know if that already got
> implemented for arrays; in FPC it is still missing for now). Also it could
> be that Insert(), Delete(), Concat() and Concat()  already support arrays
> as well in addition to strings (like FPC itself does).

From the pas2js docs:
"Supported features of dynamic arrays: SetLength(), Length(),
equal/notequal nil, low(), high(), assigned(), concat(), copy(),
insert(), delete(), multi dimensional, array of record."

https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/utils/pas2js/docs/translation.html?view=co#array

The "+' operator is not yet supported.

Mattias

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

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread warleyalex via fpc-pascal
Thanks a lot for the feedback.
it worked as expected! The solution was:
/* in DWScript world */var recA : JA;recB : JB;recC : JC;for var
k:=0 to 2 do begin  recC.id := k;  recC.name := 'abc'+IntToStr(k);  recC.age
:= 10+k;  recB.field1 := 'rec'+ IntToStr(k);  recB.params.Add(recC); 
recA.fields.Add(recB);end;/* in Pas2JS world */var recA : JA;recB : JB;   
recC : JC;k:Integer;beginfor k:=0 to 2 do begin  recC.id := k; 
recC.name := 'abc'+IntToStr(k);  recC.age := 10+k;  recB.field1 := 'rec'+
IntToStr(k);  TJSArray(recB.params).push(recC); 
TJSArray(recA.fields).push(recB);end;
Take a look at this array of record example, in Smart Pascal world, as long
as the datatypes match (e.g. field params is a array of record), we have the
pseudo methods functionality "built-in" for all arrays, for instance. Pas2JS
could have this high level functionality as well. Using the Pas2JS approach
with external classes interfaces it looks so powerful :)
 



--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Michael Van Canneyt



On Thu, 11 Jan 2018, Sven Barth via fpc-pascal wrote:


Am 11.01.2018 08:16 schrieb "warleyalex via fpc-pascal" <
fpc-pascal@lists.freepascal.org>:

Anyway, what I couldn't find is the built-in kind of *pseudo-methods for
the record data type*, set of operations, for inserting, removing, sorting
and otherwise manipulate the content, for instance:

Don't you mean "pseudo-methods for the array data type"?

In addition to *Low*, *High*, *Length* and *Count*,

I suppose that the standard Pascal way of using SetLength() is used to add
elements. Maybe also the "+" operator (not know if that already got
implemented for arrays; in FPC it is still missing for now). Also it could
be that Insert(), Delete(), Concat() and Concat()  already support arrays
as well in addition to strings (like FPC itself does).


Except the SetLength() one, none of these methods is supported yet.

The easiest currently is to do a TJSArray(myarray).push(myelement)

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

Re: [fpc-pascal] PAS2JS: operations with array of record

2018-01-11 Thread Sven Barth via fpc-pascal
Am 11.01.2018 08:16 schrieb "warleyalex via fpc-pascal" <
fpc-pascal@lists.freepascal.org>:

Anyway, what I couldn't find is the built-in kind of *pseudo-methods for
the record data type*, set of operations, for inserting, removing, sorting
and otherwise manipulate the content, for instance:

Don't you mean "pseudo-methods for the array data type"?

In addition to *Low*, *High*, *Length* and *Count*,

I suppose that the standard Pascal way of using SetLength() is used to add
elements. Maybe also the "+" operator (not know if that already got
implemented for arrays; in FPC it is still missing for now). Also it could
be that Insert(), Delete(), Concat() and Concat()  already support arrays
as well in addition to strings (like FPC itself does).

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

Re: [fpc-pascal] Generics vs templates

2018-01-11 Thread Sven Barth via fpc-pascal
Am 11.01.2018 08:06 schrieb "Michael Schnell" :

On 09.01.2018 08:04, Sven Barth via fpc-pascal wrote:

But you need to program in a way that allows the usage of multiple,
different types. That can more often than not lead to worse performance.

Seemingly it is done that way.

I rather often did a kind of "Generics" in ANSI C by using Macros. It's
catastrophic for code writing and for debugging but does not impose any
performance issues.

I suppose there is a reason why in Pascal Generics are not translated in
multiple dedicatedly typed code snippets at compile time.


Huh? A generic is reparsed for every type tuple it is specialized with
(except of course it already finds an existing previous specialization for
these types), but you need to write the generic's code in a way that
satisfies the parser for all these types (though FPC is more lenient here
than Delphi).

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

Re: [fpc-pascal] Comp type

2018-01-11 Thread greim

By the way there was a bug in fpc 3.0.
I am not sure if it is fixed yet.
Dividing a comp number by any other number gives wrong results.
Please see my posting from 29.06.2016

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