GithubHelp home page GithubHelp logo

Comments (3)

1bardesign avatar 1bardesign commented on July 19, 2024

At the moment it's mostly indecisiveness on how to integrate it with class - I'm not sure if something should be exposed per-class for allowing reflection on types. Reflection in general is something I'm not super hot on but in the absence of proper types in lua it's more or less what we're "stuck with".

I don't mind the idea of class:type() just returning class.__type.
I'm not sure how standard it is or what the rules are around __ prefix table members. Likely doesn't matter though as we're more or less "stuck with" luajit in love land.

On the performance front, having it as a method basically involves an extra function call over just a property access, which isn't great but ultimately unlikely to matter as you're rarely doing this in an ultra-performance-sensitive environment, and having the __type member would allow an escape hatch.
The tradeoff is more complicated in a JIT context too, haha - if the method was inlined it could end up faster than a property access in some situations.

I'll think about it. I can see merit to keeping familiarity with love users, but I think probably something needs to be added to class to facilitate it being standard.

from batteries.

flamendless avatar flamendless commented on July 19, 2024

Okay I understand.

It was just a hardship earlier tracking why calling pos.type() errors haha.

from batteries.

1bardesign avatar 1bardesign commented on July 19, 2024

fixed in the recent class overhaul; :type() works for all classes (same syntax as love userdata so you don't need to typecheck even more ahead of time)

from batteries.

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.