vexu / bog Goto Github PK
View Code? Open in Web Editor NEWSmall, strongly typed, embeddable language.
License: MIT License
Small, strongly typed, embeddable language.
License: MIT License
Very cool library in Zig!
Just a quick question: I’m reading the code and having a hard time determining if this is register or stack based? I’m very new to Zig syntax and I see a stack pointer (sp) variable but no actually stack-like array in the code.
I’m also see code related to register allocation but can’t find the specific registers.
For those learning can you point me to some clues in the code?
Thanks again!
# basics
let zero_to_five_step_two = 0:5:2
# any of the values can be omitted with defaults
let zero_to_five_step_one = :5
let zero_to_inf_step_five = ::5
This would mean having to changing the syntax for maps:
let map = {
- a: 2
+ a = 2
}
Now that there is a append_double
instruction there should probably be syntax for it.
If #9 is accepted +
and <<
cannot be used.
👋 looks like a very interesting project, any interest of tracking the stable zig and cut off a release for downstream package manager use? Thanks!
E.g.:
pub fn Vm(comptime intType: type, comptime floatType: type) {
...
}
var vm = bog.Vm(u128, f128).init(allocator, .{ .import_files = true });
or
pub fn Vm(comptime intBits: u8, comptime floatBits: u8) {
...
}
[1,2,3] * 2 # -> [2,4,6]
# maybe even
[1,2,3] * [4,5,6] # -> [4, 10, 18]
Hello,
I have been trying to port this project over to zig master from the past couple days. While I am already successful in it and all tests are passing, there is a small problem. AutoIndentingStream is removed from std lib in recent versions. For tests, I ended up copying the same source code over to here (and made slight modifications), but concern is licensing.
How I should go about from here? I have been considering somehow remaking the AIS...
My branch is here: https://github.com/iddev5/bog/tree/fix-build it is complete minus cleanup/zig fmt
Thank you.
hello, is there any plans for incorporating facilities which provide the ability to define your own types similar to c++ classes?
let x = 2
const foo = fn()
return fn()
return x + 5
const bar = foo()
return bar()
Bytecode with fix:
function_0:
- 5 load_capture_double 0 <- [1]
+ 5 load_capture_double 0 <- [0]
6 const_int 3 <- (5)
7 add_triple 2 <- 0 + 3
8 return_single 2
function_1:
13 load_capture_double 1 <- [0]
14 build_func 0 <- function_0(0)[1]
16 store_capture_triple 0[0] <- 1
17 return_single 0
entry:
20 const_int 1 <- (2)
23 build_func 0 <- function_1(0)[1]
25 store_capture_triple 0[0] <- 1
28 call 2 <- 0()
32 call 3 <- 2()
34 return_single 3
Example behavior:
const {assert} = import("std.debug")
const func = fn(val) match (val)
let @foo(name, 0) => name + 2
@bar => 3
1, 2, 3 => 5
let (foo, "true") => foo as bool
let error(foo) => foo
_ = 42
assert(func(@foo(2, 0)) == 4)
assert(func(@bar) == 3)
assert(func(2) == 3)
assert(func(("false", "true")) == false)
assert(func(error(2)) == 2)
assert(func("nope") == 42)
This will require some new instructions like try_unwrap_*
and try_get
.
Once those are implemented this should also work:
if (let (foo, "some") = x) foo + 2
https://en.wikipedia.org/wiki/Control_flow#Loops
I propose repeat/until as in Pacal & Lua.
The great project, thank you!
lazy
expressions would be the language level equivalent of std.once
. The value of the expression would only be executed once and only if needed. These would mainly be beneficial for expensive calculations that are only needed sometimes.
const {print} = import("std.io")
const {assert} = import("std.debug")
const x = lazy
print("resolved")
2
let y = 2
y += x # "resolved"
y += x # nothing
assert(y == 6)
https://github.com/ziglibs/ansi-term - easy dealing with ANSI terminals.
https://github.com/joachimschmidt557/zig-linenoise - line editing with hints, history, completions...
Thoughts?
Some compact way to get source index from instruction offset.
The dream would be to have Python like "batteries included" stdlib.
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.