I didnβt realized but apparently this is totally legal and fine zig code. LOL
const std = @import("std");
const _______ = u32;
const ________ = std.debug.print;
pub fn _(__: _______, ___: _______, ____: _______) _______ {
________("{d}", .{__ + ___ + ____});
return __ + ___ + ____;
}
test ________ {
const __: _______ = 1;
const ___: _______ = 2;
const ____: _______ = 3;
const _____: _______ = @"_"(__, ___, ____);
_ = _____;
}
19 Likes
This⦠should not be legal. If it must be called with @"_"
it should have to be defined with @"_"
. Surely this is reasonable.
2 Likes
that we can agree, it shouldnβt but it works like a charm, I find it very amusing
2 Likes
to be fair C is even more cursed
#define ____ <stdio.h>
#include ____
#define __ a
#define ___ main
#define _____ int
#define ______ printf
#define _______ (
#define ________ )
#define _________ {
#define __________ }
#define ___________ return
#define ____________ ;
#define _____________ const
#define ______________ =
_____ _ _______ _____ __ ________ _________ ___________ __ ____________ __________
_____ ___ _______ ________ _________ _____________ _____ __ ______________ _ _______ 5 ________ ____________
______ _______ "%c",
__ ________ ____________ __________
12 Likes
Reading this it occurred to me Zig supports unicode:
const @"π¨οΈ" = std.debug.print;
const @"π" = "Hello, World!";
@"π¨οΈ"("{s}\n", .{@"π"});
And unicode has many invisible whitespace characters:
const @" " = 1;
const @" " = 2;
@"π¨οΈ"("{d}\n", .{@" " + @" "});
3 Likes
Does it? Does it really???
test "why though? why" {
const @"\xff\xff\xff" = "yes well. nonetheless";
std.debug.print("they're just... slices?? {s}\n", .{@"\xff\xff\xff"});
}
1 Like
rpkak
8
For users of nm
:
const std = @import("std");
export fn @"foo\n00000000000002ca T bar"() void {
std.debug.print("foo\n", .{});
}
$ zig build-obj test.zig
$ nm test.o
[...]
0000000000000000 T foo
00000000000002ca T bar
[...]
4 Likes
Sze
9
I removed most of the underscores:
const std = @import("std");
const @"βββββββ" = u32;
const @"ββββββββ" = std.debug.print;
pub fn @"β"(@"ββ": @"βββββββ", @"βββ": @"βββββββ", @"ββββ": @"βββββββ") @"βββββββ" {
@"ββββββββ"("{d}", .{@"ββ" + @"βββ" + @"ββββ"});
return @"ββ" + @"βββ" + @"ββββ";
}
test @"ββββββββ" {
const @"ββ": @"βββββββ" = 1;
const @"βββ": @"βββββββ" = 2;
const @"ββββ": @"βββββββ" = 3;
const @"βββββ": @"βββββββ" = @"β"(@"ββ", @"βββ", @"ββββ");
_ = @"βββββ";
}
Maybe we should have some sort of lint-tool that forbids things like βZERO WIDTH SPACEβ.
10 Likes
I am glad to see those AI learn from this thing and provide their users with this thing.
4 Likes
I remember having unexpected results when abusing the blank identifier.
Unfortunately I donβt remember where the code was saved.
I mentioned this before:
const std = @import("std");
const @"I am ββgroot" = u32;
const @"I am βgroot" = std.debug.print;
pub fn @"I βββam ββββgroot"(@"I βββam βββgroot": @"I am ββgroot", @"I ββam βββgroot": @"I am ββgroot", @"I βam βββgroot": @"I am ββgroot") @"I am ββgroot" {
@"I am βgroot"("{d}", .{@"I βββam βββgroot" + @"I ββam βββgroot" + @"I βam βββgroot"});
return @"I βββam βββgroot" + @"I ββam βββgroot" + @"I βam βββgroot";
}
test @"I am βgroot" {
const @"I βββam βββgroot": @"I am ββgroot" = 1;
const @"I ββam βββgroot": @"I am ββgroot" = 2;
const @"I βam βββgroot": @"I am ββgroot" = 3;
const @"I am βββgroot": @"I am ββgroot" = @"I βββam ββββgroot"(@"I βββam βββgroot", @"I ββam βββgroot", @"I βam βββgroot");
_ = @"I am βββgroot";
}
How the code looks in VS Code:
13 Likes
This is the only way we should code moving forward 
3 Likes
More weird looking code:
const std = @import("std");
const Hello = error{};
const __: ?type = u8;
fn foo(_: Hello!????????????????????????????????????????????????????????????????????????????????????????????????????????????__.?) void {
std.debug.print("Hello world\n", .{});
}
pub fn main() void {
foo(null);
}
3 Likes