Virtual Pascal

Classic Object Pascal for free

After many small programs I made in VP, Ive tryed to reduce memory usage when working with huge arrays of ansistring/records.
I see resizable arrays like x:array of sometype; are not accepted.
Is it a workaround or sadly I must migrate all to Free Pascal ?

I see here people updating VP sources. Can my problem be solved by some update/patch ?

I think it will be usefull to keep a list with updates/mods in a separate discussion as soon as they are tested/approved by Allen.
If not enough space, I offer myself to host the files on my site if the owners send them to me by mail and instruct me what to write as their comments/howTo if necessary on the page.
I can host also entire remaked builds/betas of VP with your contribution.
I like too much VP to see it dead, so if I can't help with knowledge(I dont have much) I can help with hosting.

Please tell me how to help the comunity.
Please tell me how to improve my VP.

Views: 760

Reply to This

Replies to This Discussion

As an alternative to dynamic arrays, have you considered changing the affected areas of your code to use tCollection objects instead? These effectively encapsulate dynamimc arrays of objects.

VP is unlikely to ever acquire the language featue where you can declare something as an array without also specifying the length of it.

(one of the reasons that I often use arrays of records instead of is that arrays with only static types can be cheaply binary dumped to disk, copied etc)
Yes, I do that too. It's also more memory efficient if you have a fixed record type (or even simple type) that you just need an expanding array of, rather than collections which are built to hold lists of dynamically allocated things like Ansistrings and object/class instances.

If all you have is a simple array like that, and you need to size it dynamically, it would be simple to implement a class that does that for you, and manages the nitty gritty of memory allocation etc. I have often done this, although it does require a small amount of OO programming knowledge to do of course.

Yes. I still do this with dyn arrays btw, since the problem of dyn arrays is that with larger arrays you often need to grow it in larger increments than one to avoid fragmenting memory too much.

Tlist/tcollection remain with a 32-bit index in FPC btw, also in 64-bit editions. Since the core datastructure of it is a single array, fragmentation would kill you with extreme high element counts.

Note that I think btw that because of this with 32-bit compilers, the practical element count is limited to something like 2GB/sizeof(pointer), so with 64-bit you do win a factor 4 :-)
I work with lot of text files with lines of text, using arrays of string, ansistring and word/extended/longint.
Also I load the lines in the files in (fixed)records of previously types.
The number of files I must load once and the number of lines in each file is very variable.
I have to declare more arrays and more elements per array to surely cover the maximum number of files and max lines in file.

Allan, how can be implemented a class to allow the creation/use of dynamic arrays in VP?
Can you save my life?
Thank you very much for the advice. I look to the VP built-in help and I see tlist, tstringlist. No sample with how to work vith them.
Wich of them should I use?
Can it be used to handle more than 3 different lists in same runtime ?
Wich is the max number of items in list? word? integer? longint? bigger?
I am asking because I see it is also in FP, poorly documented.
In FP, tstring or tlist seem to support only one instance per runtime. Two instances share same elements, or it's my misunderstand ?
Can I use FP's samples for VP. Are they differently implemented ?
Do you have some simple demo with how to use?

Basically, I need more lists, with as many as possible(by RAM) number of elements with strings, ansistrings, numbers and maybe in the future records.
I've seen somewhere some creation for a new class on Delphi 1 wich was limited to 16000 elements.
Can this be used to add classes to VP?

Million thanks in advance.
tStringList and the other collection types are covered in the online help - just press Ctrl-F1. They can hold up to 2^31 items each, or around 2 billion.

In the examples\delphi\clsdemo.pas example, there are examples of how to use some of the classes.

The classes can obviously be instantiated as many times as you need: yes, you can have more than one of them in a program :)
As you suggested, I was looking to the the TObject and his descendants. The descendants I can use are string type.
I can't figure if can be used with ansistrings.
Also I see the max number of elements is maxlongint div 16 (hope not looked in the wrong place).
Because I need to work with expandable lists of longint, extended and records, I must convert the strings to what I need or there is a way to declare lists with elements other than strings ?

I solve my "urgent problem" by temporary add more RAM and swap and seem to work. Slow, noizy hdd but I make my job.

I salute your decission to repack the VP with fixes accumulated.
Is there a place for the dynamic arrays in your list ?
I think people use lists with other elements than strings.
Being able to natively use them in VP will be very appreciated.

Thank you in advance, whatever your answer might be !
As said before, dynamic arrays need compiler support, which is not within the scope of the current efforts, which is about library fixes only. Stuff that needs fundamental compiler changes is simply several magnitudes more work and difficult. (also in FPC, not just in VP)
The current effort is to include the (numerous) fixes that people have done to the RTL since the last release, and fix a couple of small bugs.

It is not possible to add dynamic arrays to the list of VP features, I am afraid.

I think you should consider extending your knowledge of programming though... of course people will want lists of things other than strings, and there are a bunch of features to allow just that already. You can either use classes or objects (which requires knowledge of object-oriented programming: very useful!) or you can just use dynamically sized arrays by manually allocating them on the heap.

Or you can combine the two, to encapsulate your dynamically sized list in an object. It's really quite easy, but it's something you have to do in order to understand how it works and what the shortcomings are (constructing objects, making sure they are destroyed properly, etc)

Again, the feature that allows you to declare "x: array of integer;" will not make it in this or any future version of VP...
Contacted the FPC lists, received replies from some of the devellopers.
My intuition was correct.
The IDE is not improved anymore and they don't know better alternative IDE.
They only update and fix the integrated compiler and debugger the last contributor plugged in the IDE.
The main activity is around the compiller wich is very used by Lazarus project.
About the IDE the enthousiasm is much lower than here.
Until someone with dedication get involved FPC IDE remain in the actual functionality.

The problem I have seem to have more chances to be solved in the VP team as an rtl/class/whatever fix/addon.
You, here are my last chance.
If not, lucky as I am, I will migrate to another slowly abbandoned project (I am talking about the FPC IDE).
Is there a solution?
Some of the sources from FPC can be adjusted slowly to work with VP ? Just to stay more up to date, at least in the important features ?
> Is there a solution?

Start working. The problem is that everybody that is interested is waiting for something to happen.


© 2022   Created by Allan Mertner.   Powered by

Report an Issue  |  Terms of Service