ときどきの雑記帖″

最新ページへのリンク
目次ページへのリンク

一つ前へ 2014年10月(中旬)
一つ後へ 2014年11月(上旬)

ホームへ

2014年10月30日

■_

FORTRAN が多次元配列のレイアウトに columns major を採用した理由って どこかで書かれてましたっけ? fortran - Row major versus Column major layout of matrices - Computational Science Stack Exchange

■_

■_

stable をチェック。sort 見出しを検索してそれっぽいのが引っかかった。 gawk.git - gawk

gawk.git - gawk
+/* sort_match --- compare leading part of a string against a sort option */
+
+static size_t
+sort_match(const char *str, size_t slen, const char *target)
+{
+	const char *endofword;
+
+	/*
+	 * STR comes from the user and is SLEN characters long;
+	 * if it has spaces then we care about the subset up until
+	 * its first space rather than the full length.
+	 * We check whether STR is the same as--or proper prefix
+	 * of--TARGET.
+	 * Accept "by-foo" or "as-foo" as a synonym match for "foo".
+	 */
+	endofword = strchr(str, ' ');
+	if (endofword != NULL)
+		slen = (size_t) (endofword - str);
+	/* try for exact match */
+	if (slen > 0 && strncasecmp(str, target, slen) == 0)
+		return slen;
+	/* ingore "by-" or "as-" prefix and try again */
+	if (slen > 3
+	    && (strncasecmp(str, "by-", 3) == 0
+		|| strncasecmp(str, "as-", 3) == 0)
+	    && strncasecmp(str + 3, target, slen - 3) == 0)
+		return slen;
+	/* no match */
+	return 0;
+}
+
+/*
+ * sort_selection --- parse user-specified sort ordering
+ * ("ascending index" or "value number" and so forth);
+ * returns a qsort comparison function
+ */
+
+static qsort_compfunc
+sort_selection(NODE *r, const char *warn_arg, int default_by_value)
+{
+	enum sort_bits {
+		unrecognized =    0,
+		Unsorted     = 0x01,
+		Ascending    = 0x02,
+		Descending   = 0x04,
+		by_Index     = 0x08,
+		by_Value     = 0x10,
+		as_String    = 0x20,
+		as_Number    = 0x40,
+		as_Inserted  = 0x80,
+		allbitsused  = 0xff
+	};
+	/*
+	 * The documented values are singular, but it's trivial to accept
+	 * "index numbers" and "descending values" since we're using a
+	 * prefix match.  Latin plural of index is the only complication.
+	 */
+	static const struct sort_keys {
+		const char *const keyword;
+		enum  sort_bits keybit;
+	} sorts[] = {
+		{ "unsorted",   Unsorted    },	/* not part of a three-part key */
+		{ "ascending",  Ascending   },	/* ascending vs descending */
+		{ "descending", Descending  },
+		{ "indexes",    by_Index    },	/* by_Index vs by_Number */
+		{ "indices",    by_Index    },	/* synonym for plural match */
+		{ "values",     by_Value    },
+		{ "strings",    as_String   },	/* as_String vs as_Number */
+		{ "numbers",    as_Number   },
+		{ "numeric",    as_Number   },	/* synonym; singular only */
+		{ "inserted",   as_Inserted },	/* not part of a three-part key */
+		{ "insertion",  as_Inserted },	/* another synonym */
+	};
+
+	static short warned_unrecognized = FALSE;
+	static enum sort_bits prev_invalid = unrecognized;
+
+	char *s;
+	size_t l, matchlen;
+	unsigned i;
+	const char *errfmt;
+	enum sort_bits allparts;
+	qsort_compfunc sort_func, default_sort_func;
+
+	/* deduce our caller from the args provided */
+	if (warn_arg != NULL)		/* for-in statement */
+		default_sort_func = (qsort_compfunc) 0;	/* unsorted */
+	else if (default_by_value)	/* asort() */
+		default_sort_func = sort_up_value;
+	else				/* asorti() */
+		default_sort_func = ! IGNORECASE ? sort_up_index_string
+						: sort_up_index_ignrcase;
+
+	r = force_string(r);
+	s = r->stptr;
+	l = r->stlen;
+
+	/* treat empty sort-order string as request for default */
+	if (l == 0)
+		return default_sort_func;
+
+	/* no ordering specification yet */
+	allparts = unrecognized;
+	/*
+	 * Scan through S until length L is exhausted, checking its
+	 * starting word against each possible ordering choice and
+	 * then skipping past that to get to the next word.  If no
+	 * choice matches, an error has been detected.  Duplicate
+	 * words are accepted; contradictory ones get noticed and
+	 * rejected after the string parsing has completed.
+	 */
+	while (l > 0) {
+		matchlen = 0;	/* lint suppression */
+		for (i = 0; i < (sizeof sorts / sizeof *sorts); ++i) {
+			matchlen = sort_match(s, l, sorts[i].keyword);
+			if (matchlen > 0) {
+				allparts |= sorts[i].keybit;
+				break;
+			}
+		}
+		if (matchlen == 0) {
+			/* failed to match any possible component */
+			allparts = unrecognized;
+			break;
+		}
+		/* move past the part just handled */
+		s += matchlen, l -= matchlen;
+		/* (l > 0) here would accept a trailing space; (l > 1) won't */
+		if (l > 1 && *s == ' ')
+			++s, --l;
+	} /* while (l > 0) */
+
+	/*
+	 * If we have one or two parts of a three part key, fill in
+	 * whichever parts are missing with default values.  For key
+	 * type the default is specified by our caller, for direction
+	 * it is Ascending, and for comparison mode it is as_String
+	 * but only when sorting by_Index.  When sorting by_Value,
+	 * comparison mode is out of the user's control and we don't
+	 * need or want to fill in either as_String or as_Number.
+	 */
+	if ((allparts & (Ascending|Descending|as_String|as_Number)) != 0
+	    && (allparts & (Unsorted|by_Index|by_Value|as_Inserted)) == 0)
+		allparts |= default_by_value ? by_Value : by_Index;
+	if ((allparts & (by_Index|by_Value|as_String|as_Number)) != 0
+	    && (allparts & (Unsorted|Ascending|Descending|as_Inserted)) == 0)
+		allparts |= Ascending;
+	/* by_Value is handled differently from by_Index */
+	if ((allparts & (Ascending|Descending|by_Index)) != 0
+	    && (allparts & (Unsorted|by_Value|as_String|as_Number|as_Inserted)) == 0)
+		allparts |= as_String;
+
略
+	return sort_func;
+}

