Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tab whitespace character to be placed inside of string and command #22030

Open
rxvoid opened this issue Nov 20, 2024 · 0 comments
Open

Comments

@rxvoid
Copy link

rxvoid commented Nov 20, 2024

Description

Currently, the 'dev' (or maybe even the previous) version of Zig doesn't allow tab whitespace character (not tab escape sequence) to be placed inside of a string and a command. That would make programming in Zig a little bit harder, as Zig allow tabs to be used as indentation but doesn't allow it to be placed inside of a command, because I (and I believe many other devs) use command as a way to temporary mark some piece of code as unused and so I can change it later or maybe just for debugging purpose without ever deleting it. Zig also doesn't allow tabs inside of a string, that would also make indentation for terminal output or any other work that needs string indentation a little bit harder as we need to use '\t' escape sequence or even worse we have to manually use spaces so we can see the final string in our code editor when we code it.

Zig Version

0.14.0-dev.2245+4fc295dc0

Steps to Reproduce and Observed Output

Consider the following code:

const std = @import("std");

pub fn main() void {
	const price = 80;
	std.debug.print("Price:		${}", .{ price }) catch {};
	// switch (comptime @import("builtin").cpu.arch.endian()) {
	// 	.big    => std.debug.print("BIG."),
	// 	.little => std.debug.print("little.")
	// }
}

When we compile it, the compiler will produce the following error message:

test.zig:5:18: error: expected expression, found 'invalid token'
 std.debug.print("Price:  ${}", .{ price }) catch {};
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When we change the string indentation to either '\t' or spaces, we'll get the following error:

test.zig:7:2: error: expected statement, found 'invalid token'
 //  .big    => std.debug.print("BIG."),
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected Output

Zig should allow tabs inside of string and command, and the code above should work and compile fine without any compilation error.

@rxvoid rxvoid changed the title Allow tab whitespace character to be inside of string and command Allow tab whitespace character to be placed inside of string and command Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant