Re: TFPGObjectList error

classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

vojtech.cihak

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 <[hidden email]>
> Komu: FPC-Pascal users discussions <[hidden email]>
> 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<TVec3>;
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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Michalis Kamburelis-3
 2018-07-01 4:01 GMT+02:00 Vojtěch Čihák <[hidden email]>:
> 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?

Indeed, it's a misleading message. The message

   ...identifier idents no member "Free"

doesn't talk about the line

    list.Free;

(which is fine, "list" is an instance of a class). It talks most
likely about the "Free" call inside FGL implementation in

"""
procedure TFPGObjectList.Deref(Item: Pointer);
begin
  if FFreeObjects then
    T(Item^).Free;
end;
"""

If you look inside the FGL unit sources of your FPC version, you will
likely find this to be at line 992 :)

Short explanation:Since your TVec3 is probably not a class, you cannot
do "Free" on it.

The solution is to use TFPGList instead of TFPGObjectList. You should
also define an equality operator if TVec3 is a record. See e.g. my
example in https://castle-engine.io/modern_pascal_introduction.html#_operator_overloading
(scroll to the example with TMyRecordList).

Or you could use Generics.Collections unit with generic TList for
records. It by default compares records by comparing memory contents.

Regards,
Michalis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Ryan Joseph


> On Jun 30, 2018, at 8:14 PM, Michalis Kamburelis <[hidden email]> wrote:
>
> The solution is to use TFPGList instead of TFPGObjectList. You should
> also define an equality operator if TVec3 is a record. See e.g. my
> example in https://castle-engine.io/modern_pascal_introduction.html#_operator_overloading
> (scroll to the example with TMyRecordList).

Thanks, that make sense now. I was really suspicious of TFPGObjectList having Object in it’s name but I didn’t know there was a TFPGList.

>
> Or you could use Generics.Collections unit with generic TList for
> records. It by default compares records by comparing memory contents.

Is that part of the RTL and if so what’s the unit name? I had a hard time finding good resources on classes the RTL provides.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Michalis Kamburelis-3
Ryan Joseph <[hidden email]> wrote:

> Or you could use Generics.Collections unit with generic TList for
> records. It by default compares records by comparing memory contents.

Is that part of the RTL and if so what’s the unit name? I had a hard time finding good resources on classes the RTL provides.

It is part of FPC 3.1.1, and the unit name is "Generics.Collections". For FPC 3.0.x you can take them from Maciej Izak's original repo https://github.com/maciej-izak/generics.collections .

Some examples of basic usage are in my https://castle-engine.io/modern_pascal_introduction.html#generic-containers-section . Also Delphi docs are quite useful since the API is deliberately compatible: http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.Generics.Collections .

Regards,
Michalis

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Jim Lee
In reply to this post by Ryan Joseph


On 06/30/18 19:42, Ryan Joseph wrote:
>
> Is that part of the RTL and if so what’s the unit name? I had a hard time finding good resources on classes the RTL provides.
>

That has been my experience as well.  Is there a definitive source of
documentation for both Free Pascal and Lazarus?  Anyone? Please don't
say the wiki.  And "read the source" is not useful when one doesn't even
know where to look, given the lack of documentation on what's available
and how it's laid out.  I have been forced to use my old Delphi
reference manuals, and that is less than ideal.  At some point I'd even
like to contribute to the documentation, but right now it's a Catch-22
that has me seriously considering giving up on these tools (and that
from 40+ years of programming veteran!)...

-Jim

P.S. - Read this as frustration, not criticism.  I'd just like to find
the hidden resource, if there is one.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Ryan Joseph


> On Jun 30, 2018, at 10:03 PM, Jim Lee <[hidden email]> wrote:

I know of http://docs.getlazarus.org which has some helpful stuff but it’s mainly Lazarus which I personally don’t use.

Otherwise it’s just hunting around in https://www.freepascal.org/docs-html/rtl/ for me. There’s no searching feature though. :(

FPC badly needs something like http://docs.gl (a life saving OpenGL reference).


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Jim Lee


On 06/30/18 21:14, Ryan Joseph wrote:

> I know of http://docs.getlazarus.org which has some helpful stuff but it’s mainly Lazarus which I personally don’t use.
>
> Otherwise it’s just hunting around in https://www.freepascal.org/docs-html/rtl/ for me. There’s no searching feature though. :(
>
> FPC badly needs something like http://docs.gl (a life saving OpenGL reference).
>
>
> Regards,
> Ryan Joseph
>

Thanks Ryan, but that looks like a clone of the fpdoc-generated stuff on
the wiki (with prettier colors, though).

