wu-lang / wu Goto Github PK
View Code? Open in Web Editor NEW๐ A practical game and data language
Home Page: https://wu-lang.gitbook.io/guide/
License: MIT License
๐ A practical game and data language
Home Page: https://wu-lang.gitbook.io/guide/
License: MIT License
hey, i wanna develop dynamic redbean applications with wu. is there a way to let the compiler know a function exists without providing an implementation that will be compiled?
Wu should have sum types as well as interface-like type parameters. This will speed up the development process, while also making it even more fun and nice to use the language:
Cat: struct {
weight: float
}
Dog: struct {
hat: bool
}
dog_or_cat: Cat | Dog = new Cat {
weight: 1000
}
# can later be Dog
Then the following:
Vector3: struct {
x: float, y: float, z: float
}
Vector2: struct {
x: float, y: float
}
move2D: fun(thing: { x: float, y: float}, dx: float, dy: float) {
thing x += dx
thing y += dy
}
It hasn't been changed in over two years. To quote it:
Wu is built and maintained by a minimal team of people and was primarily developed during boring primary school classes, to help make time pass faster. Currently being maintained by an 18-year-old.
I think "currently being maintained by an 18-year-old" sounds very weird in a github repository. Are we meant to treat it as a request to not use it for anything serious? If we are, that's in contradiction with tongue-in-cheek You are using it
on the selling points list just above it.
It's the kind of remark that could only hurt adoption of the project, imho. Not to mention that it's not even true anymore since time (sadly) doesn't stay constant. I'd suggest dropping that whole disclaimer altogether, the language works, it's irrelevant how it came to be ^^
Several failures:
Test: struct {}
implement Test if Test {}
Test: struct {}
implement Test: Test {
}
Test: struct {}
implement Test: Test {
foo: fun() {}
}
implement Data: Data_T {
clone: extern fun(self) -> Data
}
This is something we need to have. While it does have some downsides in introducing bad practice behavior, it's pretty useful.
Given lib.wu
with the following content:
bob := "BUILDER"
important_number: float = 100.0
The following otherfile.wu
...
import lib { * }
Should automatically generate the following import code in otherfile.lua
:
local lib = require('lib')
local bob = lib['bob']
local important_number = lib['important_number']
I don't know if it's they way it is intended to be, but I expected to be able to import a file from the same folder which the file I'm compiling resides in, but instead I got an error saying that there's no such module. But, if I set $WU_HOME to a directory somewhere and copy the file I'm importing to this folder, it compiles.
Is it intended to work this way, by only importing from $WU_HOME, or is it a bug? I'll copy here some of my terminal output
garcias@PHANTOM:~/src/wu-test$ ls
font main.wu wumodule.wu
garcias@PHANTOM:~/src/wu-test$ wu main.wu
Compiling main.wu
wrong: no such module `wumodule`, needed either `wumodule.wu`, `wumodule/init.wu` or in `$WU_HOME`
--> main.wu
โ
1 โ import wumodule { ten }
โ ^^^^^^^^^^^^^^^^^^^^^^^
Finished things in 0ms
garcias@PHANTOM:~/src/wu-test$
main.wu
import wumodule { ten }
wumodule.wu
ten := 10
Also, neither creating a directory called wumodule and putting a init.wu inside works, only inside $WU_HOME
Currently every symbol in a module is exported. Symbols should become private by default and export classifiers should be implemented, to be able to hide certain details.
Example:
bar: module {
pub foo: fun() -> int { 42 }
oof: fun() -> int { 24 }
}
a := bar foo() # 42
b := bar oof() # error: accessing private function <oof>
# bar.wu
pub foo: fun() -> int { 42 }
oof: fun() -> int { 24 }
# main.wu
import bar { foo, oof } # error: importing private function <oof>
# main.wu 2
import bar
bar oof() # error: accessing private function <oof>
Trait implement does not seem to accept user types in signatures
Data: struct {}
Data_T: trait {
clone: fun(self) -> Data
}
implement Data: Data_T {
clone: extern fun(self) -> Data
}
error:
wrong: expected implemented type `fun() -> deid(Data)` for `clone`
--> main.wu
โ
5 โ implement Data: Data_T {
โ ^^^^
how does the syntax for arrays look? couldn't find in documentation or examples
As said in the title. iter() doesnt works.
conte := ["undertale", "underale"]
for x in iter(conte) {
std print(conte)
}
Returns:
wrong: can't seem to find `iter`
--> ./definitions.wu
โ
32 โ for x in iter(conte) {
โ ^^^^
When importing things in Wu, the output require
in the Lua code should use the proper path relative to where the compiler is run.
Trait body fails to parse if there's an additional newline or comment
Data_T: trait {
getFFIPointer: fun(self) -> any
}
error:
wrong: expected `Identifier`, found `EOL`
thread 'main' panicked at 'byte index 1 is out of bounds of ``', /home/evol/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/str/mod.rs:1920:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
--> main.wu
Data_T: trait {
getFFIPointer: fun(self) -> any
#asd
}
error:
wrong: expected `Identifier`, found `EOL`
thread 'main' panicked at 'byte index 9 is out of bounds of ` #asd`', /home/evol/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/str/mod.rs:1920:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
--> main.wu
For speed!
If you think this is is something you can take on, let's talk!
While the current error messages are good, there is a lot of space for improvement. The error message system should be improved, either by hand or by plugging in something like Codespan.
The new errors should be helpful to the degree of Elm, and easily overviewed to the degree of Rust.
Let's get this.
Title says it all. Let's go.
When compiling imports should behave by this system:
compile file: all imports are relative to initial file
compile directory: all imports are relative to initial directory
build project: all imports are relative to src/
The resulting require statements should also use .
to separate path elements instead of /
and should not contain a ./
prefix
project/
src/
lib/
init.wu
mylib.wu
main.wu
wu.toml
Contents:
# main.wu
import lib { mylib }
# init.wu
import mylib { MyType }
# mylib.wu
MyType: struct {}
Building project: ~/project$ wu build
Expected contents:
-- main.wu
local lib = require "lib"
local mylib = lib["mylib"]
-- init.wu
local mylib = require "lib.mylib"
-- mylib.wu
<empty>
Building directory: ~/project$ wu src/lib
Expected contents:
-- init.wu
local mylib = require "mylib"
-- mylib.wu
<empty>
Building file: ~/project$ wu src/lib/init.wu
Expected contents:
-- init.wu
local mylib = require "mylib"
-- mylib.wu
<empty>
Enums will be simple. My current idea is to have something like the following:
import enemies { Enemy }
Weapon: enum {
Gun
Swordfish
Fist
}
damage_enemy_with: fun(enemy: Enemy, weapon: Weapon) {
switch weapon {
Weapon Gun => enemy damage(100)
Weapon Swordfish => enemy damage(9000)
Weapon Fist => enemy damage(10)
}
}
Again; very simple. :)
The intro documentation just mentions having rust and just running the cargo install
. However, you need to be on the rust nightly/beta(?) branch I think. I get the following message on the stable release channel.
error[E0554]: #![feature] may not be used on the stable release channel
--> src\lib.rs:1:1
|
1 | #![feature(i128)]
| ^^^^^^^^^^^^^^^^^
error[E0554]: #![feature] may not be used on the stable release channel
--> src\lib.rs:2:1
|
2 | #![feature(i128_type)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Just figured I would let you know ;). Cool language btw!
lua has a thread type, but wu seems to not have one
Even though my english isn't that good, I still appreciate if beginning of sentences etc are capitalized. Makes everything a lot easier to read.
The visitor is marking expressions at the end of if-expressions as implicit returns, even if it isn't the real last expression of the root block.
import lover { grahics }
foo: fun -> int {
if false {
# returns here
graphics setColor(1, 1, 0)
}
if true {
# properly inserts return here too
200
}
}
Attempting to use Object
from love
results in an error
# love/types.wu
Object: struct {}
# love/init.wu
import types { Object }
# main.wu
import love
asd : fun() -> love Object {
new love Object {}
}
error:
wrong: no such module member `Object`
--> main.wu
โ
3 โ asd : fun() -> love Object {
โ ^^^^^^
Just like lua has its own REPL(read-eval-print-loop), as in example below:
bash% lua
Lua 5.4.2 Copyright (C) 1994-2020 Lua.org, PUC-Rio
print("hi")
hi
function f1(x)
print("hi")
end
f1()
hi
In the same way please implement REPL for wu
i have some code, that looks like this:
print("something \"something\" something else")
but when i compile i get this error:
Compiling init.wu
wrong: bumped into weird character
--> ./init.wu
โ
1 โ print("something \"something\" something else")
โ ^
Finished things in 0ms
how can i fix the code?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.