Skip to content

Commit 1294632

Browse files
committed
README: Add some stuff about what FusionScript is
1 parent 45764e6 commit 1294632

File tree

2 files changed

+129
-9
lines changed

2 files changed

+129
-9
lines changed

README.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,68 @@
11
# FusionScript [![Build Status](https://travis-ci.org/RyanSquared/fusionscript.svg?branch=master)](https://travis-ci.org/RyanSquared/fusionscript)
22
The programming language of ultimate dankliness
33

4-
**Warning:** This project is very recently released and possibly has many bugs.
5-
If your code does not compile, it is *very* likely a problem in the compiler
6-
instead of your code. Please feel free to add an issue if any errors arise that
7-
you believe were caused by the compiler.
4+
**Warning:** This project is very unstable and possibly has many bugs. If your
5+
code does not compile, it is *very* likely a problem in the compiler or a
6+
change in the language instead of your code. Please feel free to add an issue
7+
if any errors arise that you believe were caused by the compiler.
8+
9+
## What is FusionScript?
10+
11+
FusionScript is a language that runs on the Lua runtime (currently, by
12+
transpiling to Lua and then using a Lua interpreter) inspired by C++, Python,
13+
and Lua. Eventually, FusionScript will compile to a modified Lua 5.3 bytecode
14+
and run on a modified Lua VM.
15+
16+
FusionScript offers an improved runtime type checking system (that
17+
checks between both native Lua types, as well as instances of a class) by using
18+
the [standard library](/RyanSquared/stdlib)'s `assert.is()` method. Eventually,
19+
runtime type checking may be implemented using syntax similar to Pythonic type
20+
hints and checked using bytecode instructions.
21+
22+
FusionScript also has a class system, with the ability to inherit values from a
23+
superclass as well as an "interface" system that when used (see below) will
24+
ensure that classes implement certain methods. Below is an example that closely
25+
mirrors the standard library's scope module:
26+
27+
```fuse
28+
interface IScope { descope; with; }
29+
class Scope {
30+
with(fn)=> {
31+
fn(self);
32+
}
33+
}
34+
35+
-- Example:
36+
37+
local lfs = require("lfs");
38+
39+
class UseDir extends Scope implements IScope {
40+
descope()=> lfs.chdir(@old_dir);
41+
__init(directory)=> {
42+
@old_dir = lfs.currentdir();
43+
@dir = directory;
44+
lfs.chdir(directory);
45+
}
46+
}
47+
48+
UseDir("/tmp"):with(\=> {
49+
File("thing.txt"):with(\file-> {
50+
file:write("Hello World!\n");
51+
});
52+
});
53+
```
54+
55+
There is also implemented an easier way to use generators / iterators using the
56+
`async` and `yield` functions:
57+
58+
```
59+
async gen_numbers(low = 1, high)->
60+
for (i=low, high)
61+
yield i;
62+
63+
for (number in gen_numbers(1, 10))
64+
print(number);
65+
```
866

967
## Commands
1068

docs/topics/FusionScript.md.html

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h1>FusionScript</h1>
3232

3333
<h2>Contents</h2>
3434
<ul>
35+
<li><a href="#What_is_FusionScript_">What is FusionScript? </a></li>
3536
<li><a href="#Commands">Commands </a></li>
3637
<li><a href="#Examples">Examples </a></li>
3738
</ul>
@@ -67,10 +68,71 @@ <h2>Programs</h2>
6768
<h1>FusionScript <a href="https://travis-ci.org/RyanSquared/fusionscript"><img src="https://travis-ci.org/RyanSquared/fusionscript.svg?branch=master" alt="Build Status"/></a></h1>
6869
<p>The programming language of ultimate dankliness</p>
6970

70-
<p><strong>Warning:</strong> This project is very recently released and possibly has many bugs.
71-
If your code does not compile, it is <em>very</em> likely a problem in the compiler
72-
instead of your code. Please feel free to add an issue if any errors arise that
73-
you believe were caused by the compiler.</p>
71+
<p><strong>Warning:</strong> This project is very unstable and possibly has many bugs. If your
72+
code does not compile, it is <em>very</em> likely a problem in the compiler or a
73+
change in the language instead of your code. Please feel free to add an issue
74+
if any errors arise that you believe were caused by the compiler.</p>
75+
76+
<p><a name="What_is_FusionScript_"></a></p>
77+
<h2>What is FusionScript?</h2>
78+
79+
<p>FusionScript is a language that runs on the Lua runtime (currently, by
80+
transpiling to Lua and then using a Lua interpreter) inspired by C++, Python,
81+
and Lua. Eventually, FusionScript will compile to a modified Lua 5.3 bytecode
82+
and run on a modified Lua VM.</p>
83+
84+
<p>FusionScript offers an improved runtime type checking system (that
85+
checks between both native Lua types, as well as instances of a class) by using
86+
the <a href="/RyanSquared/stdlib">standard library</a>'s <code>assert.is()</code> method. Eventually,
87+
runtime type checking may be implemented using syntax similar to Pythonic type
88+
hints and checked using bytecode instructions.</p>
89+
90+
<p>FusionScript also has a class system, with the ability to inherit values from a
91+
superclass as well as an "interface" system that when used (see below) will
92+
ensure that classes implement certain methods. Below is an example that closely
93+
mirrors the standard library's scope module:</p>
94+
95+
96+
<pre>
97+
interface IScope { descope; with; }
98+
class Scope {
99+
with(fn)=&gt; {
100+
fn(self);
101+
}
102+
}
103+
104+
<span class="comment">-- Example:
105+
</span>
106+
<span class="keyword">local</span> lfs = <span class="global">require</span>(<span class="string">"lfs"</span>);
107+
108+
class UseDir extends Scope implements IScope {
109+
descope()=&gt; lfs.chdir(@old_dir);
110+
__init(directory)=&gt; {
111+
@old_dir = lfs.currentdir();
112+
@dir = directory;
113+
lfs.chdir(directory);
114+
}
115+
}
116+
117+
UseDir(<span class="string">"/tmp"</span>):with(\=&gt; {
118+
File(<span class="string">"thing.txt"</span>):with(\file-&gt; {
119+
file:write(<span class="string">"Hello World!\n"</span>);
120+
});
121+
});
122+
</pre>
123+
124+
125+
<p>There is also implemented an easier way to use generators / iterators using the
126+
<code>async</code> and <code>yield</code> functions:</p>
127+
128+
<pre><code> async gen_numbers(low = 1, high)-&gt;
129+
for (i=low, high)
130+
yield i;
131+
132+
for (number in gen_numbers(1, 10))
133+
print(number);
134+
</code></pre>
135+
74136

75137
<p><a name="Commands"></a></p>
76138
<h2>Commands</h2>
@@ -250,7 +312,7 @@ <h3>Building</h3>
250312
</div> <!-- id="main" -->
251313
<div id="about">
252314
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
253-
<i style="float:right;">Last updated 2017-05-08 19:58:29 </i>
315+
<i style="float:right;">Last updated 2017-05-09 20:46:56 </i>
254316
</div> <!-- id="about" -->
255317
</div> <!-- id="container" -->
256318
</body>

0 commit comments

Comments
 (0)