From 09b8483ed67d3b85e983ef86c34260081975e1cb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 2 May 2025 06:47:07 +0900 Subject: fix(blog/nuldoc): remove unnecessary "language" attribute --- .../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 | 22 +++++++++++----------- .../rust-where-are-primitive-types-from/index.html | 8 ++++---- .../index.html | 8 ++++---- .../vim-swap-order-of-selected-lines/index.html | 8 ++++---- 7 files changed, 30 insertions(+), 30 deletions(-) (limited to 'vhosts/blog/public/posts/2021-10-02') diff --git a/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html b/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html index 94b9d8bc..16c466ba 100644 --- a/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html +++ b/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html @@ -73,7 +73,7 @@

タイトル落ち。まずはこのコードを見て欲しい。

-
+
#include <iostream>
 
 [[alignas]] [[alignof]] [[and]] [[and_eq]] [[asm]] [[auto]] [[bitand]]
@@ -138,7 +138,7 @@
           

上のコードでは [[using]] をコメントアウトしているが、これは using キーワードのみ属性構文の中で意味を持つからであり、このコメントアウトを外すとコンパイルに失敗する。

-
+
// using の例
 [[using foo: attr1, attr2]] int x; // [[foo::attr1, foo::attr2]] の糖衣構文
diff --git a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html index db2da17c..c3d48b89 100644 --- a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html +++ b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html @@ -76,7 +76,7 @@

Python でクロージャを作ろうと、次のようなコードを書いた。

-
+
def f():
     x = 0
     def g():
@@ -96,7 +96,7 @@
           

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

-
+
# 注: var は正しい Python の文法ではない。上記参照のこと
 def f():
   var x           #  f の local変数 'x' を宣言
@@ -111,7 +111,7 @@
           

当初の意図を表現するには、次のように書けばよい。

-
+
def f():
     x = 0
     def g():
diff --git a/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html b/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
index b4d41329..b11626c9 100644
--- a/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
@@ -79,7 +79,7 @@
           

上記ページの例から引用する:

-
+
$ ruby-1.9.1 -ve 'p RUBY_ENGINE'
 ruby 1.9.1p0 (2009-03-04 revision 22762) [x86_64-linux]
 "ruby"
@@ -116,7 +116,7 @@
           

mruby 該当部分のソース より引用:

-
+
/*
  * Ruby engine.
  */
diff --git a/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html b/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
index aa5b2781..614957e4 100644
--- a/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
@@ -81,7 +81,7 @@
             

使われることは稀だが、Ruby では then がキーワードになっている。次のように使う:

-
+
if cond then
   puts "Y"
 else
@@ -91,7 +91,7 @@
             

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

-
+
# Example:
 
 if x then
@@ -119,7 +119,7 @@
             

普通 Ruby のコードで then を書くことはない。なぜか。次のコードを実行してみるとわかる。

-
+
if true puts 'Hello, World!' end

@@ -138,7 +138,7 @@

ポイントは改行が then (や ;) の代わりとなることである。true の後に改行を入れてみる。

-
+
if true
 puts 'Hello, World!' end
@@ -151,19 +151,19 @@

なぜ then; や改行 (以下 「then 等」) が必要なのだろうか。次の例を見てほしい:

-
+
if a b end

then; も改行もないのでエラーになるが、これは条件式がどこまで続いているのかわからないためだ。 この例は二通りに解釈できる。

-
+
# a という変数かメソッドの評価結果が truthy なら b という変数かメソッドを評価
 if a then
 b
 end
-
+
# a というメソッドに b という変数かメソッドの評価結果を渡して呼び出し、
 # その結果が truthy なら何もしない
 if a(b) then
@@ -184,7 +184,7 @@
             

https://github.com/ruby/ruby/blob/221ca0f8281d39f0dfdfe13b2448875384bbf735/parse.y#L3961-L3986

-
+
p_case_body : keyword_in
 {
   SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
@@ -215,7 +215,7 @@
             

簡略版:

-
+
p_case_body : keyword_in p_top_expr then compstmt p_cases
 ;
@@ -225,7 +225,7 @@

これにより、case - when による従来の構文と同じように、then 等をパターンの後ろに挿入すればよいことがわかった。つまり次の3通りのいずれかになる:

-
+
case x
 in 1 then a
 in 2 then b
@@ -250,7 +250,7 @@
             

ところで、p_top_expr には if による guard clause が書けるので、その場合は if - then と似たような見た目になる。

-
+
case x
 in 0 then a
 in n if n < 0 then b
diff --git a/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html b/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
index d0d5156c..dffa5173 100644
--- a/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
@@ -72,7 +72,7 @@
             

Rust において、プリミティブ型の名前は予約語でない。したがって、次のコードは合法である。

-
+
#![allow(non_camel_case_types)]
 #![allow(dead_code)]
 
@@ -140,7 +140,7 @@
             

rustc_resolve というのはいかにも名前解決を担いそうなクレート名である。該当箇所を見てみる。

-
+
/// Interns the names of the primitive types.
 ///
 /// All other types are defined somewhere and possibly imported, but the primitive ones need
@@ -185,7 +185,7 @@
             

とある。次はこの struct の使用箇所を追う。追うと言っても使われている箇所は次の一箇所しかない。なお説明に不要な箇所は大きく削っている。

-
+
/// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.
 /// (略)
 fn resolve_ident_in_lexical_scope(
@@ -220,7 +220,7 @@
             

動作がわかったところで、例として次のコードを考える。

-
+
#![allow(non_camel_case_types)]
 
 struct bool;
diff --git a/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html b/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
index 3b9470bb..1d1d97fe 100644
--- a/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
@@ -119,14 +119,14 @@
               

https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L85-L86

-
+
{"BufAdd",      EVENT_BUFADD},
 {"BufCreate",   EVENT_BUFADD},

https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L95-L97

-
+
{"BufRead",     EVENT_BUFREADPOST},
 {"BufReadCmd",  EVENT_BUFREADCMD},
 {"BufReadPost", EVENT_BUFREADPOST},
@@ -134,7 +134,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',
diff --git a/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html b/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
index 1ccc0513..3da75e76 100644
--- a/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
@@ -69,7 +69,7 @@
           

TL; DR

-
+
" License: Public Domain
 
 command! -bar -range=%
@@ -131,7 +131,7 @@
               

なお、:g/^/m0 は全ての行を入れ替えるが、:N,Mg/^/mN-1 とすることで N行目から M行目を処理範囲とするよう拡張できる。手でこれを入力するわけにはいかないので、次のようなコマンドを用意する。

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

前述した :Reverse コマンドの定義を少し変えて、次のようにする:

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

-
+
command! -bar -range=%
     \ Reverse
     \ keeppatterns <line1>,<line2>g/^/m<line1>-1
-- cgit v1.2.3-70-g09d2