Code Monkey home page Code Monkey logo

Comments (2)

ajwfrost avatar ajwfrost commented on July 19, 2024

Just to clarify what you mean, you would like to be able to have something like:

public class Map
{
    public function set(key:*, value:*) : void
    {
        // stuff
    }
}

I think the compiler might be challenged to differentiate that from:

public class Map
{
    public function set myval(key:*, value:*) : void
    {
        // stuff
    }
}

which is a property setter..

Is there any reason you couldn't use capitalised versions or something to differentiate it from the reserved words? I'd be a little hesitant about changing those kinds of things..

thanks

from adobe-runtime-support.

ylazy avatar ylazy commented on July 19, 2024

Yes, that's exactly what I mean. I'm also want to use some other reserved keywords like break, continue, default...
The reason is, in some case I think they're the best names to use.
In above example, I just want my classes (Map/Set) to have same API compared to JavaScript, so anyone that familiar with javascript can use my lib right away.
Set.delete()
Map.delete()
Map.get()
Map.set()

Another example, I have a class AsyncLoop that can construct something like for loop. It can handle multiple items need to be loaded/processed asynchronously. And I need some functions called break, continue to break/continue the async loops.

I'm also building some library that use command line processes. The command line APIs have flags/switches named include, default... And I want to use them as property names.

In some programing languages, there're ways to use reserved names. For example in C# I can use the @ prefix.

Back to your example, I think it's quite easy to distinguish:

public class Map
{
    public function set(key:*, value:*) : void
    {
        // if there's nothing after set, so set is the function name
    }
}
public class Map
{
    public function set myval(key:*, value:*) : void
    {
        // there's something after set (myval), so set is a keyword
    }
}

from adobe-runtime-support.

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.