I'll give it a couple more days for someone to chime in, and then it's
back to the land of C for me.  Too bad - Pascal was always my favorite
language.

-Jim



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Michael Van Canneyt
In reply to this post by Jim Lee


On Sat, 30 Jun 2018, Jim Lee wrote:

>
>
> On 06/30/18 19:42, Ryan Joseph wrote:
>>
>> Is that part of the RTL and if so what’s the unit name? I had a hard time
> finding good resources on classes the RTL provides.
>>
>
> That has been my experience as well.  Is there a definitive source of
> documentation for both Free Pascal and Lazarus?  Anyone? Please don't
> say the wiki.  And "read the source" is not useful when one doesn't even
> know where to look, given the lack of documentation on what's available
> and how it's laid out.  I have been forced to use my old Delphi
> reference manuals, and that is less than ideal.  At some point I'd even
> like to contribute to the documentation, but right now it's a Catch-22
> that has me seriously considering giving up on these tools (and that
> from 40+ years of programming veteran!)...
Can you explain what you think is wrong with or missing in the official documentation ?
(apart from a search mechanism)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Marco van de Voort
In our previous episode, Michael Van Canneyt said:
> Can you explain what you think is wrong with or missing in the official documentation ?
> (apart from a search mechanism)

(the CHM form of the documentation has fulltext search, indexes etc. On
Windows you can just click them to open.

It also works from Lazarus, but you can also try a 3rd party CHM viewer like
kchmviewer, though in my opinion the quality of those varies)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Michael Van Canneyt


On Sun, 1 Jul 2018, Marco van de Voort wrote:

