Giter Club home page Giter Club logo

Comments (8)

gabrieldemarmiesse avatar gabrieldemarmiesse commented on May 27, 2024 2

@msaelices it's ongoing changes, you can take a look at #2335

from mojo.

YichengDWu avatar YichengDWu commented on May 27, 2024

I propose to use 'NTuple[2, Int]' as the type alias for 'Tuple[Int, Int]', and 'NTuple[N, T]' in general, so that it can be easily dispatch on 'N'.

from mojo.

JoeLoser avatar JoeLoser commented on May 27, 2024

I propose to use 'NTuple[2, Int]' as the type alias for 'Tuple[Int, Int]', and 'NTuple[N, T]' in general, so that it can be easily dispatch on 'N'.

Can you elaborate on the value of the type alias? I'm not sure I understand the full value yet. Are there places you have in mind in the library that would benefit from this?

from mojo.

YichengDWu avatar YichengDWu commented on May 27, 2024
NTuple[2, Int] = Tuple[Int, Int]
NTuple[3, Int] = Tuple[Int, Int, Int]

Or In general I should be able to write

alias NTuple[N, T] = Tuple[VariadicPack[T, N]]

Then I can dispatch on NTuple[5,Int] instead of Tuple[Int, Int, Int, Int ,Int], it's just shorter.

from mojo.

artemiogr97 avatar artemiogr97 commented on May 27, 2024

@JoeLoser while working on this I found a potential issue, StaticIntTuple is imported in builtin/int.mojo which exposes it everywhere as all builtins, is exposing stuff in this way intentional?

from mojo.

gabrieldemarmiesse avatar gabrieldemarmiesse commented on May 27, 2024

@JoeLoser while working on this I found a potential issue, StaticIntTuple is imported in builtin/int.mojo which exposes it everywhere as all builtins, is exposing stuff in this way intentional?

Maybe we should open an issue to have a new mechanism in the stdlib to define what exactly does not need import and what needs imports.

This issue has bitten me quite a few times.

EDIT: Created the issue and proposed a fix that must be implemented partly on the compiler side:

from mojo.

artemiogr97 avatar artemiogr97 commented on May 27, 2024

Seems like StaticIntTuple is used a lot in the tests, for those cases it should be possible to replace it once Tuple conforms to the Stringable trait

from mojo.

msaelices avatar msaelices commented on May 27, 2024

Off-topic: Why _divmod instead of the Python __divmod__?

from mojo.

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.