❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayAda: When the software HAS to work

Overthinking “new”: Types vs Records


When I declare a record in the heap I use:

declare type my_record is record: my_var : Integer; end record; type my_record_access_type is access my_record; record_1 : my_record_access_type; record_2 : my_record_access_type; begin record_1 := new my_record; record_1.my_var := 1; record_2 := record_1 record_2.my_var := 2; end 

So here’s what we did: - Declare a record with one variable, my_var of type integer. - Declare an access type that will point to the type, my_record. In my brain this is like saying “Declare an array filled with integers” except here we’re saying “declare an access type that is filled with the necessary information to access my_record(s)” - Declare two instances of this access type - Begin - Instantiate the first record we declared. Because we use “new”, it will do it on the heap. - set the variable in the record to 1; - make a reference of record_1 and save it in record_2. Since record_1 is an access type, record_2 is only a second name (alias) for record 1. - change the value of the variable in the record (the one and only record with two names) from 1 to 2. - end

Is that correct?

Secondly, I see multiple ways to make new types:

package types is type distance1 is new Float; type distance2 is range 0..100; — No new because range? type distance is Integer; — why no new here? end types 

Clearly the type creation “new” is different than the object creation new. However, the nuance of when to use “new” in type creation eludes me.

Would someone please provide some guidance?

I’m familiar and comfortable with C++ if using an analogy is helpful and appropriate.

submitted by /u/Exosvs
[link] [comments]

AdaCV - OpenCV but Ada

Hi everyone,

Long time lurker, first time poster. After a few years in Python and short, unhappy tread through the chaos of C++, I'm learning Ada, while I'm still new to the language, I have a project idea. I want to make sure I don't reinvent the wheel and that I engage with anyone else who is interested.

Are you familiar with OpenCV? If not, it’s a very good computer vision library in C++ and Python.

Well I have a several years experience with it in both C++ and Python (and the science/math directly). My interpretation is that, while the basics can be easy to use, the more complicated functions (Stereo Calibration, triangulation, really anything with photogrammetry) are nuanced and somewhat unforgiving. A lot of it is driven by poor examples and the poor documentation on what you're actually getting. For example, it doesnt talk about what units is a particular return value is in? Distance units or a some normalized unit? What's expected as the input? A vector of vectors of a custom cv::Point2f two dimension float type. Stack overflow is filled with questions where people don’t get much help and their answers are met more with theory photogrammetry and I never see actual usage help or answers. It's just like the documentation: theory heavy, usage thin, typing vague. A more… user friendly library with thorough usage documentation would be very popular if it was genuinely easy to use.

I’m sure you see where this is going but please let me finish:

Ada is the language of reliability and safety. Look at the popular and booming Tech industries, two relevant highlights are Autonomous Vehicles and Augmented Reality. Both use imaging processing and photogrammetric techniques. If an ADA based package or library that was easily usable and accurate, while having the reliability and safety of ADA, it could bring a lot of new people, companies, and industries to the language.

So anyways, the idea is AdaCV. A potentially slimmer but more easily usable and user friendly OpenCV in Ada.

Anyone working on that? Anyone finished it? Thoughts? Objections?

submitted by /u/Exosvs
[link] [comments]