yamlscript

Ingy döt Net 2024-05-10T23:36:12.037209Z

For YAMLScript releases I have a make bump rule that runs a script to change the version string in dozens of files. There's a file that defines the files to change and the regexes to be applied, and then a file to do the version bump. These files were written in Bash: • https://github.com/yaml/yamlscript/blob/0.1.58/.version.shhttps://github.com/yaml/yamlscript/blob/0.1.58/util/version-bump Yesterday I rewrote them in YS: • https://github.com/yaml/yamlscript/blob/551ec1959905b806f496a298e2cdb0e23295c3f2/.version.yshttps://github.com/yaml/yamlscript/blob/551ec1959905b806f496a298e2cdb0e23295c3f2/util/version-bump

🎉 2
2024-05-10T04:02:58.741849Z

How can I def a vector in yamlscript? I’m seeing “Sequences (block and flow) not allowed in code mode” when I do row =: [1, 2, 3]

Ingy döt Net 2024-05-10T23:12:01.563399Z

Short answer: row =:: [1, 2, 3] There are many ways to do this (and most things) in YS. Here's a few:

row =: ! [1, 2, 3]
row =:: [1, 2, 3]
row =::
- 1
- 2
- 3
row =: .[1 2 3]
row =: vec(1 .. 3)

Ingy döt Net 2024-05-10T23:12:30.035789Z

I desperately need to finish the basic docs

Ingy döt Net 2024-05-10T23:14:42.416819Z

In YS, every node is either in code mode (where unquoted scalars are ys expressions to be parsed into clojure code) or data mode (where normal YAML semantics take place.

Ingy döt Net 2024-05-10T23:17:08.359569Z

In code mode I decided I really only needed block (indented) mappings and scalars to represent code. So these forms are illegal in code mode (but valid as normal yaml in data mode):

{ foo: bar }  # flow mapping
[ foo, bar ]  # flow sequence
# block sequence:
- foo
- bar

Ingy döt Net 2024-05-10T23:17:50.810459Z

If you see any of those in valid YS then you know its in data mode

Ingy döt Net 2024-05-10T23:20:08.855389Z

now YS support clojure mappings and vector syntax:

say: .[foo bar]
say: .{foo bar}
the leading . is a trick to make the value a string. the . is removed and the rest is parsed as a ys expression (same as clojure here)

Ingy döt Net 2024-05-10T23:20:44.068579Z

the single bang tag ! is a mode toggle between code and data modes

Ingy döt Net 2024-05-10T23:23:21.654399Z

it's a bit ugly so :: does the same things for mapping pair values these are same:

say: ! hello world
say:: hello world
hello world is the string "hello world" because we toggled to data mode. In code mode it would be 2 symbols.

Ingy döt Net 2024-05-10T23:23:58.338789Z

I'll try to get further on the docs this weekend

2024-05-10T04:09:08.876519Z

I want to do a matrix multiplication

2024-05-10T04:09:42.650319Z

Not for speed, just to try out the language