Coder Social home page Coder Social logo

Comments (3)

zerbina avatar zerbina commented on August 30, 2024

This is a general problem not strictly related to void. Generic parameters are ignored when comparing routine signatures for the purpose of disallowing re-definitions (refer to searchForProcAux). For example:

proc test[T: int]() = discard
proc test[T: float]() = discard
# error: re-definition of test

proc test2[T: int](): T = discard
proc test2[T: float](): T = discard
# error: would lead to ambiguous calls

from nimskull.

saem avatar saem commented on August 30, 2024

I think discriminating based on generic parameter constraint types is reasonable, but looking for more input on that as well. Does it make sense that we differentiate based on generic parameters, in some fashion?


Assuming the above is true, then my mind turns to more practical concerns wrt implementation. I'm not sure if the current implementation can handle the weirder cases all that well, such as those involving type operations e.g.:

proc test[T: int]() = discard
proc test[T: float or int and not int]() = discard

proc test2[T: int](): T = discard
proc test2[T: float or int and not int](): T = discard

Perhaps we could start by swapping generic parameters for their constraints when considering signatures, that would mean test would still result in a redefinition, as no parameters would take the constraints of their respective T, and test2 would now work. At least the test scenario veers into the whole aliases vs phantom types (branding).

from nimskull.

disruptek avatar disruptek commented on August 30, 2024

I would feel better about the branding situation if I could figure out how to .borrow. distinct generics. I mean, I know that's already two sides of the pentagram of pain, but still...

from nimskull.

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.