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 removeByIndex #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add removeByIndex #10

wants to merge 1 commit into from

Conversation

testhound
Copy link
Collaborator

This pull request fixes this issue: #2

@tobiasholt tobiasholt requested a review from Molocher February 15, 2022 07:07
throw new java.lang.IndexOutOfBoundsException();
}
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

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

In Lua, table.remove(Array, Index) doesn't support any negative index. Moreover, I find the array in lua is really tricky on some operations, for example, the length of an array with some 'nil' elements is undefined. This brings again the question:

Does this gjavac need to follow exactly all the behaviors of Lua?

To me, the purpose of building this java compiler is to ease the smart contract development on XWC for users, so it makes more sense to simplify the semantics and avoid any undefined behavior. On the other hand, it needs to make sure that the smart contract written in Java works as expected on UVM which is designed to execute Lua code.

Another example is that, the negative numbers can be used as index of array in native Lua, but is it really necessary in the smart contract? If not, why the UvmArray needs to support negative number as index? Can we just simplify the UvmArray so that it works as a normal Java Array?

Anyway, if I were the user of gjavac, I would never think of how a Lua smart contract works, all I care about is that the smart contract that I wrote in Java should work exactly as expected.

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.

2 participants