~jturtle

https://jturtle.net

My greatest skill is fucking up patch emails. I will do it in ways you didn't think possible.

~jturtle/public-inbox

Last active 11 months ago
View more

Recent activity

[PATCH harec] typedef: emit struct literals 4 months ago

From jturtle to ~sircmpwn/hare-dev

Now you can do `export def THING: struct_type = (etc);`!
Unions still don't work, more to do elsewhere.

Signed-off-by: jturtle <jturtl@pm.me>
---
 src/typedef.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/typedef.c b/src/typedef.c
index 9991223..167cec7 100644
--- a/src/typedef.c
+++ b/src/typedef.c
@@ -167,6 +167,17 @@ emit_literal(const struct expression *expr, FILE *out)
		xfprintf(out, ")");
[message trimmed]

scdoc: New release? 6 months ago

From JTurtle to ~sircmpwn/public-inbox

Congrats on Hare 0.24.0!

scdoc is the only optional dependency for a complete Hare install, and
the only one that didn't get a stable release along with Hare. Since the
last release two years ago, there have been a few bug fixes, man page
corrections, and code cleanup. I think it's time to do a 1.11.3 release.

But i've never packaged software, sorry if there's a good reason it
hasn't happened.

[PATCH harec v2] lex: allow digit separators 9 months ago

From jturtle to ~sircmpwn/hare-dev

Allows the separator byte '_' to be placed between digits.

Signed-off-by: jturtle <jturtl@pm.me>
---
Implements suggested changes from v1, plus more tests to handle all the edge
cases i could think of. Separators may be placed between two valid
digits, except in type suffixes (like '1u3_2').

 src/lex.c             | 38 ++++++++++++++++++++++++++++++++------
 tests/00-constants.ha | 36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/src/lex.c b/src/lex.c
index 86ca9ac..ee5611d 100644
[message trimmed]

Re: Proposal: digit separator 10 months ago

From JTurtle to ~sircmpwn/hare-dev

My first patch was rejected, which is good because i submitted it
earlier than i should. I'll wait for an authoritative "we're ready, do
it" from someone before trying that stunt again.

I found a more concise way to explain separator restrictions that covers
all the cases (i hope).

"Separators may only be placed between two valid digits, and not within
a type suffix."
Here's a list of invalid numbers according to this rule:
- 1__0
- 0x_ABACA
- 0u6_4
- 0u_64

Re: [PATCH harec] lex: allow digit separators 10 months ago

From JTurtle to ~sircmpwn/hare-dev

Thank you, i'll try again the suggested way and move the tests.

I didn't consider the exponents, and this patch allows separators before
and immediately after the exponent marker in base-10 and base-16, which
is probably not desired.

Underscores before the base specifier, like `0_xFF` would be caught as
"Leading zero in base 10 literal", which isn't the ideal error message
but fixing that seems like a headache.

I should have waited for more discussion around the specifics before
submitting a patch :P

[PATCH harec] lex: allow digit separators 10 months ago

From jturtle to ~sircmpwn/hare-dev

Long number literals can be broken up by `_`. For example: `1_000_000`.
Added some tests too. This isn't covered by the spec yet.
---
 src/lex.c              | 42 ++++++++++++++++++-----
 tests/37-separators.ha | 75 ++++++++++++++++++++++++++++++++++++++++++
 tests/configure        |  3 +-
 3 files changed, 111 insertions(+), 9 deletions(-)
 create mode 100644 tests/37-separators.ha

diff --git a/src/lex.c b/src/lex.c
index 86ca9ac..fbdd6b1 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -236,6 +236,18 @@ next(struct lexer *lexer, struct location *loc, bool buffer)
[message trimmed]

Re: Proposal: digit separator 10 months ago

From JTurtle to ~sircmpwn/hare-dev

I'm glad everyone's on board.

 > Would we want to actually enforce that the digit separator "makes
 > sense", i.e. actually separating the hundreds, thousands, etc?

Neither Rust, C/C++, nor Zig enforce separating by
hundreds/thousands/nibbles/bytes, and i don't think we should either.

 > The easiest way to implement would probably be just to allow and
 > ignore `_` in number literals.

That's the state my implementation is in. But after making it, i've come
up with some reasonable restrictions on where the separator may go:

Proposal: digit separator 10 months ago

From JTurtle to ~sircmpwn/hare-dev

Pre-emptive apologies, if it would have been better to post this in hare-rfc instead.

Digit separators are useful for breaking up long numbers, e.g. in english: 1,000,000,000 is easier to visually parse than 1000000000. They're common in modern programming languages. Even C has a digit separator after C23. 

The most common separator is `_`, as in `1_000_000_000`.
C and C++ use `'` as the separator, as in `1'000'000'000`.

I propose that Hare allows the use of a separator, probably `_`, in integer (and float?) literals. This is a non-breaking change that will ideally only affect the lexer.

Some details worth clarifying before implementation:
- Allow more than one separator in a row, like `1__000_____0`?
- Allow trailing separators, like `1_000_`?
- Allow separators immediately after an integer prefix, like `0x_ACAB`?
- Allow separators before a type suffix, like `420_i32`?

[PATCH scdoc] Emit '\e' instead of '\\' 10 months ago

From jturtle to ~sircmpwn/public-inbox

I noticed that the rc shell's docs are messed up when using
man-db, but fine with mandoc. '\e' is the standard way to emit a
backslash, and the way that makes man-db not cry.
---
 src/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index ca7db55..0030fdc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -208,7 +208,7 @@ static void parse_text(struct parser *p) {
			if (ch == UTF8_INVALID) {
				parser_fatal(p, "Unexpected EOF");
[message trimmed]

[PATCH] Fix for loops in interactive mode 10 months ago

From jturtle to ~sircmpwn/rc-devel

Using a for loop in interactive mode will crash because `state.ctx` is empty.
An implied for loop over $*, like `for (arg) echo $arg` would crash as well
because $* is not set in interactive mode.
---
 interp/exec.ha | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/interp/exec.ha b/interp/exec.ha
index fafa10a..5965e5a 100644
--- a/interp/exec.ha
+++ b/interp/exec.ha
@@ -262,8 +262,9 @@ fn exec_for_loop(state: *state, cmd: *ast::for_loop) (int | error) = {
	defer strings::freeall(iter);
[message trimmed]