HomeUpSign my Guestbook!RSS • Published: 2026-04-16 • Powered by IPFS

Minis


Random things I wanna write down

2026-04 April🔗

2026-04-16 Thursday🔗

Using Org-Mode🔗

Trying out Org-Mode after a while, will try to use it for minis, as that’s probably the simplest way to start gradually.

It should also allow me to easily include:

2026-04-21 Tuesday🔗

Unix Lossage🔗

Back when reading the Unix Hater’s Handbook I learnt a fun little term “Unix Lossage”. It might mean various things to various people, however I’ll use it to generally mean when I accidentally burn time or money due to something I don’t think is entirely my fault.

My First two examples were:

2026-03 March🔗

2026-03-14 Sunday🔗

@ Syntax🔗

Ada has a neat syntax since 2021.

X := @ * 2;

The @ always signifies the LHS of the assignment. Even in more complex situations like this:

Cursor(3, Next) := @ * 2 + Sqrt(@);

It’s a very nice way of doing all the +=, *=, |=, <<=, etc. which seems slightly more readable to me, for the basic cases I still learnt to see :=@+ as a +=, and in the more complex expressions where you don’t actually want to just have the final operation be + the old value, it comes in way more handy.

Ofc doing this with macros is trivial.

OCaml has curried keywords🔗

I spoke about keywords improving readability in an older post.

And actually found something that does it close to what I described.

OCaml calls it “Labelled Arguments”:

# let add ~x ~y = x + y;;
val add : x:int -> y:int -> int = <fun>

# add ~x:2 ~y:4;;
- : int = 6

# add ~y:2 ~x:5;;
- : int = 7

# add ~y:4;;
- : x:int -> int = <fun>

Sadly you can’t do something like add ~x to remove the label from the argument, it’s a labelled argument, it’s a different type and that’s that unless you wrap it in a lambda.

They also have an interesting approach to optional arguments, where you can just skip over them when applying a later label? This of course means you need a sentinel value if there are no non-optional arguments and also that optional arguments come first rather than last.

2026-03-07 Sunday🔗

CFFI Struct Vectors🔗

(asdf:load-system :cffi)

(cffi:defcstruct point
  (x :int)
  (y :int))

(cffi:with-foreign-object (vec '(:struct point) 4)
  (loop
    :with idx := 0
    :for i :to 4
    :do
       (cffi:with-foreign-slots 
         ((x y)
          (cffi:mem-aptr vec '(:struct point) i)
          (:struct point))
         (setf
          x (incf idx)
          y (incf idx))))
  (sb-vm:hexdump vec))

Footnotes🔗

1 Of Quality