GithubHelp home page GithubHelp logo

range issue? about rapydscript-ng HOT 16 CLOSED

kovidgoyal avatar kovidgoyal commented on May 29, 2024
range issue?

from rapydscript-ng.

Comments (16)

kovidgoyal avatar kovidgoyal commented on May 29, 2024

Well the problem is that in python3 range() does not actually give a standard iterator, but a special object that apparently restarts after reaching the end, and has some special methods, like count() and index(). I suppose one could implement this in rs-ng as well.

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

I believe that originally in CPython range(N) actually produced a list of length N. This has obvious disadvantages, but it would be a simple implementation while considering a more elegant solution (maybe this is what RS does, since it works there). In any case, this does seem a rather significant departure from CPython, and an unexpected one, so it would be great if you see a way to implement it.

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 29, 2024

Sure, I'm not saying it should not be fixed. It will just be a little while before I can get to it. In the meantime, you can always change the implementation of range in baselib-builtins.pyj for yourself to use an array.

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

I tried the obvious changes, namely to replace the RS_range function in the run-time package and in the in-browser compiler, to construct a list, but then compiling doesn't work at all. I see that the range function is used for various purposes in the in-browser compiler, so maybe that's why I can't make the change?

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 29, 2024

I've already fixed this.

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

That's terrific (you're incredibly responsive!), but how do I recreate the in-browser compiler, which is still 0.7.11? The only way I know to get a new in-browser compiler is to go to

https://kovidgoyal.github.io/rapydscript/repl/rapydscript.js

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 29, 2024

How to build the embedded compiler is documented in the readme

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

I really appreciate the documentation you provide on installing etc. Many repositories provide little such information.

I had been using "npm install rapydscript-ng" followed by executing "rapydscript --bare input.py > runtime.js", where input.py just contains "a = 1", then deleting the last few lines, as you had explsined, and I obtained the mebedded compiler from kovidgoyal.github.io/rapydscript/repl/rapydscript.js. However, following that procedure didn't get me the changes to range(), so I built from source (on my Mac; bin/web-repl-export fails on my primary machine, a Windows 10 desktop). I'm curious:

  1. What triggers an update to kovidgoyal.github.io/rapydscript/repl/rapydscript.js?

  2. Under what circumstances will "npm install rapydscript-ng" not pick up the latest state of the repository?

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 29, 2024
  1. a version bump

  2. whenever there have been commits after the last version bump

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

Thanks.

When I built yesterday from source, I assumed that dev/baselib-plain-pretty.js would be the runtime file I needed (previously I ran rapydscript on "a=1" as you had explained to me). What I found was that the following preamble was missing from the start of dev/baselib-plain-pretty.js:

var ρσ_iterator_symbol = (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") ? Symbol.iterator : "iterator-Symbol-5d0927e5554349048cf0e3762a228256";
var ρσ_kwargs_symbol = (typeof Symbol === "function") ? Symbol("kwargs-object") : "kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256";
var ρσ_cond_temp, ρσ_expr_temp, ρσ_last_exception;
var ρσ_object_counter = 0;
var ρσ_len;

Is there some other file obtainable when working with the source that includes these essential definitions? Or should I have again run rapydscript on "a=1"?

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 29, 2024

To generate rapydscript.js just do:

./build
./bin/web-repl-export out

File is out/rapydscript.js

In any case I have updated the online one manually, so you can just use that.

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

I did run web-repl-export and picked up embedded_compiler/rapydscript.js. That's not the issue; the issue was how to construct the runtime library. I made the guess that it would be dev/baselib-plain-pretty.js, but in fact that file doesn't define ρσ_iterator_symbol, etc. Those five lines are the only pieces missing from using dev/baselib-plain-pretty.js as the runtime library.

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 29, 2024

Oh sorry (I've been rather swamped because I just released a new project to the public https://github.com/kovidgoyal/kitty so I did not pay as much attention as I should have) -- yeah you need to do the run trick again.

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

I found that I didn't understand how to "do the run trick" when working with the source. If I execute "rapydscript --bare input.py > runtime.js" I don't get the most recent changes. Presumably I need to use not "rapydscript" but dev/compiler.js, but I couldn't figure out in the node environment what command to issue.

from rapydscript-ng.

kovidgoyal avatar kovidgoyal commented on May 29, 2024

First uninstall any previous rapydscript you have installed with npm. Then run

git clone git://github.com/kovidgoyal/rapydscript-ng.git
cd rapydscript-ng
sudo npm link .  # this will link the rapydscript executable to the current dir
npm install  # This will automatically install the dependencies for RapydScript

from rapydscript-ng.

BruceSherwood avatar BruceSherwood commented on May 29, 2024

I'll try again, but I've always installed rapydscript locally, in its own initially empty directory. After executing the four statements you quote, my experience was that "rapydscript --bare input.py > runtime.js" didn't get the most recent changes, which is why I thought I had to invoke rapydscript a different way, maybe invoking the compiler in dev.

from rapydscript-ng.

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.