bakpakin / Fennel

Lua Lisp Language
https://fennel-lang.org
MIT License
2.45k stars 126 forks source link

Add online demo #3

Closed daurnimator closed 6 years ago

daurnimator commented 6 years ago

Easy to do with fengari.

For fun, try on https://fengari.io/: image

For those that want to copy/paste:

package.preload.fnl = loadfile("https://raw.githubusercontent.com/bakpakin/fnl/master/fnl.lua")
require "fnl".eval([[  (print 'hello, world!')  ]])
bakpakin commented 6 years ago

@daurnimator This is really awesome btw. I tried taking a poke at it, but I noticed I couldn't do io.read from standard input (there was no io table). Is there another way we turn this into a fnl repl?

technomancy commented 6 years ago

I have a WIP stash thing that lets you provide your own IO functions: fnl.repl({read=myread, write=mywrite}) which might be useful for this. I can put together a PR.

bakpakin commented 6 years ago

That sounds great, as long as we can get input from within fengari.

daurnimator commented 6 years ago

I tried taking a poke at it, but I noticed I couldn't do io.read from standard input (there was no io table)

Well yeah. In a browser io.read (which blockingly reads from stdin) doesn't really make sense: what what it read from? The only blocking primitive for input in a browser is prompt() which isn't going to be nice to use.

Is there another way we turn this into a fnl repl?

The repl is written in lua itself: it should be easy to write a fnl repl in fnl (or lua) if you so choose :) See https://github.com/fengari-lua/fengari.io/blob/master/static/lua/web-cli.lua

technomancy commented 6 years ago

In a browser io.read (which blockingly reads from stdin) doesn't really make sense: what what it read from?

This is pretty easy to address if you have coroutines. I wonder if they just haven't gotten around to it yet or if there are technical reasons preventing their implementation of coroutines from working here.

daurnimator commented 6 years ago

Sure it's easy to read input with coroutines, but io.read isn't documented to use coroutines: so it's necessary for a user to implement it themselves.

technomancy commented 6 years ago

@bakpakin I've got a prototype of this working decently, but I thought it would be nice to have a proper site up at https://fennel-lang.org or something like that to host it on. Thoughts?

Edit: Fengari passes all the Fennel test suite except for require-macros (which needs io.open).

bakpakin commented 6 years ago

Yeah, I suppose I could buy a domain.

@technomancy Is your prototype completely static? Maybe we could host with github pages and just redirect the domain to github. In the long term, it might be better to make a the site in a separate repo.

technomancy commented 6 years ago

Yeah, I suppose I could buy a domain.

I could handle the registration and hosting if you don't want to be bothered, but I'd understand if you want to keep it in your name.

Is your prototype completely static? Maybe we could host with github pages and just redirect the domain to github. In the long term, it might be better to make a the site in a separate repo.

From the server side it's all static, yeah. So GitHub pages would work fine. The Fengari Githubissues.

  • Githubissues is a development platform for aggregating issues.