Giter Club home page Giter Club logo

Comments (3)

mewmew avatar mewmew commented on May 26, 2024

Just want to question a4f2487. Is there a good rationale for it? One rule I try to abide by is "only have one name for a thing, to the extent it is possible". So it should be type Func xor func NewFunction.

I'd say it's a good rule in general. The reason really is that we will end up typing ir.NewFunc quite often, and thus making it shorter makes it more pleasant to use. This is analogous to the func keyword in Go.

As for having the same name for the type as the construction, sure. We already have another case where the constructor is an abbreviated version of the type name, ir.NewBlock returning *ir.BasicBlock.

There are also two constructors where the name does not match, but that is by design. ir.NewGlobalDecl and ir.NewGlobalDef both return *ir.Global.

from llvm.

mewmew avatar mewmew commented on May 26, 2024

I think I'm starting to lean more towards your suggestion, to make consistent use of one name throughout. I'd therefore like to get this in place before tagging the final v0.3 release.

The two primary API changes are as follows:

  • rename type Function to type Func
  • rename type BasicBlock to type Block
  • rename func NewGlobalDecl to func NewGlobal
    • keep func NewGlobalDef as a more specialized constructor for creating global variable definitions. It is also possible to use the Init field directly, e.g. g := ir.NewGlobal("foo", types.I32); g.Init = constant.NewInt(types.I32, 42)

If we find any other inconsistent use of naming, lets add it to this issue.

from llvm.

mewmew avatar mewmew commented on May 26, 2024

I think we can close this issue as the constructor and type names are now consistent. If we find any others, we can simply re-open it later. Thanks for reporting it @pwaller!

from llvm.

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.