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

Add lists:append/1 and lists:append/2. #1548

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

migmatore
Copy link
Contributor

These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

Copy link
Collaborator

@bettio bettio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looked legit, but somehow CI is failing.

Copy link
Collaborator

@UncleGrumpy UncleGrumpy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment in the code where the documentation is failing to build.

Copy link
Collaborator

@UncleGrumpy UncleGrumpy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple mistakes in the tests.

@migmatore
Copy link
Contributor Author

Looks like I fixed everything. Waiting for CI.

Copy link
Collaborator

@UncleGrumpy UncleGrumpy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was only the second exception that needed to be changed.

@migmatore
Copy link
Contributor Author

It looks like I still have to remove ?ASSERT_ERROR(lists:append(1, 3), badarg) or add the lists:append/2 function to successfully complete CI.

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Feb 18, 2025

It looks like you found a discrepancy between AtomVM an OTP. Your test now passes on the BEAM, but fails on AtomVM. OTP is raising a badarg for lists:append(1, 3) but AtomVM is raising undef.

@migmatore
Copy link
Contributor Author

I'll try adding lists:append/2 to this commit, I think it will fix it. Because it looks like BEAM gives badarg error, since the append/2 function is implemented there.

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Feb 18, 2025

I'll try adding lists:append/2 to this commit, I think it will fix it. Because it looks like BEAM gives badarg error, since the append/2 function is implemented there.

Good catch, I should have realized that was the difference here. You could check the return conditionality based on the return of erlang:system_info(machine). OTP will return "BEAM" and AtomVM will return "ATOM".

@UncleGrumpy
Copy link
Collaborator

But lists:append/2 might be a good compliment to this addition anyway.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

Signed-off-by: migmatore <[email protected]>
@migmatore migmatore changed the title Add lists:append/1. Add lists:append/1 and lists:append/2. Feb 18, 2025
@migmatore
Copy link
Contributor Author

migmatore commented Feb 18, 2025

I also think I need to add these functions to List.ex? And maybe the elixir files should be named using snake_case, right? Well, at least that's what the elixir documentation says about Naming conventions, although it's not necessary. If there is an opportunity and there are no restrictions, I could do it.

Copy link
Collaborator

@UncleGrumpy UncleGrumpy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Those last few tests that failed and not related to your changes. This looks ready to merge.

@UncleGrumpy
Copy link
Collaborator

I also think I need to add these functions to List.ex? And maybe the elixir files should be named using snake_case, right? Well, at least that's what the elixir documentation says about Naming conventions, although it's not necessary. If there is an opportunity and there are no restrictions, I could do it.

As far as I can tell Elixir does not have List.append/1,2, I think this is normally accomplished with ++, but regardless, it can be left for a future PR.

@migmatore
Copy link
Contributor Author

As far as I can tell Elixir does not have List.append/1,2, I think this is normally accomplished with ++, but regardless, it can be left for a future PR.

Yes, exactly... for some reason it seemed to me that there are such functions, but okay :)

@bettio bettio merged commit 8d71042 into atomvm:main Feb 18, 2025
83 checks passed
@migmatore migmatore deleted the add_lists_append branch February 18, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants