HackerTrans
トップ新着トレンドコメント過去質問紹介求人

alurm

no profile record

投稿

Nix Taco Sprint 2026

jrdsgl.com
6 ポイント·投稿者 alurm·16 日前·0 コメント

A generic dynamic array in C that stores no capacity and needs no struct

gist.github.com
27 ポイント·投稿者 alurm·先月·33 コメント

[untitled]

1 ポイント·投稿者 alurm·2 か月前·0 コメント

[untitled]

1 ポイント·投稿者 alurm·11 か月前·0 コメント

Json2dir: a JSON-to-directory converter, a fast alternative to home-manager

github.com
51 ポイント·投稿者 alurm·11 か月前·20 コメント

Moreshell tricks: first class lists, jq, and the es shell

alurm.github.io
41 ポイント·投稿者 alurm·11 か月前·14 コメント

コメント

alurm
·27 日前·議論
Yeah, I've added macros `vec_len` and `vec_ptr` (or, enums, actually), which help somewhat.

`arr[3]` should be flagged by the compiler it is known to the compiler that you're operating on an array.

You can pass `arr` as `&arr` to functions, then compiler will know the length of the array since the type would be `T ()[2]`.

And you can then use it like this:

  void f(int *(*ints)[2]) {
      for (size_t i = 0; i < (size_t)vec_len[*ints]; i++) printf("f: %d\n", vec_ptr[*ints][i]);
  }
Curiously, this is a rare case where the "inverted" `a[b]` requires less typing compared to `(b)[a]`.

A compiler will not be able to flag `vec_len[ints]` though, which is unfortunate.
alurm
·27 日前·議論
Thank you! I implemented this pattern initially about a year ago, but decided to write about it now. Since you liked it, it wasn't for nothing. :)
alurm
·27 日前·議論
You're right, I added some more clarity in the README.

Interestingly, I think my approach will work fine on CHERI, since the pointer is never dereferenced, but I didn't test this. But yeah, there are some architectures where it would fail.
alurm
·27 日前·議論
Good point! Added `vec_ptr[vec]` and `vec_len[vec]` helpers to mitigate this somewhat.
alurm
·27 日前·議論
Thanks for mentioning it, I've heard about stb, but this time around I actually looked at the code. Their approach is very nice.
alurm
·4 か月前·議論
Making a strict subset of some existing language (Go) be a "better C" is quite an interesting idea compared to others (D, Zig, Hare, C3, D, ...), haven't seen it elsewhere. No new syntax. And Go seems to be a pretty good choice for this. Not sure if it's gonna fly though.
alurm
·11 か月前·議論
Yes, but you can generate JSON with other tools easily. home.md describes how you can do it with Nix, but just as easily you can use Cue or something else.

Edit: mentioned this in the README explicitly. Thanks!
alurm
·11 か月前·議論
Yeah, in general (a bit of a tangent), ideas from Plan 9 are really powerful. For example, the Acme text editor exposes it's API as a file system (it's represented via Unix sockets in plan9port, but FUSE is available as well there). It's easy to write scripts to manipulate the editor, and quite fun.
alurm
·11 か月前·議論
Well, if you're generating JSON with Nix, you don't have to put everything inside of one file. It would be a better idea to split it up into multiple. You can also use builtins.readFile for reading config files which don't have to be generated in a complex manner. It's up to you to choose, I just kept everything inside of one file since it makes for a simpler example.

Edit: I have updated the documentation to mention this explicitly, thanks!
alurm
·11 か月前·議論
YSH looks very nice here, thanks. I thought to mention YSH, but have no experience with it, so I hoped you would comment.

(I guess we're duplicating threads at this point :D)
alurm
·11 か月前·議論
Sure.

I have tried Bash namerefs. I found them to be kinda awkward, since you need to name them uniquely. So, you have to pretend that they are global variables, even though they are declared inside a function, which makes their usage verbose.

Here, this could look like:

  split_by_double_dash() {
    declare -n split_by_double_dash_before=$1
    declare -n split_by_double_dash_after=$2
    
    split_by_double_dash_before=()
    split_by_double_dash_after=()

    ...
  }
alurm
·11 か月前·議論
Yeah, PowerShell and nushell are pretty cool, I hope they gain more adoption.
alurm
·12 か月前·議論
Location: Yerevan, Armenia.

Remote: yes.

Willing to relocate: yes.

Technologies: Rust, C/C++, Bash, Go, Linux, Nix.

Résumé/CV: https://alurm.github.io/resume/alan-urmancheev.html (or .pdf for a PDF).

Email: [email protected].

A systems programmer. Prefer US opportunities.