@["0x103cb8a08@[118, 116, 127, 127, 123, 225, 221, 123, 222, 127, 126, 69, 131, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225]\n", "0x103cb8a68@[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n", "0x103cb8ac8@[118, 116, 127, 127, 123, 225, 221, 123, 222, 127, 126, 142, 220, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225]\n", "0x103cb8b28@[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// runs as expected with Node v22.1.0, [email protected], [email protected] | |
// $ npm install ix rxjs | |
/* global require setTimeout */ | |
// Rx | |
const {Subject} = require('rxjs'); | |
const {tap: rxTap} = require('rxjs/operators'); | |
// Ix |
@["0x103cae228@[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 48, 49, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]\n", "0x103cae288@[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 48, 50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]\n", "0x103cae2e8@[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 48, 51, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]\n", "0x103cae348@[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 48, 52, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
$ cd /opt/local/lib | |
$ otool -L libunistring.2.dylib | |
libunistring.2.dylib: | |
/opt/local/lib/libunistring.2.dylib (compatibility version 5.0.0, current version 5.0.0) | |
/opt/local/lib/libiconv.2.dylib (compatibility version 9.0.0, current version 9.1.0) | |
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1853.0.0) | |
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0) | |
$ otool -L libdeflate.0.dylib |
when (NimMajor, NimMinor, NimPatch) >= (1, 4, 0): | |
{.push raises:[].} | |
else: | |
{.push raises: [Defect].} | |
import chronos except `?` | |
import stew/results except `?` | |
export chronos except `?` | |
export results except `?` |
#!/usr/bin/env bash | |
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}' |
I wanted to share my "first big macro" in Nim (and it actually works, but still cleaning some things ups); has been an interesting experience:
Some helpful things I learned, in case you need/want to write your own Nim macros:
When you've got a macro where you're passing in a body: untyped
(usually the last param, and not necessarily called "body" but that's common), you can print it to the screen in the compile-time output with e.g.
echo()
echo(treeRepr body)
import os, threadpool | |
type | |
ThreadSafeString* = distinct cstring | |
proc safe*(input: string): ThreadSafeString = | |
var res = cast[cstring](allocShared(input.len + 1)) | |
copyMem(res, input.cstring, input.len) | |
res[input.len] = '\0' | |
res.ThreadSafeString |
import os, stew/faux_closures, threadpool | |
type | |
MyString* = distinct cstring | |
proc mine*(input: string): MyString = | |
input.cstring.MyString | |
proc `$`*(input: MyString): string = | |
$(input.cstring) |
import os, stew/faux_closures, threadpool | |
type | |
Sob = ref object | |
key: int | |
type | |
Rob = ref object | |
sub: Sob |