GithubHelp home page GithubHelp logo

Comments (7)

dicarlo2 avatar dicarlo2 commented on June 12, 2024

Also would need to implement it for the enumerator/iterator wrappers in neo core.

from neo-vm.

dicarlo2 avatar dicarlo2 commented on June 12, 2024

Alternatively, just move the implementation of GetHashCode to the primitive types.

from neo-vm.

dicarlo2 avatar dicarlo2 commented on June 12, 2024

I would also recommend making sure Equals is implemented for all things that can be InteropInterface, e.g. all of the state classes

from neo-vm.

erikzhang avatar erikzhang commented on June 12, 2024

Is there a specific scenario that you need this for?

In JavaScript, an array is serialized as a string as a key.

var a = [1, 2];
var o = {};
o[a] = 100;
alert(o["1,2"]);

So I don't see why it is necessary to implement these.

from neo-vm.

dicarlo2 avatar dicarlo2 commented on June 12, 2024

JavaScript also has a Map class that we've implemented in neo-one which is supposed to function the same as the C# equivalent assuming no custom hash code or equals implementation - that is, references may be used as keys. E.g.

const a = new Map();
const b = [1, 2];
a.set(b, 'hello');
console.log(a.get([1, 2])) // -> undefined
console.log(a.get(b)) // -> 'hello'

from neo-vm.

erikzhang avatar erikzhang commented on June 12, 2024

I think it is still impossible to implement a JavaScript Map.

console.log(a.get([1, 2])) // -> undefined

This line returns an undefined, but in NeoVM it throws an exception.

if (!map.TryGetValue(key, out item))
{
State |= VMState.FAULT;
return;
}

from neo-vm.

dicarlo2 avatar dicarlo2 commented on June 12, 2024

@erikzhang we check if the map has the key before calling pickitem so that we have a chance to return undefined. This is blocking NEO-ONE TypeScript smart contracts, can we revisit implementing this?

from neo-vm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.