Giter Club home page Giter Club logo

Comments (5)

AArnott avatar AArnott commented on July 21, 2024 1

Looking at HANDLE, I see it already has a static Null property and an instance IsNull property.
Now, HANDLE has an IntPtr field, and your subject line suggests you want this for nint typedef structs. But nint isn't necessarily a handle or pointer, so 'null' isn't a concept that directly applies to it.
Are there structs that are backed by nint that should rather be treated like handles (thus backing with IntPtr)? Can you name some so I can look into it?

Yes, yes, I know that syntactically IntPtr and nint is nearly identical nowadays. But IMO it's useful to maintain the semantic distinction.

from cswin32.

elachlan avatar elachlan commented on July 21, 2024 1

I think I am repeating myself without realizing I think we looked into it in #610.

Examples:

  • HIMC
  • HKL

I think we closed it previously because we wanted to be sure something was a handle vs just a pointer. So anything that was annotated as a handle already has the IsNull property.

from cswin32.

jnm2 avatar jnm2 commented on July 21, 2024 1

Yes, yes, I know that syntactically IntPtr and nint is nearly identical nowadays. But IMO it's useful to maintain the semantic distinction.

This came up in the #csharp-lang-design channel in https://aka.ms/dotnet-discord. When some of us were making this point about a semantic distinction, one of the language design team members said:

No, it's literally not a meaningful distinction. It will be normalized for display. It's like int vs Int32.

(https://discord.com/channels/732297728826277939/732297994699014164/1104796983761322105)

from cswin32.

AArnott avatar AArnott commented on July 21, 2024 1

Thanks for sharing, @jnm2. I guess I'll just have to accept that.

Still, if we can tell from the metadata that a one typedef struct represents a pointer and another doesn't, I think it's fair to use that as an indicator to add IsNull in one case and not in another.
After all, a handle could legitimately be 0 and still be valid, while a pointer couldn't be 0 and valid. So adding IsNull in both cases could lead to misuse as code assumes IsNull means it isn't valid, but for an opaque handle type, that isn't true.

from cswin32.

AArnott avatar AArnott commented on July 21, 2024

Duplicate of #610.

from cswin32.

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.