Yamd notes

Yamd notes

Those are the notes I took while implementing YAMD crate.

First of all, it is more complex than it looked in the beginning.

The test case for nested lists is failing. I rewrote the deserializer logic multiple times. I rewrote half of the project. Two weeks later - Oh, a space is missing in the test case.

Naming is really hard. How should I name a thing that contains a vector of patterns? Is it a Token?

Most of the nodes do not require context for deserialization. But a few of them, you can only deserialize correctly with context. Adding an optional param to deserialize is a bad idea because that would mean two things. First, I will need to add None to every deserialize call. Second, that would be a longer explanation, so bear with me.

trait deserializer {
 pub fn deserialize(input:&str)->Option<Self>{}
}

I want to add context, right?

Fn deserializer(input: &str, context: <What type should be here?>)

It does not make much sense to specify type here because every node can have it is own context type. Generics will pollute (is that a term?) the tree all the way up.

For now, I am fighting the urge to go and check how it is done in Serde. They should have solved this problem years ago.

You know what? Maybe I do not want to have context. But I want a read-only access to the parent, which will implement some traits.

Ok. I checked Serde. And yes, they had this problem. The solution is Trait serde::de::DeserializeSeed. IDK, it looks like it will have the same problem as the generic context approach from above.

I massaged the idea of a parent instead of context. It does not work, or I did not figure out how to make it work. The problem is:

fn deserialize<Parent>(input: &str, parent: Option<Parent>) -> Option<Self> {
	<what type Parent is?> 
}

It turned out that I needed to pass multiple values in one context. I ended up with a wrapper around HashMap. It may not be the best approach, and I could remove the HashMap in the future, but from what I read, all alternatives will involve some unsafe code, and I do not feel comfortable enough yet. For now, it works, and I can finally finish the List node deserializer.

It may be time to write some documentation.

I just rewrote the matcher for the third time. Maybe using regex is not a bad idea.

Oh, “yamd” is free on crates.io.

Publishing a crate went surprisingly smoothly.

GitHub shows John Hoo as a contributor, which is technically accurate, but he does not know about that.

Now, when I publish those notes, I think I should do that more often. It is a good way to keep track of the project.

Look ma, NO JS!

Look ma, NO JS!

I rewrote my blog without any JS.

YAMD 0.14.0 release

YAMD 0.14.0 release

YAMD stands for - Yet Another MarkDown (flavor) and is a simplified version of CommonMark.

Rust Atomics and Locks by Mara Bos

Rust Atomics and Locks by Mara Bos

I remember that I wanted to read more fiction, but hear me out.