Giter Club home page Giter Club logo

Comments (9)

andymcn avatar andymcn commented on May 15, 2024

Names should be restricted to the following forms:

Foo - public type
_Foo - private type
foo - public non-type
_foo - private non-type

In particular leading double underscore or underscore followed by a digit are not allowed.

The lexer should just accept all of these and the correctness pass should verify them.

from ponyc.

sylvanc avatar sylvanc commented on May 15, 2024

What about structural types and private methods? Obviously, this isn't an issue for private fields, but for methods, there is no way to determine which package a type that has been passed as a structural type was defined in (other than with an runtime check, which isn't what we're looking for).

That means a structural type can expose private methods outside the package.

Should we disallow private methods in structural types? I'm thinking yes, we should. That way, anonymous types never expose access to class internals.

from ponyc.

sylvanc avatar sylvanc commented on May 15, 2024

I've put this in as denying private method lookup on structural types. We can revisit this later if we need to, of course.

from ponyc.

andymcn avatar andymcn commented on May 15, 2024

I agree, structural types should not have private methods. A structural type is an inteface, just like a trait, so they don't need private methods which are internal.

from ponyc.

sylvanc avatar sylvanc commented on May 15, 2024

Ok, great. Right now, it only catches that on lookup. Should we be more aggressive, and disallow it when the structural type is defined?

from ponyc.

sblessing avatar sblessing commented on May 15, 2024

I agree on this. Generally, if think type checking should always be as aggressive as possible. There is no point it seemingly allowing the declaration/definition, but then throw an error on lookup.

from ponyc.

andymcn avatar andymcn commented on May 15, 2024

We should definitely be more aggressive on this. It would be easy to check structural types (and also traits) for private methods in either the parse_fix or scope passes. Scope probably makes more sense logically.

from ponyc.

sylvanc avatar sylvanc commented on May 15, 2024

Ok sounds good. Andy, can you handle it?

from ponyc.

sylvanc avatar sylvanc commented on May 15, 2024

I handled it in the scope pass.

from ponyc.

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.