が、↑では各項目はフルスペルだし、区切りは空白だったりと CodeZin の斉藤さんの記事とは違っている部分が。 それじゃあと、修正ファイルは分かったので先っちょをみてみると

gawk.git - gawk

gawk.git - gawk

/* assoc_list -- construct, and optionally sort, a list of array elements */  

NODE **
assoc_list(NODE *symbol, const char *sort_str, sort_context_t sort_ctxt)
{
	typedef int (*qsort_compfunc)(const void *, const void *);

	static const struct qsort_funcs {
		const char *name;
		qsort_compfunc comp_func;
		assoc_kind_t kind;
	} sort_funcs[] = {
{ "@ind_str_asc",	sort_up_index_string,	AINDEX|AISTR|AASC },
{ "@ind_num_asc",	sort_up_index_number,	AINDEX|AINUM|AASC },
{ "@val_str_asc",	sort_up_value_string,	AVALUE|AVSTR|AASC },
{ "@val_num_asc",	sort_up_value_number,	AVALUE|AVNUM|AASC },
{ "@ind_str_desc",	sort_down_index_string,	AINDEX|AISTR|ADESC },
{ "@ind_num_desc",	sort_down_index_number,	AINDEX|AINUM|ADESC },
{ "@val_str_desc",	sort_down_value_string,	AVALUE|AVSTR|ADESC },
{ "@val_num_desc",	sort_down_value_number,	AVALUE|AVNUM|ADESC },
{ "@val_type_asc",	sort_up_value_type,	AVALUE|AASC },
{ "@val_type_desc",	sort_down_value_type,	AVALUE|ADESC },
{ "@unsorted",		0,			AINDEX },
};

	/*
	 * N.B.: AASC and ADESC are hints to the specific array types.
	 *	See cint_list() in cint_array.c.
	 */

	NODE **list;
	NODE akind;
	unsigned long num_elems, j;
	int elem_size, qi;
	qsort_compfunc cmp_func = 0;
	INSTRUCTION *code = NULL;
	extern int currule;
	int save_rule = 0;
	assoc_kind_t assoc_kind = ANONE;
	
	elem_size = 1;

	for (qi = 0, j = sizeof(sort_funcs)/sizeof(sort_funcs[0]); qi < j; qi++) {
		if (strcmp(sort_funcs[qi].name, sort_str) == 0)
			break;
	}

	if (qi < j) {
		cmp_func = sort_funcs[qi].comp_func;
		assoc_kind = sort_funcs[qi].kind;

		if (symbol->array_funcs != cint_array_func)
			assoc_kind &= ~(AASC|ADESC);

		if (sort_ctxt != SORTED_IN || (assoc_kind & AVALUE) != 0) {
			/* need index and value pair in the list */

			assoc_kind |= (AINDEX|AVALUE);
			elem_size = 2;
		}

	} else {	/* unrecognized */
		NODE *f;
		const char *sp;	

		for (sp = sort_str; *sp != '\0' && ! isspace((unsigned char) *sp); sp++)
			continue;

		/* empty string or string with space(s) not valid as function name */
		if (sp == sort_str || *sp != '\0')
			fatal(_("`%s' is invalid as a function name"), sort_str);

		f = lookup(sort_str);
		if (f == NULL || f->type != Node_func)
			fatal(_("sort comparison function `%s' is not defined"), sort_str);

		cmp_func = sort_user_func;

		/* need index and value pair in the list */
		assoc_kind |= (AVALUE|AINDEX);
		elem_size = 2;

		/* make function call instructions */
		code = bcalloc(Op_func_call, 2, 0);
		code->func_body = f;
		code->func_name = NULL;		/* not needed, func_body already assigned */
		(code + 1)->expr_count = 4;	/* function takes 4 arguments */
		code->nexti = bcalloc(Op_stop, 1, 0);	

		/*
		 * make non-redirected getline, exit, `next' and `nextfile' fatal in
		 * callback function by setting currule in interpret()
		 * to undefined (0).
		 */

		save_rule = currule;	/* save current rule */
		currule = 0;

		PUSH_CODE(code);
	}

	akind.flags = (unsigned int) assoc_kind;	/* kludge */
	list = symbol->alist(symbol, & akind);
	assoc_kind = (assoc_kind_t) akind.flags;	/* symbol->alist can modify it */

	if (list == NULL || ! cmp_func || (assoc_kind & (AASC|ADESC)) != 0)
		return list;	/* empty list or unsorted, or list already sorted */

	num_elems = assoc_length(symbol);

	qsort(list, num_elems, elem_size * sizeof(NODE *), cmp_func); /* shazzam! */

	if (cmp_func == sort_user_func) {
		code = POP_CODE();
		currule = save_rule;            /* restore current rule */ 
		bcfree(code->nexti);            /* Op_stop */
		bcfree(code);                   /* Op_func_call */
	}

	if (sort_ctxt == SORTED_IN && (assoc_kind & (AINDEX|AVALUE)) == (AINDEX|AVALUE)) {
		/* relocate all index nodes to the first half of the list. */
		for (j = 1; j < num_elems; j++)
			list[j] = list[2 * j];

		/* give back extra memory */

		erealloc(list, NODE **, num_elems * sizeof(NODE *), "assoc_list");
	}

	return list;
}

