aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-04-08 22:53:07 +0900
committernsfisis <nsfisis@gmail.com>2023-04-11 22:06:56 +0900
commit989992278475aefa0f4679d89896cba462f5de9a (patch)
tree76d390c3231079089fdff4d4a908675788c2ef93
parent0ca9e9540dfb4f611aa579293690db0773d376cb (diff)
downloadphpstudy-151-slides-989992278475aefa0f4679d89896cba462f5de9a.tar.gz
phpstudy-151-slides-989992278475aefa0f4679d89896cba462f5de9a.tar.zst
phpstudy-151-slides-989992278475aefa0f4679d89896cba462f5de9a.zip
スライド作成
-rw-r--r--.gitignore1
-rw-r--r--Dockerfile14
-rw-r--r--Makefile28
-rw-r--r--README.md1
-rw-r--r--assets/me.jpegbin0 -> 10890 bytes
-rw-r--r--slide.pdfbin0 -> 205906 bytes
-rw-r--r--slide.saty305
7 files changed, 349 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..19780ee
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/slide.satysfi-aux
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..0cbb1ff
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,14 @@
+FROM amutake/satysfi
+
+RUN opam update && \
+ opam install satysfi-base
+
+RUN opam install satysfi-class-slydifi && \
+ opam install satysfi-code-printer && \
+ opam install satysfi-fonts-noto-sans && \
+ opam install satysfi-fonts-noto-sans-cjk-jp
+
+RUN eval $(opam env) && \
+ satyrographos install
+
+WORKDIR /work
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2e45d1a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+.PHONY: all
+all: slide.pdf
+
+slide.pdf: slide.saty
+ docker run \
+ --rm \
+ --name satysfi \
+ --mount type=bind,src=$$(pwd),dst=/work \
+ satysfi \
+ satysfi slide.saty
+
+.PHONY: shell
+shell:
+ docker run \
+ -it \
+ --rm \
+ --name satysfi \
+ --mount type=bind,src=$$(pwd),dst=/work \
+ satysfi \
+ sh
+
+.PHONY: docker
+docker:
+ docker build --tag satysfi .
+
+.PHONY: clean
+clean:
+ rm -f *.pdf *.satysfi-aux
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a5fffda
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+https://phpstudy.doorkeeper.jp/events/154280
diff --git a/assets/me.jpeg b/assets/me.jpeg
new file mode 100644
index 0000000..4e01020
--- /dev/null
+++ b/assets/me.jpeg
Binary files differ
diff --git a/slide.pdf b/slide.pdf
new file mode 100644
index 0000000..4ecf896
--- /dev/null
+++ b/slide.pdf
Binary files differ
diff --git a/slide.saty b/slide.saty
new file mode 100644
index 0000000..f8f38d5
--- /dev/null
+++ b/slide.saty
@@ -0,0 +1,305 @@
+@require: class-slydifi/theme/akasaka
+@require: code-printer/code-design
+@require: code-printer/code-printer
+@require: code-printer/code-syntax
+@require: code-printer/code-theme
+@require: figbox/figbox
+
+let-block +code-block-php source =
+ '<
+ +code-printer?:(
+ CodePrinter.make-config CodeSyntax.php CodeTheme.iceberg-light
+ |> CodePrinter.set-number-fun CodeDesign.number-fun-null
+ )(source);
+ >
+
+let-block +code-block-c source =
+ '<
+ +code-printer?:(
+ CodePrinter.make-config CodeSyntax.c CodeTheme.iceberg-light
+ |> CodePrinter.set-number-fun CodeDesign.number-fun-null
+ )(source);
+ >
+
+open FigBox
+in
+
+document '<
+ +set-config(|
+ SlydifiThemeAkasaka.default-config with
+ color-emph = Color.black;
+ |);
+
+ +make-title(|
+ title = {
+ |list でない array の末尾を探す
+ |};
+ author = {|nsfisis (いまむら)|};
+ date = {|第151回PHP勉強会@東京|};
+ |);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ +frame{自己紹介}<
+ +fig-center(vconcat [
+ gap 75pt;
+ hconcat [
+ textbox{nsfisis (いまむら)};
+ gap 20pt;
+ include-image 50pt `assets/me.jpeg`;
+ ];
+ gap 20pt;
+ textbox{\@ デジタルサーカス株式会社};
+ ]);
+ >
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ +frame{配列の末尾挿入}<
+ +code-block-php(`<?php
+
+$xs = [1, 2, 3];
+$xs[] = 42;
+assert($xs[3] === 42);
+`#);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ "a" => 1,
+ "b" => 2,
+ "c" => 3,
+];
+$xs[] = 42;
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ "a" => 1,
+ "b" => 2,
+ "c" => 3,
+];
+$xs[] = 42;
+assert($xs[0] === 42);
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ 0 => 1,
+ 1 => 2,
+ 3 => 4,
+];
+$xs[] = 42;
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ 0 => 1,
+ 1 => 2,
+ 3 => 4,
+];
+$xs[] = 42;
+assert($xs[4] === 42);
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ -10 => 1,
+ -7 => 2,
+ -5 => 4,
+];
+$xs[] = 42;
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ -10 => 1,
+ -7 => 2,
+ -5 => 4,
+];
+$xs[] = 42;
+assert($xs[-4] === 42);
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [];
+$xs[10] = 1;
+$xs[] = 42;
+$xs[5] = 2;
+$xs[] = 57;
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [];
+$xs[10] = 1;
+$xs[] = 42;
+$xs[5] = 2;
+$xs[] = 57;
+assert($xs[11] === 42);
+assert($xs[12] === 57);
+`);
+ >
+
+ +section{|php-srcを読む|}<
+ +frame{ZEND_ASSIGN_DIM}<
+ +listing{
+ * \inline-code(`Zend/zend_vm_opcodes.h`);
+ ** PHP の VM (virtual machine) の opcode (operation code) 一覧
+ }
+ >
+
+ +frame{ZEND_ASSIGN_DIM}<
+ +listing{
+ * \inline-code(`Zend/zend_vm_opcodes.h`);
+ ** PHP の VM (virtual machine) の opcode (operation code) 一覧
+ * \inline-code(`ZEND_ASSIGN_DIM`);
+ ** 配列への代入 (assign dimensional)
+ }
+ >
+
+ +frame{ZEND_ASSIGN_DIM}<
+ +listing{
+ * \inline-code(`Zend/zend_vm_opcodes.h`);
+ ** PHP の VM (virtual machine) の opcode (operation code) 一覧
+ * \inline-code(`ZEND_ASSIGN_DIM`);
+ ** 配列への代入 (assign dimensional)
+ * \inline-code(`Zend/zend_vm_def.h`);
+ ** 各 opcode のハンドラが定義されている
+ }
+ >
+
+ +frame{php-srcを読むヒント}<
+ +listing{
+ * \inline-code(`EXPECTED`);
+ ** よく通るパス。最も一般的なケース
+ * \inline-code(`UNEXPECTED`);
+ ** ほとんど通らないパス。エラー処理など
+ }
+ >
+
+ +frame{zend_hash_next_index_insert}<
+ +code-block-c(`value = zend_hash_next_index_insert(
+ Z_ARRVAL_P(object_ptr),
+ value
+);`);
+ +p{※説明のためやや改変}
+ >
+
+ +frame{zend_hash_next_index_insert}<
+ +code-block-c(`zval* zend_hash_next_index_insert(
+ HashTable *ht,
+ zval *pData
+) {
+ return _zend_hash_index_add_or_update_i(
+ ht,
+ ht->nNextFreeElement, /* 挿入先のインデックス */
+ pData,
+ HASH_ADD | HASH_ADD_NEXT
+ );
+}
+`);
+ +p{※説明のためやや改変}
+ >
+
+ +frame{nNextFreeElement}<
+ +listing{
+ * \inline-code(`Zend/zend_hash.c`);
+ * \inline-code(`_zend_hash_index_add_or_update_i()`);
+ }
+ >
+
+ +frame{nNextFreeElement}<
+ +listing{
+ * \inline-code(`Zend/zend_hash.c`);
+ * \inline-code(`_zend_hash_index_add_or_update_i()`);
+ }
+ +p{
+ \inline-code(`array`);に数値のキーで代入したとき、そのキーが\inline-code(`nNextFreeElement`);以上なら、その値+1になる
+ }
+ >
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ "a" => 1,
+ "b" => 2,
+ "c" => 3,
+];
+$xs[] = 42;
+assert($xs[0] === 42);
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ 0 => 1,
+ 1 => 2,
+ 3 => 4,
+];
+$xs[] = 42;
+assert($xs[4] === 42);
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [
+ -10 => 1,
+ -7 => 2,
+ -5 => 4,
+];
+$xs[] = 42;
+assert($xs[-4] === 42);
+`);
+ >
+
+ +frame{PHP クイズ}<
+ +code-block-php(`<?php
+
+$xs = [];
+$xs[10] = 1;
+$xs[] = 42;
+$xs[5] = 2;
+$xs[] = 57;
+assert($xs[11] === 42);
+assert($xs[12] === 57);
+`);
+ >
+
+ +frame{おまけ}<
+ +code-block-php(`<?php
+$xs = [1, 2, 3];
+$xs[] += 10;
+`);
+ +p{末尾代入と複合代入演算子は同時に使える}
+ >
+
+>