From de13d68cddef5bb321469bcffb868f27ddd5390e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 12 Mar 2023 15:12:10 +0900 Subject: style: add .highlight class to pre tag --- .../index.html | 4 ++-- .../python-unbound-local-error/index.html | 6 +++--- .../ruby-detect-running-implementation/index.html | 4 ++-- .../ruby-then-keyword-and-case-in/index.html | 24 +++++++++++----------- .../rust-where-are-primitive-types-from/index.html | 12 +++++------ .../index.html | 10 ++++----- .../vim-swap-order-of-selected-lines/index.html | 8 ++++---- 7 files changed, 34 insertions(+), 34 deletions(-) (limited to 'public/posts/2021-10-02') diff --git a/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html b/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html index 479520e..ae44da9 100644 --- a/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html +++ b/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html @@ -56,7 +56,7 @@ タイトル落ち。まずはこのコードを見て欲しい。

-
+          
             #include <iostream>
 
 [[alignas]] [[alignof]] [[and]] [[and_eq]] [[asm]] [[auto]] [[bitand]]
@@ -126,7 +126,7 @@ std::cout << "Hello, World!" << std::endl;
             上のコードでは[[using]]をコメントアウトしているが、これはusingキーワードのみ属性構文の中で意味を持つからであり、このコメントアウトを外すとコンパイルに失敗する。
           

-
+          
             // using の例
 [[using foo: attr1, attr2]] int x; // [[foo::attr1, foo::attr2]] の糖衣構文
           
diff --git a/public/posts/2021-10-02/python-unbound-local-error/index.html b/public/posts/2021-10-02/python-unbound-local-error/index.html index fa0b1db..27c2d05 100644 --- a/public/posts/2021-10-02/python-unbound-local-error/index.html +++ b/public/posts/2021-10-02/python-unbound-local-error/index.html @@ -60,7 +60,7 @@ Python でクロージャを作ろうと、次のようなコードを書いた。

-
+          
             def f():
 x = 0
 def g():
@@ -84,7 +84,7 @@ f()
             local変数xが代入前に参照された、とある。これは、fxを参照するのではなく、新しく別の変数をg内に作ってしまっているため。 前述のコードを宣言と代入を便宜上分けて書き直すと次のようになる。varを変数宣言のための構文として擬似的に利用している。
           

-
+          
             # 注: var は正しい Python の文法ではない。上記参照のこと
 def f():
 var x           #  f の local変数 'x' を宣言
@@ -101,7 +101,7 @@ g()
             当初の意図を表現するには、次のように書けばよい。
           

-
+          
             def f():
 x = 0
 def g():
diff --git a/public/posts/2021-10-02/ruby-detect-running-implementation/index.html b/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
index 08700c4..ed7ccd5 100644
--- a/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
+++ b/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
@@ -65,7 +65,7 @@
             上記ページの例から引用する:
           

-
+          
             $ ruby-1.9.1 -ve 'p RUBY_ENGINE'
 ruby 1.9.1p0 (2009-03-04 revision 22762) [x86_64-linux]
 "ruby"
@@ -192,7 +192,7 @@ jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [i386-java]
             mruby 該当部分のソースより引用:
           

-
+          
             /*
 * Ruby engine.
 */
diff --git a/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html b/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
index 1def6b6..9b1df47 100644
--- a/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
+++ b/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
@@ -65,7 +65,7 @@
               使われることは稀だが、Ruby ではthenがキーワードになっている。次のように使う:
             

-
+            
               if cond then
   puts "Y"
   else
@@ -77,7 +77,7 @@
               このキーワードが現れうる場所はいくつかあり、ifunlessrescuecase構文がそれに当たる。 上記のように、何か条件を書いた後thenを置き、式がそこで終了していることを示すマーカーとして機能する。
             

-
+            
               # Example:
 
 if x then
@@ -107,7 +107,7 @@ end
               普通 Ruby のコードでthenを書くことはない。なぜか。次のコードを実行してみるとわかる。
             

-
+            
               if true puts 'Hello, World!' end
             
@@ -115,7 +115,7 @@ end
次のような構文エラーが出力される。

