[fpc-pascal] New Arc attempt

2016-08-02 Thread leledumbo
Just came across this on my fb timeline:
https://pascal.today/2016/08/01/arc-for-non-managed-types/
would be interesting for gc lovers. WARNING: the given code there doesn't
compile with FPC, even on trunk




--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/New-Arc-attempt-tp5725903.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


Re: [fpc-pascal] New Arc attempt

2016-08-02 Thread Maciej Izak
2016-08-02 11:43 GMT+02:00 leledumbo :

> Just came across this on my fb timeline:
> https://pascal.today/2016/08/01/arc-for-non-managed-types/
> would be interesting for gc lovers. WARNING: the given code there doesn't
> compile with FPC, even on trunk
>

Nothing new. Proposed long time ago (2008!), many times:

http://blog.barrkel.com/2008/11/somewhat-more-efficient-smart-pointers.html
https://adugmembers.wordpress.com/2011/12/05/smart-pointers/
http://delphisorcery.blogspot.com/2015/01/smart-pointers-in-delphi.html

In FPC (branch for smart pointers) we have own much faster implementation
(based on the default field):

https://github.com/maciej-izak/PascalSmartPointers

which is usable also for nullable types.

-- 
Best regards,
Maciej Izak
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] String concatenation failure (again)

2016-08-02 Thread Jürgen Hestermann

I just came accross another issue of string concatenation within my program
that worked okay before FPC 3 but fails after updating to FPC 3.
I had not used this function since the update so I found the problem
only now (by accident):

--
type MyStringType = string;
var S : MyStringType;
Liste : array of MyStringType;
i : SizeInt;

begin
[..] // "Liste" is setup with many string entries (which are also shown 
correctly with Ctrl+F7 (evaluate/modify)
S := '';
for i := Low(Liste) to High(Liste) do
   S := S+Liste[i]+LineEnding;
SetLength(Liste,0);
ShowMessage(S);
end;
--

"S" now always consists of only one line
even when "Liste" has many more.
The for-loop is passed multiple times
as expected but only the first pass adds
a line to "S".

Any idea why this code no longer works?


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


Re: [fpc-pascal] String concatenation failure (again)

2016-08-02 Thread Jürgen Hestermann

Am 2016-08-02 um 12:25 schrieb Jürgen Hestermann:
> --
> type MyStringType = string;
> var S : MyStringType;
> Liste : array of MyStringType;
> i : SizeInt;
>
> begin
> [..] // "Liste" is setup with many string entries (which are also shown 
correctly with Ctrl+F7 (evaluate/modify)
> S := '';
> for i := Low(Liste) to High(Liste) do
>S := S+Liste[i]+LineEnding;
> SetLength(Liste,0);
> ShowMessage(S);
> end;
> --

I just tested a bit more and it seems that the problem
is located in the way the strings are fed into "Liste"
which is done like this from a Windows API function:

--
if FindNextFileNameW(H,Laenge,@Pfad[1]) then
   begin
   SetLength(Liste,Length(Liste)+1);
   Liste[High(Liste)] := copy(Pfad,1,Laenge);
   end;
--

where "Pfad" is a "widestring" (because of the Windows W-function),
"H" is of type "hwnd" and "Laenge" is "SizeInt".

I would expect that with the new string encoding handling
widestring will be converted automatically to "MyStringType"
(which is string in my case). This assumption is  encouraged
by the fact that "Liste" is shown with the correct list of all strings
in the evaluate window when debugging.

The interesting thing is, that *one* (the first) string
from "Liste" is added to "S" (but all others are missing).

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


Re: [fpc-pascal] String concatenation failure (again)

2016-08-02 Thread José Mejuto

El 02/08/2016 a las 16:51, Jürgen Hestermann escribió:


I would expect that with the new string encoding handling
widestring will be converted automatically to "MyStringType"
(which is string in my case). This assumption is  encouraged
by the fact that "Liste" is shown with the correct list of all strings
in the evaluate window when debugging.

The interesting thing is, that *one* (the first) string
from "Liste" is added to "S" (but all others are missing).


Hello,

Check the length of the string I think you have a NULL char at the end 
of every string, so only the first one (up to #00 char) is displayed.



--

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


Re: [fpc-pascal] New Arc attempt

2016-08-02 Thread leledumbo
> In FPC (branch for smart pointers) we have own much faster implementation
(based on the default field):
> 
> https://github.com/maciej-izak/PascalSmartPointers
> 
> which is usable also for nullable types.

I think I've seen this before, but never really dig in to the
implementation.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/New-Arc-attempt-tp5725903p5725908.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