お、こっちは記事通りな指定文字列。でも該当するものが見つからなかったときの /* unrecognized */ な部分の記述、 ソートで使う関数の名前とみなしてる?

■_ YAPC::Asia

最後ってどゆことーと気になったのだけどこういう英語の文章が The Final YAPC::Asia Tokyo — Medium

The Final YAPC::Asia Tokyo — Medium

We just announced the dates to YAPC::Asia Tokyo 2015, and that this is going to be the LAST YAPC::Asia that
we will be holding. I’m coming out of retirement as YAPC organizer to run this one final show.

To be clear what “last YAPC::Asia” means: (1) YAPC::Asia is independent of other YAPCs such as YAPC::NA,
YAPC::EU, etc, so this does not affect them. (2) Anybody is free to hold their own YAPC::Asia, but this just
means we (Japan Perl Association and myself) will not be organizing it anymore.

って牧さんのツイートがあったのね。 そっか十年やったのかー。

2014年10月29日

■_

これが最後のYAPCだ! 「YAPC::Asia Tokyo 2015」は東京ビッグサイトで開催 - ねとらぼ YAPC::Asia Tokyo 2015, Aug 20, 21, 22 20-22 Aug, @Tokyo Big Sight ビッグサイト?! YAPC::Asia Tokyoは世界最大級のエンジニアの手による草の根技術カンファレンスです。これまで9回開催され、様々な技術に関する発表そして技術者同士の出会いを生んできました。 これまでもエンジニアのお祭りとして様々な伝説を生んできたYAPC::Asia Tokyoですが、2015年は記念すべき10回目、そして最後の開催となります。これまで「また来年でいいや…」と思ってパスしてきた皆様も今回を逃すともう次はありませんので2015年は来場必須です! なんと?

