Giter VIP home page Giter VIP logo

Comments (10)

Akuli avatar Akuli commented on September 3, 2024 1

It seems that everyone is happy with public. I will use it when I eventually get around to implementing this :)

from jou.

Akuli avatar Akuli commented on September 3, 2024 1

How about a decorator?

@public
def add(x: int, y: int) -> int:
    return x + y

from jou.

littlewhitecloud avatar littlewhitecloud commented on September 3, 2024

I think on the contrary, you can use the "extern" keyword to decide which functions need to be exported.
Then other variables, functions, structs of the current file will not be accessed.And then, they will be private

from jou.

littlewhitecloud avatar littlewhitecloud commented on September 3, 2024
def internal_util_function() -> int:
    return 123

static struct PrivateStruct:
    x: int
    y: int

extern def public_function() -> int:
    return internal_util_function() * 2

extern struct PublicStruct:
    message: byte*
    line: int

from jou.

Akuli avatar Akuli commented on September 3, 2024

I think on the contrary, you can use the "extern" keyword to decide which functions need to be exported. Then other variables, functions, structs of the current file will not be accessed.And then, they will be private

So basically, everything is private by default, and you can use a keyword like extern to make public things. This seems like a good idea.

I think I will probably name the keyword public instead of extern, for two reasons:

  • With extern many people would think: "what does the extern keyword do again? Ah now I remember, it makes the thing public."
  • The extern keyword has a different meaning in C. Jou's declare and C's extern both correspond to the same idea: they tell the linker that something exists without defining it.

from jou.

Akuli avatar Akuli commented on September 3, 2024

More possible keywords to use for this:

  • export, same as in JavaScript
  • pub, same as in Rust

from jou.

Akuli avatar Akuli commented on September 3, 2024
  • I think I don't like export, because it would get confused with __declspec(DLLEXPORT) in windows.
  • pub is a bit too short considering Jou's goals: we need readability.

from jou.

sumeshir26 avatar sumeshir26 commented on September 3, 2024

I think global or public will be the most clear

from jou.

Moosems avatar Moosems commented on September 3, 2024

public looks fine to me. I understood extern just fine and would be a little disappointed if someone couldn't deduce its meaning.

from jou.

Moosems avatar Moosems commented on September 3, 2024

I like that, but if it isn't written in Jou that would feel a bit too automagic-y for a decorator.

from jou.

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.