Skip to content

Commit

Permalink
add component for Note & more editing
Browse files Browse the repository at this point in the history
  • Loading branch information
MidAutumnMoon committed Aug 20, 2024
1 parent 320257c commit f5d3e18
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 12 deletions.
31 changes: 31 additions & 0 deletions src/_components/Note.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* A Github styled note blockquote
*/

import { ComponentChildren } from "preact"


type Props = {
children: ComponentChildren,
}

export default function(
{ children }: Props
) {
return <blockquote
class="
not-prose
border-blue-500 border-l-8 border
ps-3 pe-3 py-3
"
>

<p class="text-blue-500 mb-3 flex gap-2">
<span class="icon-[mdi--information-outline] w-6 h-6"></span>
<span class="">Note</span>
</p>

<p>{ children }</p>

</blockquote>
}
15 changes: 10 additions & 5 deletions src/posts/2023/11/notes-on-nixos-in-systemd-nspawn/index.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
title: Notes on NixOS in systemd-nspawn
date: '2023-11-01'
updated: '2023-11-01'
updated: '2024-08-20'
tags:
- linux
- nix
incomplete: true
---

<comp.Note>
This post was originally written during the period that the author is obsessed with Roam Research and Logseq, but unfortunately this writing style made the content really difficult to read on phones so was quickly abandoned.
</comp.Note>

- https://hub.nspawn.org/images/ provides NixOS tarball
- Has a sane default configuration.nix
- Has `boot.loader.initScript.enable = true;` (otherwise nspawn won't be able to boot the system)
Expand All @@ -30,12 +33,14 @@ incomplete: true

- Start the container `machinectl start nickname`

- Configure the inside NixOS
- Configure the guest NixOS
- To access the container `machinectl shell root@nickname`
- Do a channel update
- Do a channel update or flake update[^update]
- Edit `/etc/nixos/configuration.nix`
- Set `services.openssh.enable = true;` so that it looks like being a normal system
- Enable sshd by `services.openssh.enable = true;`
- Change the port to not conflict with the host's sshd
- Do a `nixos-rebuild`

[^update]: This is the most tedious part but motivation isn't enough for me to talk about it.

That should be everything.
23 changes: 18 additions & 5 deletions src/posts/2024/02/history-of-ruby-s-lambda-and-proc/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: History of Ruby's Lambda and Proc
date: '2024-02-27'
updated: '2024-08-17'
updated: '2024-08-19'
tags:
- history
- ruby
Expand All @@ -10,7 +10,7 @@ incomplete: true

Got really confused by Ruby having both `lambda` and `proc` one day. They are the same thing but with different semantics, right? If so, what's reasoning behind this miserable design? If not so, what's the real miserable difference between them?

Author of this post is neither using Ruby at $work, an OK C programmer, a experienced history digger nor even a fluent English writer. So please take everything with a grain of salt Appreciate that!
Author of this post is neither using Ruby at $work, an OK C programmer, a experienced history digger nor even a fluent English writer. So please take everything with a grain of salt. Appreciate that!


# Primitive Era (1994\~200x)
Expand All @@ -30,7 +30,9 @@ test = do tt() using i
end
```

But it was quickly changed to bracket style few months after between `v0.50` and `v0.51` (still in 1994), and its internal name was also changed to `SCOPE` respectively [^relic_sample_but_v0_50].
But it was quickly changed to brace style[^brace_style] few months later in `v0.51` (still in 1994)[^relic_sample_but_v0_50], although it continued to be called `DO` internally.

[^brace_style]: Quick note: Ruby already had hash at this moment, which also uses the brace symbol.

[^relic_sample_but_v0_50]: https://github.com/ruby/ruby/blob/v0_51/sample/t2.rb

Expand All @@ -54,8 +56,15 @@ Matz even expressed himself about this in the changelog[^matz_do_changelog]:
</figcaption>
</figure>

Then in `v0.54`, `DO` was renamed to `ITER` internally, although the implementation seems to be unchanged.

At this moment, neither did `proc` nor `lambda` exist.

Advance to [*version 0.95*](https://github.com/ruby/ruby/tree/v0_95), `Block` got renamed to `Proc` with two methods `proc` and `lambda` added to `Kernel`. At that point, they were [aliased to each other](https://github.com/ruby/ruby/blob/fca49a8a69a0f6bb4feae74c6cd0e93d7fac8b36/eval.c#L3025), and the ambiguity just got planted.


# Ruby 1.0 Era

Passing Ruby *v1.0* through *v1.7*, these two methods remained the same.

> Ruby didn't have a VM back then, and it's really cute to see it doing GC based on AST :)
Expand All @@ -70,6 +79,8 @@ During the lifespan of Ruby *v1.8*, the two global function `proc` and `lambda`

# YARV Era

The complexity of

Then the big *v1.9.0* came where the YARV virtual machine replaced the old interpreter, alongside with loads of language changes, `proc` and `lambda` started to differ from each other for the first time.

Firstly, [their definition](https://github.com/ruby/ruby/blob/816e8751b1dc600dfcca602524182b1d0558bb67/proc.c#L1592) became different which the VM [was aware of](https://github.com/ruby/ruby/blob/816e8751b1dc600dfcca602524182b1d0558bb67/vm.c#L555). Secondly, the VM gained the ability to [allow control flow](https://github.com/ruby/ruby/blob/a3e1b1ce7ed7e7ffac23015fc2fde56511b30681/insns.def#L1368C5) in lambda, although that "lambda" is not the `lambda` being discussed on. The ambiguity is having its leaves grown bigger and more.
Expand All @@ -81,12 +92,14 @@ The ambiguity is fully grown, casting its shadow over all Ruby land.
One last problem is that, there were **one** [huge commit](https://github.com/ruby/ruby/commit/a3e1b1ce7ed7e7ffac23015fc2fde56511b30681) that YARV got merged from sources out-of-tree, so consequently history commits are lost. Worse, the `yarv-dev` mailing list is long gone and non indexable, ultimately I can't answer the question of the title :( Asking Matz himself might be the last resort.


# Conclude
# Conclusion

To conclude, why does Ruby have both `lambda` and `proc` and they differ?
So why does Ruby have both `lambda` and `proc` doing almost the same thing?

Dunno. To my guess, maybe "because we want and we can" and "no one wants to clean up" and "everyone will be mad about breaking changes".

Another thing worth mentioning is that there are a lot of valuable information in the changelog, reading through it is like watching a documentary of animal evolution history (reword)

{/*
1) Even only reading the tiny portion of the Ruby codebase, the reason why Matz regretting introducing threads to Ruby can be quite understandable.
Expand Down
12 changes: 11 additions & 1 deletion src/posts/2024/07/personal-blog-and-e-waste/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,14 @@ Footnote[^fn] might be useful[^fn2] in the future[^future]. By the way, when wri

# MDX

This section demonstrates some of the components of Swoosh.
This section demonstrates some of the components of Swoosh.

## Note, Warning and Caution

Mimic what Github has, ref: https://github.com/orgs/community/discussions/16925

<comp.Note>
Note
</comp.Note>

*Warning and Caution are not yet used.*
2 changes: 1 addition & 1 deletion src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
& blockquote#{$NotProse} {
@apply italic;
@apply border-blue-100 border border-l-8;
@apply ps-2 pe-2 py-1;
@apply ps-3 pe-3 py-1;
@apply text-gray-500 text-balance;

& > * { @apply my-2; }
Expand Down

0 comments on commit f5d3e18

Please sign in to comment.