User talk:CKWG - Ada Magica

Welcome!
Welcome to Wikibooks, CKWG - Ada Magica!

 First steps tutorial Wikibooks is for collaborative development of free textbooks.

You do not need technical skills to contribute. You can easily change most books. Please introduce yourself, and let us know what interests you.

If you already contribute at other Wikimedia projects, our Wikimedia Orientation should quickly get you started. (Would you like to provide feedback on this message?)

  Getting help   Made a mistake?   Goodies, tips and tricks
 * Read the Using Wikibooks book for a friendly introduction to the project, or our help pages for more information.
 * You can get friendly help from the community in the user assistance room or our IRC channel.
 * Upload freely licensed files to Wikimedia Commons. You may request permission to upload fair use files locally. Please include author and source information and a non-free use rationale for non-free files.
 * You can restore a previously saved version.
 * Pages should follow the  naming convention.
 * Need to rename a page? Use the move tab (is available once your account is 4 days old - until then, ask for help).
 * To request a page be deleted, add to the top of the page.
 * Was a page you made deleted? Please read the deletion policy, and check the deletion log to find out why. Also check the RFD archives if applicable. You can request undeletion at WB:RFU, or ask the administrator who deleted the page.
 * Please fill in the edit summary and preview your edits before saving.
 * Sign your name on discussion pages by typing &#126;&#126;&#126;&#126;
 * User scripts can make many tasks easier. Look at the Gadgets tab of my preferences; check off the boxes for the scripts you want, and hit save!

Thanks for your contributions -- Jules (Mrjulesd) 06:55, 24 February 2022 (UTC)

Ada Memory Management
Hello, I've reverted your edits here because I could not find reliable sources that indicate that memory is not freed when an access type is out of scope. Memory is also freed when Storage_Size is defined so both versions work.

Hi, thank you for this note.

Finalization and deallocation are tricky. They are different things: Deallocation finalizes, however finalization does not deallocate, which I have learned via a mistake I made many years ago.

13.11(18/4) If Storage_Size is specified for an access type T, an implementation-defined pool P is used for the type... the storage for P is reclaimed when the master containing the declaration of the access type is left...

This states that storage is reclaimed when Storage_Size is given. I see that this does not say that storage is not reclaimed when Storage_Size is not given. However, there is the principle that only what is explicitly stated in the RM can be relied on.

To elaborate further:

You might point to (21.7/3) where Unchecked_Deallocation is called as part of the finalization of the collection of T. This paragraph does not apply because it talks of user-defined storage pools. Storage_Size defines an implementation-defined one (see above and (17)).

7.6.1(11.1/3) Each nonderived access type T has an associated collection, which is the set of objects created by allocators of T, or of types derived from T. Unchecked_Deallocation removes an object from its collection. Finalization of a collection consists of finalization of each object in the collection, in an arbitrary order.

This states that all remaining objects in the collection are finalized (but finalize does not deallocate). UD has to be called explicitly.

I hope this exegesis is convincing enough and that I did not overlook another important point. I'm by no means a language lawyer, but this is to my best knowledge.

Perhaps some notes about these facts should be added to the page in question. But this subject is so tricky I do not see how it could be explained more easily understandably.

CKWG - Ada Magica (discuss • contribs) 16:02, 25 February 2022 (UTC)

PS: Your reference "Dynamic memory allocation" is not up to date. I get "Sorry we can't find your page. Error 404" CKWG - Ada Magica (discuss • contribs) 16:11, 25 February 2022 (UTC)


 * Finalizers don't apply to scalar types such as strings, arrays and integers. They are simply popped out of the stack. Finalizers apply to classes.
 * Managing memory with pools is OK. It has advantages such as permiting allocation with different allocator functions on different memory regions. But you can also free memory for individual objects instead of destroying the entire pool. It is possible to dealocate memory with Unchecked_Dealocation but this method is unsafe. You can dealocate memory safely (using the default pool and default allocators) by declaring access types. Memory is freed like using alternate pools (your method) but they don't have to have spare unallocated space for each pool. M4t3uz (discuss • contribs) 21:53, 25 February 2022 (UTC)
 * Hm, I do not see what you are aiming at.
 * First of all: All objects are finalized when they go out of scope according to RM 7.6(1) - for many of them, this is just null.
 * Further: Strings, arrays and integers are not scalar types - at least in Ada. I can't speak for other languages.
 * So I had expected a reply wrt Ada RM. I can't make any sense out of your message wrt to Storage_Size. I insist on my post as it is - I do not see any conclusion of your post to the contrary. CKWG - Ada Magica (discuss • contribs) 09:41, 26 February 2022 (UTC)
 * Cut and paste error: Of course, integers are scalar. Other scalars: Floating point, fixed point, enumeration.
 * All others are composite - also access types (there is nothing in Ada saying there is a one-to-one correspondence between access values and addresses). Addresses are private, btw. 94.31.100.23 (discuss) 16:02, 26 February 2022 (UTC)