■_

こーゆーツイートがあったけど

algorithm - What are the pitfalls in implementing binary search? - Stack Overflow Research Blog: Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken この辺で話題になっている int mid = low + ((high - low) / 2); は関係ないんだろか。

■_

■_

Feedback about the C++ developers choices after the analysis of many C++ open source projects. | CoderGears Blog 10 feedbacks about the C++ developers choices after the analysis of more than 100 of C++ open source projects | CoderGears Blog で挙げられた項目が

  1. No common build system ,Visual Studio, make and CMake are the most widely used
  2. Namesapces not widely used
  3. Inheritance and polymorphism are widely used
  4. Design Patterns not widely used
  5. No common frameworks for the GUI, database access and logging needs.
  6. Smart pointers not enough used
  7. STL widely used , not boost.
  8. Exceptions not widely used
  9. For many projects two or more ways used to represent a string class
  10. New created projects use more the new C++ standards

2014年10月28日

■_

実写パトレイバー長編映画、銃撃戦シーン解禁 | マイナビニュース 遂に片鱗を見せた『パトレイバー長編劇場版』イングラムVSステルス戦闘ヘリ | マイナビニュース 1,000万人を人質に東京を蹂躙するテロリスト集団を相手に、特車二課の隊員たちが立ち向かっていくというストーリーで、 というのを読んで 「ま た か」 と思ったのはナイショだ。 ま、好きなんだけどねw 機動警察パトレイバー アーリーデイズ VOLUME 2. [DVD]
機動警察パトレイバー アーリーデイズ VOLUME 2. [DVD] EMOTION the Best 機動警察パトレイバー2 the Movie [DVD]
EMOTION the Best 機動警察パトレイバー2 the Movie [DVD]

CodeZin の斉藤さんの記事で気になる部分があったので後でチェック。 つーか最近追いかけてなかったわー gawk.git - gawk VC 対応 + その他おまけのローカルパッチはもうつくる気ないんだけどね (C99 前提になってきているので、いちいちそこを直していくのは面倒だしお互い不幸だ)。

■_

■_

二分探索で

■_

わりと面白いこと書いてるblog

