yamlscript

Ingy döt Net 2025-06-30T12:34:36.577829Z

See how YS extends Clojure's truthiness: https://yamlscript.org/blog/2025-06-29/the-truth-about-sunday/

2025-06-30T23:03:32.075259Z

I spend most of my programming time in normalcy, where the canonical truthiness test for empty-is-falsey things, including strings, is (seq x), and if I understand correctly, the exact analog of truey? for seqable things is (not-empty x).

Ingy döt Net 2025-06-30T23:45:57.751469Z

$ ys -e 'x =:: []' -e 'say: 1 x.?' -e 'say: 2 x:truey?' -e 'say: 3 x:seq' -e 'say: 4 x:not-empty' -e 'say: 5 not-empty(x)' -e '=>: (say 6 (not-empty x))'
1 nil
2 nil
3 nil
4 nil
5 nil
6 nil
$ ys -e 'x =:: [42]' -e 'say: 1 x.?' -e 'say: 2 x:truey?' -e 'say: 3 x:seq' -e 'say: 4 x:not-empty' -e 'say: 5 not-empty(x)' -e '=>: (say 6 (not-empty x))'
1 [42]
2 [42]
3 (42)
4 [42]
5 [42]
6 [42]

Ingy döt Net 2025-06-30T23:49:25.042389Z

I think it's nice to have a dual set of primitives for "strict truthiness" and "loose truthiness" Like a || b vs a ||| b

Ingy döt Net 2025-06-30T23:51:08.289049Z

I think Rich even stated somewhere that (seq x) is the one wart required to get the nil punning behavior he desired.

Ingy döt Net 2025-06-30T23:57:41.774779Z

When you're writing code where you are making a lot of decisions based on whether a number is zero or not, or a string or collection is empty or not, it can feel awkward to constantly need to the extra question when you just want yes or no. But other times when you are dealing with boolean questions or nil vs not nil, Clojure's truthiness is great. Sometimes even nil being false is annoying. It's just different solutions for different problems. I don't use one style more than the other (for my YS code), I just have a bigger tool set.

Ingy döt Net 2025-07-01T15:48:21.221839Z

This might be a decent example:

$ ys -pe '42:zero?:not.when(43)'
43
$ ys -pe '42.?.when(43)'
43
clj:
$ ys -ce '42:zero?:not.when(43)'
(when (not (zero? 42)) 43)