Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement Quantity values #1165

Merged
merged 1,005 commits into from
Jun 12, 2023
Merged

Re-implement Quantity values #1165

merged 1,005 commits into from
Jun 12, 2023

Conversation

drkameleon
Copy link
Collaborator

@drkameleon drkameleon commented Apr 20, 2023

Description

Quantity values - albeit a relatively new feature in Arturo - is a rather interesting feature, that could potentially give the language an edge and allow its use in different sectors (e.g. scientific calculations, engineering, etc).

That being said, there are already a few pending issues (mostly regarding the operations between different quantities/etc), which is anything but bulletproof (at least so far).

The goals of this PR:

(*that I've been preparing for at least the past 2 weeks, writing and re-writing and re-writing)

  • Re-implement the Quantity value type from scratch
  • Add better core unit support
  • Make quantities and units Dimension-aware
  • Allow for more complex unit expression (with compound units, etc)
  • Make operation rules less rigid when we don't have to be too strict, and make them stricter in case the operation shouldn't be allowed

Stretch goal

  • Allow the user to optionally define his own units

Other changes

(*Most of them directly derived from the above - or at least very relevant)


πŸ’¬ Discussion: @ #1144

πŸ‘€ Also see: 1, 2 & 3


Fixes

Fixes: #1004
Fixes: #1110
Fixes: #1131

Type of change

  • Code cleanup
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

@drkameleon drkameleon added enhancement New feature or request cleanup Code cleanup, comments and micro-optimizations values Issues related to the core Value type new feature New feature/addition labels Apr 20, 2023
@github-actions github-actions bot added ast Issues related to the intermediate AST representation documentation Improvements or additions to documentation helpers Issues related to Helper modules library Issues related to the standard library parser Issues related to the evaluator (src/vm/parse.nim) rosetta code Issues and PRs related to Rosetta Code snippets unit-test Unit tests values Issues related to the core Value type vm Issues related to the Virtual Machine implementation and removed values Issues related to the core Value type labels Apr 20, 2023
@drkameleon
Copy link
Collaborator Author

@RickBarretto I keep testing and testing (and testing...) and I'm at the stage where I keep hitting unit-test issues. I cannot imagine what would have happened if you hadn't done it so thoroughly (especially the Arithmetics-related tests). Pure awesomeness! πŸ˜‰

@celtic-coder
Copy link

@RickBarretto I keep testing and testing (and testing...) and I'm at the stage where I keep hitting unit-test issues. I cannot imagine what would have happened if you hadn't done it so thoroughly (especially the Arithmetics-related tests). Pure awesomeness! πŸ˜‰

In a galaxy far, far away, I once worked for a major software company, where the team of which I was a part, supported over 20k developers. It was our job to keep the servers and the software that they used on a daily basis, in smooth running order. You can't imagine the amount of testing that went on. And despite all of this, there were still bugs! 😒

As a former database developer, I am a huge fan of unit tests. And in my own case, I used to unit-test the unit-tests! (Well, almost!). Developing software of any kind requires certain specific skills. Writing good tests requires an allied list of skills, which, unfortunately, are in short supply.

So, as @drkameleon has said: great work @RickBarretto!

@RickBarretto
Copy link
Collaborator

RickBarretto commented Apr 27, 2023

I cannot imagine what would have happened if you hadn't done it so thoroughly (especially the Arithmetics-related tests). Pure awesomeness! πŸ˜‰

@drkameleon, Appreciated! πŸ™‚

I once worked for a major software company, where the team of which I was a part, supported over 20k developers

@celtic-coder, WOW! I can imagine this!
Unit tests are really important for software development, you spend some hours to implement them, but it can save thousands and thousands of hours to solve new bugs that had already been solved. I have an idea that there is more of this in your area, database management is a crucial area that can spend not only working hours to solve problems, but also money. If you lose or corrupt some customer's data, the company will lose (a lot of, sometimes) money.

src/vm/values/custom/vquantity.nim Show resolved Hide resolved
src/vm/values/custom/vquantity.nim Outdated Show resolved Hide resolved
src/vm/values/custom/vquantity.nim Outdated Show resolved Hide resolved
src/vm/parse.nim Outdated Show resolved Hide resolved
src/vm/parse.nim Outdated Show resolved Hide resolved
src/vm/values/printable.nim Outdated Show resolved Hide resolved
src/vm/values/printable.nim Outdated Show resolved Hide resolved
src/vm/values/printable.nim Outdated Show resolved Hide resolved
src/vm/values/printable.nim Outdated Show resolved Hide resolved
src/vm/values/printable.nim Outdated Show resolved Hide resolved
@drkameleon
Copy link
Collaborator Author

drkameleon commented Apr 29, 2023

First successfully-building version! πŸŽ‰

(*There must be tons of stuff to be fixed & there are a couple of cases where I simply commented-out code to make it go forward - since the updated implementations would probably take some time - but we're definitely getting there; slowly but... surely!)

@drkameleon drkameleon marked this pull request as ready for review June 6, 2023 14:47
@RickBarretto
Copy link
Collaborator

πŸ‘€πŸ‘€πŸ‘€

It's not a draft anymore and all checks have passed...
Excited for this PR! πŸ”₯

@drkameleon
Copy link
Collaborator Author

πŸ‘€πŸ‘€πŸ‘€

It's not a draft anymore and all checks have passed... Excited for this PR! πŸ”₯

Totally accurate!

It took me some time to revise everything and - at least - make it compile but we're definitely getting closer! :)

Now, I'll have to double-check everything, clean up any leftovers, write some tests and we're quite ready to go! πŸš€

@drkameleon
Copy link
Collaborator Author

So... after close to 2 months, as we were saying with @RickBarretto, I think it's time to finally merge this to the main branch, so that we can work on it, step-by-step, and on a per-issue basis, rather than keep bloating this PR again and again, until it becomes an unmanageable mess. (Is it 100% perfect? It's not. But then, nothing is...)

And, of course, I'll take the time to open as many issues as possible so that we can start ironing things out. πŸ˜‰

That being said...

πŸ₯ πŸ₯ πŸ₯

...ready to merge! πŸš€

@drkameleon drkameleon merged commit 8938ff7 into master Jun 12, 2023
12 checks passed
@RickBarretto
Copy link
Collaborator

RickBarretto commented Jun 12, 2023

Awesome work! @drkameleon .
These PR's features already are one of my favorites.

I had the chance to play with that before the merge, as you ask me for it. And... Everything have been fan-tas-tic!

Now, let's get things happen and see how it will behavior with the time.

Again, awesome work as always!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Issues related to the intermediate AST representation ci CI-related issues cleanup Code cleanup, comments and micro-optimizations documentation Improvements or additions to documentation enhancement New feature or request helpers Issues related to Helper modules library Issues related to the standard library new feature New feature/addition parser Issues related to the evaluator (src/vm/parse.nim) rosetta code Issues and PRs related to Rosetta Code snippets unit-test Unit tests values Issues related to the core Value type vm Issues related to the Virtual Machine implementation workflows Issues related to GitHub workflows, building, releases, etc
Projects
None yet
3 participants