2014年10月27日

■_

ちょっと前の半額セール(お題目はなんだったっけ?)で 21st Century C, 2nd Edition - O'Reilly Media を買った。

これの前の版は 21st Century C - O'Reilly Media21st Century C - O'Reilly Media 2012年10月の発売なので、そんなに大きく内容変わってないだろうし スルーでも良いかと思ったのだけど This edition also includes new material on concurrent threads, virtual tables, C99 numeric types, and other features. 辺りが気になったので、半額だしいいやで買ってみたw

そいやこいつって翻訳されてない? O'Reilly Japan - Books :: プログラミング まあ別にいいんだけど。

■_

■_

2014年10月26日

■_

最近は勉強会の類行ってないなあ。と。 とは言え平日の夜開催のは色々辛いところもあるし、 と言って土曜(日曜)午前中からというのもなあなどと。 あと募集開始してすぐ埋まる類のはあまり食指が動かないとか。 ……なんかわがまま放題言ってるなw

某所で書評を見て気になったのでちょっと確かめてみたけど、 他に買う本とこの本の値段と内容を考えるとちょっと保留かなあ… wishlist には入れておこう 乱世から大帝国へ 春秋戦国―秦・漢 (中国人物伝 第I巻)
乱世から大帝国へ 春秋戦国―秦・漢 (中国人物伝 第I巻) 反逆と反骨の精神 三国時代―南北朝 (中国人物伝 第II巻)
反逆と反骨の精神 三国時代―南北朝 (中国人物伝 第II巻)

バスの座席。 運転席のすぐ後ろの席に座っていたのだけど、 後から乗ってきた少年(小学校に上がるか上がらないかくらい?)が 聞こえよがしに「あの席座りたいー」「どいてもらうー」とか駄々捏ねてたのだけど お母さんはちゃんと窘めてたのね。 まああの席は「お子様とご老人はご遠慮ください」てなことが書かれてたりするんだけど、 本人が代わって欲しいと直接言ってきたら代わってあげようかと思ってた。 んが、最後まで駄々コネで終了。 ただしその親子連れが降りた停留所がわたしも降りようと思ってたところだったので 一つ乗り過ごしたのはここだけのはなし。

まんがくらぶオリジナルを、最終号ということで一年半ぶりくらいに買う。 「はるまちダンス」のおねーちゃん達三年生になってたのかー 月刊 まんがくらぶオリジナル 2014年 12月号 [雑誌]
月刊 まんがくらぶオリジナル 2014年 12月号 [雑誌]

■_

2014年10月25日

■_

何事もなかったかのように某コンビニでアフタヌーンの12月号が売られていたので購入。

■_

■_ ALGOL 30?

うぃきぺのBASIC のところを見ていたら 見慣れないもの(プログラミング言語の名)が

Thomas E. Kurtz - Wikipedia, the free encyclopedia

Influence

The road to BASIC itself was a long one. Kemeny and Kurtz had forged DARSIMCO – Dartmouth Simplified Code –
Dartmouth’s inaugural attempt at making a computing language in 1956; however DARSIMCO soon became obsolete
when the language FORTAN manifested itself. In 1962 Kemeny and a Dartmouth undergraduate, Sidney Marshall,
created the language DOPE, Dartmouth Oversimplified Programming Experiment, which was a direct predecessor of
BASIC. DOPE itself was little used, and Kurtz preferred trying to implement successful languages such as
FORTRAN and ALGOL. Kurtz's experience with Dartmouth ALGOL 30 for the LGP-30 convinced hime that devising
subsets of these languages was not quite practical, and this led him to adopt Kemeny’s notion of creating a
new language entirely.

ALGOL 30 ってなに。と思ったらちゃんとウィキペにあった。 Dartmouth ALGOL 30 - Wikipedia, the free encyclopedia

History of Computers and Computing, Birth of the modern computer, Software history, BASIC of John Kemeny and Thomas Kurtz