-
+            
               20:1: syntax error, unexpected local variable or method, expecting `then' or ';' or '\n'
   if true puts 'Hello, World!' end
   ^~~~
@@ -131,7 +131,7 @@ end
               ポイントは改行がthen(や;) の代わりとなることである。trueの後に改行を入れてみる。
             

-
+            
               if true
 puts 'Hello, World!' end
             
@@ -147,7 +147,7 @@ puts 'Hello, World!' end なぜthen;や改行 (以下 「then等」) が必要なのだろうか。次の例を見てほしい:

-
+            
               if a b end
             
@@ -155,14 +155,14 @@ puts 'Hello, World!' end
then;も改行もないのでエラーになるが、これは条件式がどこまで続いているのかわからないためだ。 この例は二通りに解釈できる。

-
+            
               # a という変数かメソッドの評価結果が truthy なら b という変数かメソッドを評価
 if a then
 b
 end
             
-
+            
               # a というメソッドに b という変数かメソッドの評価結果を渡して呼び出し、
 # その結果が truthy なら何もしない
 if a(b) then
@@ -188,7 +188,7 @@ end
               https://github.com/ruby/ruby/blob/221ca0f8281d39f0dfdfe13b2448875384bbf735/parse.y#L3961-L3986
             

-
+            
               p_case_body : keyword_in
   {
   SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
@@ -221,7 +221,7 @@ end
               簡略版:
             

-
+            
               p_case_body : keyword_in p_top_expr then compstmt p_cases
 ;
             
@@ -234,7 +234,7 @@ end これにより、case-whenによる従来の構文と同じように、then等をパターンの後ろに挿入すればよいことがわかった。つまり次の3通りのいずれかになる:

-
+            
               case x
 in 1 then a
 in 2 then b
@@ -261,7 +261,7 @@ end
               ところで、p_top_exprにはifによる guard clause が書けるので、その場合はif-thenと似たような見た目になる。
             

-
+            
               case x
 in 0 then a
 in n if n < 0 then b
diff --git a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
index 8879a79..8bcb923 100644
--- a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
+++ b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
@@ -55,7 +55,7 @@
               Rust において、プリミティブ型の名前は予約語でない。したがって、次のコードは合法である。
             

-
+            
               #![allow(non_camel_case_types)]
 #![allow(dead_code)]
 
@@ -111,7 +111,7 @@ struct str;
               rustcはセルフホストされている (=rustc自身が Rust で書かれている) ので、boolcharなどで適当に検索をかけてもノイズが多すぎて話にならない。 しかし、お誂え向きなことにi128/u128というコンパイラ自身が使うことがなさそうな型が存在するのでこれを使ってgit grepしてみる。
             

-
+            
               $ git grep "\bi128\b" | wc      # i128
 165    1069   15790
 
@@ -126,7 +126,7 @@ $ git grep "\bbool\b" | wc      # cf. bool の結果
               165 程度であれば探すことができそうだ。今回は、クレート名を見ておおよその当たりをつけた。
             

-
+            
               $ git grep "\bi128\b"
 ...
 rustc_resolve/src/lib.rs:        table.insert(sym::i128, Int(IntTy::I128));
@@ -137,7 +137,7 @@ rustc_resolve/src/lib.rs:        table.insert(sym::i128, Int(IntTy::I128));
               rustc_resolveというのはいかにも名前解決を担いそうなクレート名である。該当箇所を見てみる。
             

-
+            
               /// Interns the names of the primitive types.
 ///
 /// All other types are defined somewhere and possibly imported, but the primitive ones need
@@ -186,7 +186,7 @@ Self { primitive_types: table }
               とある。次はこの struct の使用箇所を追う。追うと言っても使われている箇所は次の一箇所しかない。なお説明に不要な箇所は大きく削っている。
             

-
+            
                   /// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.
 /// (略)
 fn resolve_ident_in_lexical_scope(
@@ -226,7 +226,7 @@ None
               動作がわかったところで、例として次のコードを考える。
             

-
+            
               #![allow(non_camel_case_types)]
 
 struct bool;
diff --git a/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html b/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
index 5fc12fc..db28b1c 100644
--- a/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
+++ b/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
@@ -112,7 +112,7 @@
                 https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L85-L86
               

-
+              
                     {"BufAdd",      EVENT_BUFADD},
 {"BufCreate",   EVENT_BUFADD},
               
@@ -121,7 +121,7 @@ https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L95-L97

-
+              
                     {"BufRead",     EVENT_BUFREADPOST},
 {"BufReadCmd",  EVENT_BUFREADCMD},
 {"BufReadPost", EVENT_BUFREADPOST},
@@ -131,7 +131,7 @@
                 https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L103-L105
               

-
+              
                     {"BufWrite",    EVENT_BUFWRITEPRE},
 {"BufWritePost",    EVENT_BUFWRITEPOST},
 {"BufWritePre", EVENT_BUFWRITEPRE},
@@ -148,7 +148,7 @@
                 https://github.com/neovim/neovim/blob/71d4f5851f068eeb432af34850dddda8cc1c71e3/src/nvim/auevents.lua#L119-L124
               

-
+              
                   aliases = {
 BufCreate = 'BufAdd',
 BufRead = 'BufReadPost',
@@ -161,7 +161,7 @@ FileEncoding = 'EncodingChanged',
                 ところで、上では取り上げなかったFileEncodingだが、これは:help FileEncodingにしっかりと書いてある。
               

-
+              
                                                                            *FileEncoding*
 FileEncoding                    Obsolete.  It still works and is equivalent
 to |EncodingChanged|.
diff --git a/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html b/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
index afe6ba9..8a3b304 100644
--- a/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
+++ b/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
@@ -115,7 +115,7 @@
                 なお、:g/^/m0は全ての行を入れ替えるが、:N,Mg/^/mN-1とすることで N行目から M行目を処理範囲とするよう拡張できる。手でこれを入力するわけにはいかないので、次のようなコマンドを用意する。
               

-
+              
                 command! -bar -range=%
 \ Reverse
 \ <line1>,<line2>g/^/m<line1>-1
@@ -152,7 +152,7 @@
               前述した:Reverseコマンドの定義を少し変えて、次のようにする:
             

-
+            
               function! s:reverse_lines(from, to) abort
   execute printf("%d,%dg/^/m%d", a:from, a:to, a:from - 1)
   endfunction
@@ -211,7 +211,7 @@
               

-
+            
               command! -bar -range=%
   \ Reverse
   \ keeppatterns <line1>,<line2>g/^/m<line1>-1
@@ -230,7 +230,7 @@
           
           

コピペ用再掲

-
+            
               " License: Public Domain
 
   command! -bar -range=%
-- 
cgit v1.2.3-70-g09d2