Code Monkey home page Code Monkey logo

Comments (4)

Hackerpilot avatar Hackerpilot commented on May 27, 2024

I think this was caused by attribute inferrence not working on the various functions in HashMap. The problem is that the @nogc-ness of the HashMap depends on the hash function also being @nogc.

from containers.

Stretto avatar Stretto commented on May 27, 2024

One can get around @nogc attributes by casting. Making the hash function(s) predicates with defaulting to the built in types might be the way to go?

from containers.

mleise avatar mleise commented on May 27, 2024

Druntime should offer @nogc hashing for basic types. Structs and classes will work if they implement toHash() @nogc. Also all the container methods using hashes like insert(Key, Value) would have to become templates for attribute inference to kick in.
I've just hit the same issues when implementing a hash table. For now I'll use a separate hashOf() function that reimplements hashing of basic types.

@Stretto Predicates for the hash function are a good idea. It is just not quite so obvious to have as the less comparator in sorted lists. There may be many ways in which one thing is greater than another, but typically only one way it equals another.

from containers.

CyberShadow avatar CyberShadow commented on May 27, 2024

I don't think this is practical right now in D. We need to select the attributes (with/without @nogc) depending on the allocator and the supportGC parameter, which is currently doable only by duplicating all function declarations. Inference for template functions is usable but only for methods and not e.g. destructors.

from containers.

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.