Giter Club home page Giter Club logo

jsforth's People

Contributors

brendanator avatar petermortensen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsforth's Issues

JavaScript Strings in Interop

I am attempting to figure out how to convert a counted string (such as from using s" in a definition) into a JavaScript string so that I can call external JavaScript functions that require strings as input. However, I cannot seem to get it working. Here is what I am trying to do:

: test123 s" statusTarget" ;
statusTarget is the ID of an element on the DOM in my test page

test123
Two numbers are now on the stack, representing the counted string

js /document.getElementById{2}
This pops TOS and NOS, but only returns null (where it should have returned something relating to the found element).

I have checked that document.getElementById('statusText') works in the console, however I cannot manage to get the JS interop code to do the same thing. Browsing through js-interop.js seems to indicate that there isn't currently a function to do this conversion, as there are no examples of how to this in the comments at the top. Other JS functions seem to work as long as they only take numbers as input.

I would have attempted to implement this myself, but I cannot yet figure out how strings are stored in Forth's virtual memory, so I am a bit lost (the address on the stack is always some large negative number). Am I overlooking something or is this not yet implemented?

P.S. Great code by the way! jsForth works really well otherwise.

non-destructive display of stack

It would be nice if the ".s" command was supported in the browser interpreter so that we could look at the stuff in the stack without deleting it.

S" doesn't work like in other forths

Hey @brendanator

First off - your Forth rocks! ๐Ÿ˜Ž I've played with building Forths for numerous platforms, and I've enjoyed playing with a lot of pre-existing Forths too. For people like me who don't get how the whole "threading" thing works, creating a full ANS Forth is nothing short of incredible. Very, very cool!

Having said that, I've kinda got two issues in one here:

  1. The main issue - the only one that's really an issue per se - is that S" doesn't put the pointer and length on the stack... at least, not in the demo page. For example, if I'm in Gforth, and I type s" Forth" .s, I'll get output like 1234567 5 (the 5 being the length of the word "Forth" and the other number being a pointer to the string in memory). That's not happening here.
  2. This may (and probably should, sorry) be a separate issue, but how would strings work with JS interop? It could be you hve an example somewhere and I just haven't seen it yet, but my first thought was something like s" Message here" /js alert{1} and it would show an alert("Message here"). If you need some tutorials, I'd be happy to contribute those once I know what the heck I'm doing. ๐Ÿ˜†

Anyway, thanks again for the awesome #Forth ! I can't wait to wire this up to something like xterm.js, build a nice little API of words around a canvas, and doo all kinds of crazy fun stuff with this thing. ๐Ÿ˜ƒ

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.