cryptocode / bio Goto Github PK
View Code? Open in Web Editor NEWA Lisp dialect written in Zig
License: MIT License
A Lisp dialect written in Zig
License: MIT License
With version
zig version
0.13.0-dev.75+5c9eb4081
typing
zig build
in the bio root directory results in the message
/home/data2/Build/bio/build.zig:3:21: error: root struct of file 'std' has no member named 'build'
/usr/lib/zig/std/std.zig:1:1: note: struct declared here
What benefits does a zig implementation of a LISP have over C/C++ and can bio leverage that?
trivial solution, maybe quit should call some rundown routines
https://github.com/benjiqq/bio/blob/quit/src/interpreter.zig#L577
I have cloned the bio, but they don't compile ::
./src/main.zig:16:41: error: expected type '[]const *ast.Expr', found '*struct:16:41'
var stdlib = try makeListExpr(&.{ &expr_atom_quote, try makeAtomByDuplicating("std.lisp") });
^
./src/intrinsics.zig:281:39: error: no member named 'readUntilDelimiterOrEofAlloc' in struct 'std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)'
if (try std.io.getStdIn().reader().readUntilDelimiterOrEofAlloc(allocator, '\n', std.math.maxInt(u32))) |line| {
^
./src/intrinsics.zig:420:39: error: expected type '[]const *ast.Expr', found '*intrinsics.struct:420:39'
return boolExpr((order(ev, env, &.{ try ev.eval(env, args[0]), try ev.eval(env, args[1]) }) catch |_| return &expr_atom_false) == std.math.Order.eq);
^
./src/intrinsics.zig:406:41: error: expected type '[]const *ast.Expr', found '*intrinsics.struct:406:41'
return switch (try order(ev, env, &.{ try ev.eval(env, args[0]), try ev.eval(env, args[1]) })) {
^
./src/intrinsics.zig:117:57: error: expected type '[]const []const u8', found '*intrinsics.struct:117:57'
var path = try std.fs.path.resolve(allocator, &.{filename_expr.val.sym});
^
./src/intrinsics.zig:150:22: error: no member named 'readUntilDelimiterOrEofAlloc' in struct 'std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)'
if (file.reader().readUntilDelimiterOrEofAlloc(allocator, '\n', std.math.maxInt(usize))) |maybe| {
^
./src/interpreter.zig:432:23: error: no member named 'readUntilDelimiterOrEofAlloc' in struct 'std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)'
if (reader.readUntilDelimiterOrEofAlloc(allocator, '\n', 2048)) |maybe| {
^
./src/intrinsics.zig:200:36: note: called from here
if (ev.readBalancedExpr(&reader, "")) |maybe| {
^
./src/intrinsics.zig:176:83: note: called from here
pub fn stdImport(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
^
./src/ast.zig:182:46: error: expected type '[]const *ast.Expr', found '*const ast.struct:182:46'
const intrinsic_atoms: []const *Expr = &.{
^
./src/interpreter.zig:398:51: error: expected type '[]const *ast.Expr', found '*interpreter.struct:398:51'
return try makeListExpr(&.{ unquote_op, try self.read(it) });
^
./src/ast.zig:150:29: error: no member named 'swapRemove' in struct 'std.array_hash_map.ArrayHashMap(*ast.Expr,*ast.Expr,ast.hash_util.hash,ast.hash_util.eql,true)'
_ = self.map.swapRemove(var_name);
^
./src/intrinsics.zig:391:44: error: expected type '[]const *ast.Expr', found '*intrinsics.struct:391:44'
res = try order(ev, env, &.{ item, op2.val.lst.items[index] });
^
bio...The following command exited with error code 1:
/nix/store/6ai6418cmg13kk5ccbbbi6xycgkmhczi-zig-0.7.1/bin/zig build-exe /home/user/git/clone/bio/src/main.zig --library c -cflags -std=c99 -- /home/user/git/clone/bio/deps/linenoise.c --cache-dir /home/user/git/clone/bio/zig-cache --global-cache-dir /home/user/.cache/zig --name bio -I /home/user/git/clone/bio/deps --enable-cache
error: the following build command failed with exit code 1:
/home/user/git/clone/bio/zig-cache/o/4345f123fc22f6ed40cca0398ffa1936/build /nix/store/6ai6418cmg13kk5ccbbbi6xycgkmhczi-zig-0.7.1/bin/zig /home/user/git/clone/bio /home/user/git/clone/bio/zig-cache /home/user/.cache/zig
are you have some idea how to solve this problem ?
I tried to run the module example in the readme, using latest master.
./zig-out/bin/bio run usepoint.lisp
ERROR: /Users/ben/zigdev/bio/usepoint.lisp, line 5: x is not defined
ERROR: /Users/ben/zigdev/bio/usepoint.lisp, line 5: lambda received 1 arguments, expected 2
x isn't defined, looks like readme reuses session code from somewhere before
code used
;use-mod-example.lisp
(var Point (import "modules/mod-point.lisp"))
(var pt (Point new-location 24.5 69.2))
(pt x)
24.5
((pt as-string))
24.5 °N 69.2 °E
; Call update in two different ways
((pt update) 25.4 70.5)
(pt (update 25.4 70.5))
;mod-point.lisp
((lambda ()
; Functions shared between types are actually macros so their parent
; environment is the calling environment; this way x and y will be found
(var generic-update (macro (new-x new-y)
(set! x new-x)
(set! y new-y)
nil
))
; A point datatype with regular formatting
(var new-point (lambda (x y)
(var update generic-update)
(var as-string (lambda ()
(string x " " y)
))
(self)
))
; A version with longitude and latitude formatting
(var new-location (lambda (x y)
(var update generic-update)
(var as-string (lambda ()
(string
(math.abs x) (if (< x 0) "° S" "° N")
" "
(math.abs y) (if (< y 0) "° W" "° E"))
))
(self)
))
(var module-name "Position Module")
(var module-version '(1 0 0))
(self)
))
all examples print Memory leaks detected
at the end
./bio run examples/hello.lisp
How many times to print Hello?
1
Hello
Memory leaks detected
zig version
0.11.0-dev.4183+32a175740
the bio binary is zig-out
$zig build
$ls zig-out
total 4384
-rwxr-xr-x 1 ben staff 2242232 Jul 23 18:12 bio
ben@Bens-MacBook-Air bio % ./zig-out/bio
ERROR: repl, line 1: File not found: /Users/ben/zigdev/bio/zig-out/std.lisp
Memory leaks detected
error: AlreadyReported
/Users/ben/zigdev/zig-0.11/lib/std/os.zig:5115:19: 0x102c54dfd in realpathZ (bio)
.NOENT => return error.FileNotFound,
^
/Users/ben/zigdev/zig-0.11/lib/std/os.zig:5085:5: 0x102bfd297 in realpath (bio)
return realpathZ(&pathname_c, out_buffer);
^
/Users/ben/zigdev/bio/src/intrinsics.zig:258:17: 0x102bf2a7a in stdImport (bio)
return ExprErrors.AlreadyReported;
^
/Users/ben/zigdev/bio/src/main.zig:25:13: 0x102bf1f18 in main (bio)
_ = try intrinsics.stdImport(&interpreter, interpreter.env, args.items);
^
After some minor fixes like fixing unused function errors,etc. Bio would not compile and it errors out with
Semantic Analysis [531/911] Unreachable at /home/vsts/work/1/s/src/stage1/analyze.cpp:892 in get_slice_type. This is a bug in the Zig compiler.thread 1520 panic: Unable to dump stack trace: debug info stripped bio...The following command terminated unexpectedly: /workspace/bio/zig/zig build-exe /workspace/bio/src/main.zig -lc -cflags -std=c99 -- /workspace/bio/deps/linenoise.c --cache-dir /workspace/bio/zig-cache --global-cache-dir /home/gitpod/.cache/zig --name bio -I /workspace/bio/deps --enable-cache error: the following build command failed with exit code 6: /workspace/bio/zig-cache/o/cd6f1c31aba6ac98cbd2100f0f46b5d3/build /workspace/bio/zig/zig /workspace/bio /workspace/bio/zig-cache /home/gitpod/.cache/zig
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.