Code Monkey home page Code Monkey logo

Comments (2)

atsepkov avatar atsepkov commented on July 20, 2024

Part of the problem is duck-typing nature of JS/RS. Just because you see a.split() in the code, doesn't mean you're dealing with a string. In that context a could be a string, or some class named Loot that you're splitting with a friend. Compiler needs more information to do this operation without screwing things up for developers. There is no reason, however, stdlib can't overload String in this way (there are two versions of stdlib, one that modifies string, another creates a new class that inherits from it - the 2nd is less destructive but you'll have to declare strings as str('hello world')).

from rapydscript.

kovidgoyal avatar kovidgoyal commented on July 20, 2024
  1. Is implemented in my fork, you can do str.split(a) and the same for all python's builtin string functions including format()
  2. @atsepkov the way to do this, is to create a new access operator for compile time function mangling. So the compiler would translate

a->split() to str.split(a)

And the compiler can maintain an internal list of all such functions to be overriden.

However, I am not convinced that 2 is really worth it. It saves only two characters of typing, at the cost of adding a new operator.

from rapydscript.

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.