> In our previous episode, Michael Van Canneyt said:
>> Can you explain what you think is wrong with or missing in the official documentation ?
>> (apart from a search mechanism)
>
> (the CHM form of the documentation has fulltext search, indexes etc. On
> Windows you can just click them to open.

I know. we have fpIndexer to make such an index. I just need to find time to
integrate building the index into the deployment process and add a link in
the header.

The length of my todo list can no longer be expressed in an Int64.
Maybe we need to add Int128 to the compiler...

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Ryan Joseph
In reply to this post by Marco van de Voort


> On Jul 1, 2018, at 6:19 AM, Marco van de Voort <[hidden email]> wrote:
>
> (the CHM form of the documentation has fulltext search, indexes etc. On
> Windows you can just click them to open.

The CHM reader can be searched so why doesn’t search work for the web interface? I would think there would be a standard script for displaying that format online.

Also the RTL is missing collections.generics. Is that because it’s a new addition?

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Marco van de Voort
In reply to this post by Michael Van Canneyt
In our previous episode, Michael Van Canneyt said:
> > (the CHM form of the documentation has fulltext search, indexes etc. On
> > Windows you can just click them to open.
>
> I know. we have fpIndexer to make such an index.

The CHM packages has its own (afaik with phrase compression)

> I just need to find time to integrate building the index into the
> deployment process and add a link in the header.
>
> The length of my todo list can no longer be expressed in an Int64.
> Maybe we need to add Int128 to the compiler...

True. I actually have a local webserver based helpsystem that loads the CHMs
on my todo. Even to just be able to easier check working on non Windows
systems. gnochm and kchmviewer are more often broken than not for non
trivial files.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Jim Lee
In reply to this post by Michael Van Canneyt


On 07/01/18 01:03, Michael Van Canneyt wrote:
>
> Can you explain what you think is wrong with or missing in the
> official documentation ?
> (apart from a search mechanism)
>
> Michael.
>
Well, search is a big one, but there seems to be a lot of missing pieces
(again, without search it's hard to tell exactly how much is missing). 
There also seems to be a lot of outdated stuff, and most of what I find
was auto-generated from fpdoc (when? last week or 10 years ago?  no
timestamps!), with scant (or no) explanation beyond "here is a terse,
un-commented example".

I haven't found any sort of map or tree that shows how the rtl and fcl
are organized, or an index that shows which types/functions/classes are
in which units (that's hugely important).  Basically, I expected to find
the equivalent of the old Borland programmer's reference manuals.

The most common scenario for me is this: "I wonder if fpc (or Lazarus)
already has <insert feature here>".  Go to the wiki and browse
haphazardly, looking for something named similarly.  If that something
is found, and looks promising, follow link to a half-page of
"documentation" which is basically just a snippet of the interface
section in the source.  Then, try to find the referenced module in my
local source tree and discover that it's not quite the same, or is not
what I was looking for in the first place.  Rinse and repeat.

I would love to be able to use fpc, as it's pretty much the only game in
town when it comes to a cross-platform Pascal able to be used for
low-level, even bare metal programming.  I also realize that
documentation is often low on the list of priorities - but good
documentation is vital to build a user base, and bad documentation is
what drives people away.

-Jim

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

wkitty42
On 07/01/2018 02:38 PM, Jim Lee wrote:
> The most common scenario for me is this: "I wonder if fpc (or Lazarus)
> already has <insert feature here>".  Go to the wiki and browse haphazardly,
> looking for [...]

that may be part of your problem... you're looking in a wiki instead of a more
proper place... all the FPC docs i read on the web are almost exactly like the
help files you can use locally with a CHM viewer or similar... what you are
looking for are these...

https://www.freepascal.org/docs-html/rtl/index.html
https://www.freepascal.org/docs-html/fcl/index.html

and actually, you would start here at the beginning...

https://www.freepascal.org/docs.var


it is rather interesting that the above docs.var doesn't appear to be mentioned
in the wiki's page for Lazarus_Documentation... all the links in the
#Free_Pascal_Compiler_Documentation section of that page point to lazarus-ccr
instead of the above docs.var location...

i don't know which is right but i do know you're not looking in the right place
or your google-fu is lacking a bit... i started this reply with a search for
"freepascal runtime library" and the second hit was the docs-html one above... ;)


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list unless*
        *a signed and pre-paid contract is in effect with us.*
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Jim Lee


On 07/01/18 12:07, [hidden email] wrote:

> On 07/01/2018 02:38 PM, Jim Lee wrote:
>> The most common scenario for me is this: "I wonder if fpc (or Lazarus)
>> already has <insert feature here>".  Go to the wiki and browse
>> haphazardly,
>> looking for [...]
>
> that may be part of your problem... you're looking in a wiki instead
> of a more proper place... all the FPC docs i read on the web are
> almost exactly like the help files you can use locally with a CHM
> viewer or similar... what you are looking for are these...
>
> https://www.freepascal.org/docs-html/rtl/index.html
> https://www.freepascal.org/docs-html/fcl/index.html
>
> and actually, you would start here at the beginning...
>
> https://www.freepascal.org/docs.var
>
>
> it is rather interesting that the above docs.var doesn't appear to be
> mentioned in the wiki's page for Lazarus_Documentation... all the
> links in the #Free_Pascal_Compiler_Documentation section of that page
> point to lazarus-ccr instead of the above docs.var location...
>
> i don't know which is right but i do know you're not looking in the
> right place or your google-fu is lacking a bit... i started this reply
> with a search for "freepascal runtime library" and the second hit was
> the docs-html one above... ;)
>
>
That is exactly the documentation I'm talking about.  I've seen all of
them.  I got to them via the wiki, so I suppose I should have said "The
wiki, and documentation linked to from there".

-Jim

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

wkitty42
On 07/01/2018 03:13 PM, Jim Lee wrote:
> That is exactly the documentation I'm talking about.  I've seen all of them.  I
> got to them via the wiki, so I suppose I should have said "The wiki, and
> documentation linked to from there".


oh!! ok, well... i think the docs.var one i pointed out above is the better
one... i don't know why but i do... it is where i always go... it also has dates
at the very bottom of when it was generated... the rtl one i linked to was
generated in 2017...

bookmark that docs.var link ;)


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list unless*
        *a signed and pre-paid contract is in effect with us.*
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Michael Van Canneyt
In reply to this post by Jim Lee


On Sun, 1 Jul 2018, Jim Lee wrote:

>
>
> On 07/01/18 01:03, Michael Van Canneyt wrote:
>>
>> Can you explain what you think is wrong with or missing in the
>> official documentation ?
>> (apart from a search mechanism)
>>
>> Michael.
>>
> Well, search is a big one, but there seems to be a lot of missing pieces
> (again, without search it's hard to tell exactly how much is missing). 
> There also seems to be a lot of outdated stuff, and most of what I find
> was auto-generated from fpdoc (when? last week or 10 years ago?  no
> timestamps!), with scant (or no) explanation beyond "here is a terse,
> un-commented example".
The documentation is brought up to date at every release: all new
identifiers are documented and the documentation regenerated.
If you look in the bugtracker, you will see that I regularly fix
documentation issues.

If you think it is too terse in places, please report them in the
bugtracker. I will always fix all such reports.

>
> I haven't found any sort of map or tree that shows how the rtl and fcl
> are organized, or an index that shows which types/functions/classes are
> in which units (that's hugely important).  Basically, I expected to find
> the equivalent of the old Borland programmer's reference manuals.

It is all there, user's guide, language reference, programmer's guide,
Reference to *all* rtl units. What do you think is missing ?

See https://www.freepascal.org/docs.var

index:
RTL: https://www.freepascal.org/docs-html/current/rtl/index-8.html
FCL: https://www.freepascal.org/docs-html/current/fcl/index-8.html


>
> The most common scenario for me is this: "I wonder if fpc (or Lazarus)
> already has <insert feature here>".  Go to the wiki and browse
> haphazardly, looking for something named similarly.  If that something
> is found, and looks promising, follow link to a half-page of
> "documentation" which is basically just a snippet of the interface
> section in the source.  Then, try to find the referenced module in my
> local source tree and discover that it's not quite the same, or is not
> what I was looking for in the first place.  Rinse and repeat.

I don't know what documentation you are referring to, but as said, all basic
RTL units, and selected FCL units  are documented:
https://www.freepascal.org/docs.var

Packages are another story. I checked the packages. There are roughly 16.000 classes.
I didn't count methods/functions, but they surely are a multiple of that.
There is 1 documenter: me.

I have toyed with the idea to run fpDoc on all packages, and put the result
online, so people can at least have a look in the index to see what's
available.,

Feel free to chip in.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Jim Lee


On 07/01/18 12:28, Michael Van Canneyt wrote:
>
> The documentation is brought up to date at every release: all new
> identifiers are documented and the documentation regenerated.
> If you look in the bugtracker, you will see that I regularly fix
> documentation issues.
>

Thanks.  The user's guide, programmer's guide, and language reference
manual all say they are for version 3.0.2.  Perhaps the current version
didn't require any documentation changes?

> If you think it is too terse in places, please report them in the
> bugtracker. I will always fix all such reports.
>
>

That really wasn't my point.  From the point of view of someone just
coming to fpc,  the documentation is the "face" of the product.  If that
face is ugly or hard to navigate, they are likely to just walk away.  
Getting involved in the bugtracker is for people already invested in
fpc, and familiar enough with it to not *need* the documentation.

> It is all there, user's guide, language reference, programmer's guide,
> Reference to *all* rtl units. What do you think is missing ?
>
> See https://www.freepascal.org/docs.var
>

Perhaps the rtl is more complete than the rest - I'll take your word for
it.  I know it's a tremendous amount of work!

The class library chart on that page is nice, but it's 11 years old
(dated 2007).

> index:
> RTL: https://www.freepascal.org/docs-html/current/rtl/index-8.html
> FCL: https://www.freepascal.org/docs-html/current/fcl/index-8.html
>

An auto-generated index of all identifiers used across all modules is
useful, if you know what you're looking for.  Say I was looking for
something like a Timer class - where do I start?  Would it be in the
rtl, the fcl, or somewhere else?  Would it be named Timer, TTimer, or
something else?  I can't find an index that has an entry for "timer" and
points to all the timer-related things.

> Packages are another story. I checked the packages. There are roughly
> 16.000 classes.
> I didn't count methods/functions, but they surely are a multiple of that.
> There is 1 documenter: me.
>

Pardon my ignorance, but I take it that "packages" is more like an
un-curated repository of contributions rather than an official part of
the fpc distribution?  If so, I wasn't aware of that.  It would explain
a big part of my frustration.

-Jim

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Ryan Joseph
In reply to this post by Michael Van Canneyt


> On Jul 1, 2018, at 1:28 PM, Michael Van Canneyt <[hidden email]> wrote:
>
> RTL: https://www.freepascal.org/docs-html/current/rtl/index-8.html

Without a good search feature these are really hard to use. Searching should be the first priority. Can’t we just make a little script to put on the server which searches the original indexed format which the HTML is derived from? It would be so easy to make something that’s cheap but at least works.


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TFPGObjectList error

Michael Van Canneyt


On Sun, 1 Jul 2018, Ryan Joseph wrote:

>
>
>> On Jul 1, 2018, at 1:28 PM, Michael Van Canneyt <[hidden email]> wrote:
>>
>> RTL: https://www.freepascal.org/docs-html/current/rtl/index-8.html
>
> Without a good search feature these are really hard to use.  Searching
> should be the first priority.  Can’t we just make a little script to put
> on the server which searches the original indexed format which the HTML is
> derived from?  It would be so easy to make something that’s cheap but at
> least works.
And to what page would this script then point when you find something ?
If it was easy, it would have been done already.

But, here's your shot at contributing :)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
12