4 ms·
I think this is not equivalent because in D, this imports all symbols in the package `std` while in Zig, you just get a "struct" called `std`. I think the equi
by brabel 1y ago
I think this is not equivalent because in D, this imports all symbols in the package `std` while in Zig, you just get a "struct" called `std`. I think the equivalent D is:
import std=std;
- WalterBright 1y agoWhat I wrote is equivalent to the zig declaration. Google says: const my_module = @import("my_module.zig"); This allows you to access pub (public) declarations from my_module.zig through the my_module identifier.
- brabel 1y agoYes, but how is that equivalent? Zig: const std = @import("std"); pub fn main() !void { // std is like a namespace here std.debug.print("Hello, World!\n", .{}); } D: import std.stdio; void main() { // no namespace here, "writeln" and everything else in "std.stdio" is imported writeln("Hello, World!"); } The closest to Zig in D would be: import io = std.stdio; void main() { io.writeln("Hello, World!"); }
- WalterBright 1y agoYou can write in D: std.stdio.writeln("Hello, world!");