History of Computers and Computing, Birth of the modern computer, Software history, BASIC of John Kemeny and Thomas Kurtz

The BASIC language was initially based on FORTRAN II, with some influences from ALGOL 60 and with additions to
make it suitable for timesharing systems like DTSS. Initially, BASIC concentrated on supporting straightforward
mathematical work, with matrix arithmetic support from its initial implementation as a batch language and full
string functionality being added by 1965.

ALGOL 60 の影響…

2014年10月24日

■_

■_

■_ off by one

grep.git - grep

grep.git - grep

grep: fix off-by-one bug in -P optimization
Reported by Norihiro Tanaka in: http://bugs.gnu.org/18738
* src/pcresearch.c (Pexecute): Fix off-by-one bug with validation_boundary.
* tests/init.cfg (envvar_check_fail): Catch off-by-one bug.
grep.git - grep

diff --git a/src/pcresearch.c b/src/pcresearch.c
index 6f016b6..1fd5bde 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -214,7 +214,7 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
             options |= PCRE_NO_UTF8_CHECK;
           int valid_bytes = validated - p;
-          if (valid_bytes < 0)
+          if (valid_bytes <= 0)
             {
               e = pcre_exec (cre, extra, p, search_bytes, 0,
               options, sub, NSUB);

おお、確かに>一個外れエラー

2014年10月23日

■_

新出さんが著者のひとりの数理論理学の本、一週間ほど発売予定日が延びた?

■_

2014年10月22日

■_

めもめも。 『美術手帖』11月号はティム・バートン特集 | ニュース - ファッションプレス 2014年11月1日(土)より開催されるティム・バートンの展覧会を前に

こっちは木曜日からと。 「ムーミン」作者トーベ・ヤンソン回顧展が日本巡回 - 著名作に見る、芸術家としての知られざる一面

■_

この話題。 新鋭の言語: この5年を振り返る Emerging Languages: A Look at The Last Five Years はてなブックマーク - 新鋭の言語: この5年を振り返る

rooling をカタカナ書きでツーリングはないんじゃないかなあ 先進的な言語であるにも関わらず、ツーリングが弱点になってしまうのはなぜでしょうか。 原文はこう。 Why is tooling a weak point for many otherwise advanced languages?

tooling で色々あるのだねえ toolingの意味 - 英和辞典 Weblio辞書 ツーリング - Wikipedia Tooling - Wikipedia, the free encyclopedia What is tooling? definition and meaning Tool management - Wikipedia, the free encyclopedia

で、「ツーリング」の他にも気になる部分はいくつかあるんだけど、


最近の記事でEmerging Languages CampのオーガナイザであるAlex Payne氏がこの5年でプログラミング言語の世界が
どのように変わったか、これからどのように変わっていくのかについて考えを披瀝している。InfoQは氏に話を聞いた。

In a recent article, Alex Payne, organizer of the Emerging Languages Camp, provides insight on how the language
landscape has changed in the last five years and how it might change in future. InfoQ has talked with him.

氏は最近の言語の進化の物語とその未来を語る上で手助けになる3つの条件を挙げる。

From his vantage viewpoint, Alex identifies three main criteria that help tell the recent story of language
evolution and understand their future:

    ツールの重要性
    "実装戦略"として仮想マシンを使う
    他言語化

    The importance of tooling.
    Using virtual machines as "implementation strategy".
    Language polyglotism.

最初の方のこの部分だけでも、 The importance of tooling → ツールの重要性 や、 three main criteria → 三つの条件、 Language polyglotism → 他言語化 はちょっとよろしくないんじゃないかなあという気が。

■_

2014年10月21日

■_

Larry Wall: “I can do better, I know how to write a computer language” | Wir sind Techno-Z

■_


一つ前へ 2014年10月(中旬)
一つ後へ 2014年11月(上旬)

ホームへ


リンクはご自由にどうぞ

メールの宛先はこちらkbk AT kt DOT rim DOT or DOT jp