Язык Zig (канал)
173 subscribers
28 photos
3 videos
6 files
243 links
Download Telegram
Дожили???
https://github.com/ZigC-Lang/zigc

ZigC is a C-like language with a lot of modern concepts introduced in Zig language, and getting rid of a lot of seemingly unnecessary features from C/C++ and embarrassing peculiarities from Zig syntax.
In result, ZigC is easier than C++/Rust, faster than Go/Java, safer than C/C++, familiar than Rust/Zig, smaller than Rust/C++, and more machine friendly than C/C++/Rust/Go.

...блабла...

...блабла...

ZigC corrected Zig syntax as follows:
* Back to C like syntax from Pascal-like variable, function declaration.
* JSON like struct iniatialization.
* Array bracket [] for array initialization.
* Simple for loops, removing crapy while/for syntax.
* Semicolon in struct/union, instead of comma.
* Back to switch/case/default.
* Non-null, non-error 'quotation, instead of |capture|.
* Error sets merge A|B, not A||B.
* Array concat + and mult *, not ++ and **.
* anyframe(return_type) not anyframe->return_type.
* Public and static.
* Non-public main.
* ! operator, not try ...
* catch (null), instead of 'orelse'.

В репозитории только примеры кода кстати.
🤨3
Язык Zig (канал)
Дожили??? https://github.com/ZigC-Lang/zigc ZigC is a C-like language with a lot of modern concepts introduced in Zig language, and getting rid of a lot of seemingly unnecessary features from C/C++ and embarrassing peculiarities from Zig syntax. In result…
https://github.com/ZigC-Lang/zigc/blob/102b162a30626d0d7c1885da1acdd44d9e7c125f/15.%20ZigC%20Syntax%20Principle.md

Followings are how ZigC syntax is formulated:
* shoul be most comfortable for C programmers.
should accommodate all modern syntax introduced by Zig, but in more C-like way.
* should take simplist form, comparing among other modern languages.
* should guarrantee zero overhead on Zig, which also guarrantees zero overhead on C.
* may take away unnecessary details from Zig, if possible.
* may compromise rigid rules, if it helps programmer's happyness.
* may slightly sacrifice compile time, if it helps programmer's sanity.
Debugging a Zig Test Failure
https://zinascii.com/2023/debugging-a-zig-test-failure.html
Про исправление ошибки в стандартной библиотеки Zig для платформы Illumos (если точнее, дистрибутив OmniOS). Много разьяснений и мыслей (ну или воды, для кого как) про отладку, DTrace и т.д.

#блоги
Парный стрим kristoff_it и andrewrk по программированию https://www.twitch.tv/kristoff_it
#стримы
🔥1
https://github.com/ziglang/zig/pull/17497
pub fn fatal(comptime fmt: []const u8, args: anytype) error{TestFatal} {
fail(fmt, args);
return error.TestFatal;
}
оказывается можно писать и так, думал только error{TestFatal}!void (и т.д.) работает
usingnamespace оказывается ещё и на enum/union работает... (я думал только на struct и opaque) тот же результат — публичные обьявления ре-экспортируются
Язык Zig (канал)
usingnamespace оказывается ещё и на enum/union работает... (я думал только на struct и opaque) тот же результат — публичные обьявления ре-экспортируются
const Location = enum(u32) {
box = 0,
stolovaya = 1,
workshop = 2,
mine = 3,
_,

pub const start_facilites: u32 = 2;
pub const end_facilities: u32 = 3;
}

const Everything = struct {
pub usingnamespace Location; // теперь можно писать Everything.start_facilities, но не Everything.box пушто не публичное обьявление, а просто член
};
очередной compiler meeting в дискорде начался
Forwarded from Königskraut
немного оффтопик, но смотрите что теперь в телеграме есть

const std = @import("std");

pub fn main() !void {
std.debug.print("kek\n", .{});
}
2👍2🤯1
Königskraut
немного оффтопик, но смотрите что теперь в телеграме есть const std = @import("std"); pub fn main() !void { std.debug.print("kek\n", .{}); }
В k версии [1.9.6 (418)] старый вид, в z/a [10.0.15] новый (с кнопкой копировать) но подсветки нет, в десктоп клиенте [4.11.1] есть и кнопка и подсветка
Кстати насчёт той весёлой задачки „Man or boy test” с Rosetta Code, я по фану сегодня таки сделал её (немного схитрил внутри, но шо поделать — Зиг так хочет), вроде работает с правильными результатами вплоть до 20, дальше мне стека не хватило:

https://rosettacode.org/wiki/Man_or_boy_test?oldid=358095#Zig
🤔1
Язык Zig (канал)
Кстати насчёт той весёлой задачки „Man or boy test” с Rosetta Code, я по фану сегодня таки сделал её (немного схитрил внутри, но шо поделать — Зиг так хочет), вроде работает с правильными результатами вплоть до 20, дальше мне стека не хватило: https://ro…
const Record = struct {
yieldFn: *const fn (record: *Record) i32,

k: *i32 = undefined,
x1: *Record = undefined,
x2: *Record = undefined,
x3: *Record = undefined,
x4: *Record = undefined,
x5: *Record = undefined,

inline fn run(record: *Record) i32 {
return record.yieldFn(record);
}

pub fn A(record: *Record) i32 {
return if (record.k.* <= 0)
record.x4.run() + record.x5.run()
else
record.B();
}

fn B(record: *Record) i32 {
record.k.* -= 1;

var k_copy_on_stack: i32 = record.k.*;

var b: Record = .{
.yieldFn = &Record.B,

.k = &k_copy_on_stack,
.x1 = record,
.x2 = record.x1,
.x3 = record.x2,
.x4 = record.x3,
.x5 = record.x4,
};
return b.A();
}
};

const numbers = struct {
fn positiveOne(unused_record: *Record) i32 {
_ = unused_record;
return 1;
}

fn zero(unused_record: *Record) i32 {
_ = unused_record;
return 0;
}

fn negativeOne(unused_record: *Record) i32 {
_ = unused_record;
return -1;
}
};

const std = @import("std");

pub fn main() void {
var i: u31 = 0;
while (i <= 31) : (i += 1) {
var k: i32 = i;
var @"+1_record": Record = .{ .yieldFn = &numbers.positiveOne };
var @"0_record": Record = .{ .yieldFn = &numbers.zero };
var @"-1_record": Record = .{ .yieldFn = &numbers.negativeOne };

var record: Record = .{
.yieldFn = &Record.B,

.k = &k,
.x1 = &@"+1_record",
.x2 = &@"-1_record",
.x3 = &@"-1_record",
.x4 = &@"+1_record",
.x5 = &@"0_record",
};

std.debug.print("[{d:>3}] = {d}\n", .{ i, record.A() });
}
}
https://ziglang.org/learn/build-system/
Будущая документация про Zig Build System (будет перенесена в доки std.Build как я понял)
#upstream
3
Generating a Star Sphere using Zig
https://pollrobots.com/blog/zig/code/2023/11/11/star-sphere-in-zig.html
Генерация карты звезд с помощью разбора звездного каталога.

#блоги
👍3