ときどきの雑記帖 混迷編

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

一つ前へ 2011年2月(下旬)
一つ後へ 2011年3月(中旬)

ホームへ

2011年03月10日

■_

のら犬兄弟のギョーカイ時事放談! ちょっと長いけど(全部で80分くらい)、今回の配信(第137回)はオススメ。 エンジニアの身の振り方の参考になる部分もあると思います (大体40分あたりのところかな)。

■_ COBOLは不滅…か?

【超初心者】プログラミング質問スレ【基礎】part4 

179 デフォルトの名無しさん [] 2011/03/10(木) 10:54:12.37 ID: Be:
    COBOL勉強中の商業高校1年生です。
    COBOL不要論などがあるなかでCOBOLを勉強する意味はありますか?

    プログラムを学ぶ上で初心者が入りやすいということですか? 

180 デフォルトの名無しさん [sage] 2011/03/10(木) 11:04:08.55 ID: Be:
    プログラマを目指すならどのちみちあらゆる言語に触れることになる
    そのどれもが無駄だとは思わない
    HSPを除いては 

181 デフォルトの名無しさん [sage] 2011/03/10(木) 11:05:01.58 ID: Be:
    >>179
    COBOLとJavaを知っていると、結構仕事があるかもしれない。Javaの。 

182 デフォルトの名無しさん [sage] 2011/03/10(木) 11:05:29.46 ID: Be:
    初心者向けじゃねえよ。
    料金明細か簿記とかを出力するのに特化してるだけ。
    変わった言語で、現代の主流ではない。
    変な癖がつく。
    選ばずに済むならやめておけ。 

183 デフォルトの名無しさん [sage] 2011/03/10(木) 11:31:36.05 ID: Be:
    >>182
    来年度COBOLで情報処理検定1級取るために
    情報の授業は全てCOBOLです。
    いま2級もってます。
    COBOLを勉強するのは避けられません。

    どうしようも無いんでしょうか?

184 デフォルトの名無しさん [sage] 2011/03/10(木) 11:35:51.70 ID: Be:
    >>181
    Javaは何も知らないorz 

185 デフォルトの名無しさん [sage] 2011/03/10(木) 11:37:38.93 ID: Be:
    簿記とかやるなら無駄にはならないんじゃね
    プログラマとかになる気ならCOBOLの勉強は最低限にして、
    独学で主流なCやJavaなどをやっておいた方がいいのでは 

186 デフォルトの名無しさん [sage] 2011/03/10(木) 11:47:13.79 ID: Be:
    そういうことだな。
    一級取れなくても高校の単位には関係が無い。
    プロを目指すならCOBOLより他が得意なほど勉強しとけ。


187 デフォルトの名無しさん [sage] 2011/03/10(木) 12:03:07.94 ID: Be:
    うちも情報処理のためにCOBOLの授業があったな
    理由はCOBOLでうけるほうが複雑な問題が出ないのでうかりやすいんだとか
    COBOLerジジイをクビにできないから教壇に立たせるためにしてんじゃねえかと当時思った
    俺は無視してCを選択してうかったけどな
    おこられたけど
    卒業したらCOBOLなんて役に立たないからばっさり捨ててしまえ 

192 デフォルトの名無しさん [sage] 2011/03/10(木) 12:44:34.39 ID: Be:
    定期考査でCOBOLでるから
    ばっさり捨ててしまうのは無理なんですよね

    まぁ簿記やってるから後々やくに立つのかな? 

193 デフォルトの名無しさん [sage] 2011/03/10(木) 12:49:12.77 ID: Be:
    卒業してからも定期考査があるのか
    たいへんだな 

194 デフォルトの名無しさん [sage] 2011/03/10(木) 12:55:44.58 ID: Be:
    >>193
    まだ高校1年なんですよね(;^ω^) 

195 デフォルトの名無しさん [sage] 2011/03/10(木) 13:00:30.57 ID: Be:
    結局何が聞きたかったんだ?世間話したかっただけ? 

196 デフォルトの名無しさん [sage] 2011/03/10(木) 13:01:42.57 ID: Be:
    将来どうするのかだ。学校の成績あげたければやったほうがいい。
    プログラマやるなら別のをやったほうがいい。 

206 デフォルトの名無しさん [sage] 2011/03/10(木) 20:13:38.80 ID: Be:
    未だに高校生にCOBOLを教えてる化石高校があるんだなぁ
    教師が化石だから仕方ないだろうけど
    ちゃんと時代に即したカリキュラムにしてやるべき 

207 デフォルトの名無しさん [sage] 2011/03/10(木) 20:15:52.88 ID: Be:
    pc98使ってそう 

208 デフォルトの名無しさん [sage] 2011/03/10(木) 21:32:56.50 ID: Be:
    >>207
    PC-98なら、BASICだな。
    最近の厨は知らないだろうが、未だ、オフコンとか大型ではCOBOLが多い。 

多分教える側の…げふんげふん。

■_ given

given って switch-case 型の構文で使うあれだよね。 複数の意味を持たせてるのか。

Perl 6 IO Tablet / Perl 6

open

Synopsis:

    open('new', :w).close


    given open('foo', :w) { # "Anonymous" filehandle

        .say('Hello, world!');
        .close

    }

ぱっとみて、最後の .close なしでもRubyのブロックのように 自動でクローズしてはくれないのかなあと思った。 無名だし、外へ渡す手段もないっぽいから手動にするメリットあるんだろうか。

■_ gawk

FUTUREES ってファイルを見てみた。

  Copyright (C) 2005, 2006, 2010 Free Software Foundation, Inc.
  
  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.

This file lists future projects and enhancements for gawk.  Items are listed
in roughly the order they will be done for a given release.  This file is
mainly for use by the developers to help keep themselves on track, please
don't bug us too much about schedules or what all this really means.

With the 3.0 release, we are acknowledging that awk is not PERL, nor should
it become PERL.  (To paraphrase Dennis Ritchie, "If you want PERL, you
know where to get it.")

The focus on the future is thus narrowed to performance and functional
enhancements, with only minor plans for significant new features.

(OK, so 3.1 had a bad case of feature-itis.  I think I'm mostly over it
now, though. :-)

For 3.1.8 + bytecode
====================
	DONE: Performance fixes / improvements

	DONE: Change @sourcefile to @include per awk.info poll

	DONE: Document @include

	DONE: Update copyrights

	DONE: Document dgawk

For 4.0 (4.0へ向けて)
=======
	DONE: Add a single letter option for all long options & document them.
        完了: すべてのロングオプションに対して対応する一文字オプションを追加し、
              ドキュメントに記載する。

	DONE: Add an FPAT variable and patsplit function where the regex
	describes the fields, not the separators.
        完了: FPAT 変数および patsplit 関数を追加する

	DONE: Remove support for all unsupported systems.
        完了: サポートされていないすべてのシステムを削除する

	DONE: Remove all old README* files.
        完了  古い README* ファイル群の削除

	DONE: Remove --copyleft, leaving just --copyright.
        完了  --copyleft を削除し、--copyright だけを残した。

	DONE: Enable \s, \S in regexes (regcomp.c and dfa.c) and document them.
        完了  正規表現中での \s と \S を有効にし(regcomp.cとdfa.c)、ドキュメントに記載した。

	DONE: Integrate byte code changes and dgawk
		Indirect functions
		BEGINFILE, ENDFILE

	DONE: Simplify awk.h.
        完了  awk.hの単純化

	Consider moving var_value info into Node_var itself
	to reduce memory usage.

	Consider removing use of and/or need for the protos.h file.

	DONE: Make POSIX 2001 behavior the default for sub/gsub.

	DONE: Add IPv6 support.
        完了  IPv6サポートの追加

	DONE: Add true multidimensional arrays.
        完了  本物の多次元配列の追加

	Gnulib?

	DONE: Move to git.
        完了  gitへの移行

	Additional manual features:
		Remove all page breaks
		Review internal notes about reorganization
		DONE: Full front to back read through - before editing
		Full front to back read through - after editing

For 4.1 (4.1へ向けて)
=======
	Implement designed API for loadable modules
        ローダブルモジュール向けに設計されたAPIの実装

	Merge xmlgawk -l feature
        xmlgawk の -l の機能をマージする

	Merge xmlgawk XML extensions
        xmlgawk の XML 拡張をマージする

	Redo the loadable modules interface from the awk level.
        ローダブルモジュールのインターフェースを awk レベルからやり直す

	Rework management of array index storage. (Partially DONE.)

	DBM storage of awk arrays. Try to allow multiple dbm packages.
        awkの配列を DBM storage に置く。複数の dbmパッケージを許可できるようにする。

	? Move the loadable modules interface to libtool.
          loadable モジュールのインターフェースを libtool へ移行

	? Add an optional base to strtonum, allowing 2-36.
          2から36を許可する strtonumに対する(省略可能な)基数の追加

	? Optional third argument for index indicating where to start the search.
          検索の開始位置を指定するindexのための(省略可能な)第三引数

	?? A RECLEN variable for fixed-length record input. PROCINFO["RS"]
	would be "RS" or "RECLEN" depending upon what's in use.
        固定長レコードの入力を扱うための変数 RECLEN。

	?? Use a new or improved dfa and/or regex library.

For 4.x:
========
	Look at ISO C 99 printf features.

Probably never: (おそらくやらないこと)
===============
	Do an optimization pass over parse tree?

	Consider integrating Fred Fish's DBUG library into gawk.

	Make 	awk '/foo/' files...	run at egrep speeds (how?)

	? Have strftime() pay attention to the value of ENVIRON["TZ"]

	Add a lint check if the return value of a function is used but
	the function did not supply a value.

	Additional manual features:
		? A section on where gawk is bounded
			regex
			i/o
			sun fp conversions

  

■_

Amazon.co.jp: プログラミングの宝箱 アルゴリズムとデータ構造 第2版: 紀平 拓男, 春日 伸弥: 本 というのを近刊リストで見かけて、どんなんだったかなあと調べる Amazon.co.jp: プログラミングの宝箱 アルゴリズムとデータ構造 (C magazine): 紀平 拓男, 春日 伸弥: 本 あ、これか。 まあ中身次第だなあ。

2011年03月09日

■_

行ってきました
ASCII.jp:総数3650枚以上! 「よつばとひめくり」展覧会開催中 「よつばと10年1日展」行ってきました。 - 三軒茶屋 別館 『よつばとひめくり』展覧会 よつばと10年1日展に行ってきたよ - アンバランスな日々に

10年分の日めくりは圧巻でした。デジカメを持っていかなかったので(会社帰りに行ったし) 写真は撮りませんでしたが、 上のリンク先の記事にあるように実物大ダンボーがあってこれだけは撮影OKでした。

入場券 このほかにもいろいろありました ノベルティ購入時に袋を断るとこのカードがもらえます

■_ J

予告通り公開されたようです。

J Source

J Source is available under GPL 3.

Download j701_b_source.tar.gz to [temp].

$ cd ~
$ tar -xzf [temp]/j701_b_source.tar.gz
$ cd jgplsrc
$ cat docs/readme.txt

Join the source forum. Have fun!

J Source - Commercial

J Source is also available under Commercial license. Contact us for more information 
if a license without GPL restrictions is of interest.

ダウンロードした .gz の大きさは割りと小さな印象が。 tar tvf してみると

drwxr-xr-x eric/staff        0 2011-03-07 00:22 jgplsrc/
-rw-r--r-- eric/staff     5896 2011-03-07 00:24 jgplsrc/a.c
-rw-r--r-- eric/staff     2304 2011-03-07 00:24 jgplsrc/a.h
-rw-r--r-- eric/staff     8822 2011-03-07 00:24 jgplsrc/ab.c
-rw-r--r-- eric/staff     2855 2011-03-07 00:24 jgplsrc/af.c
-rw-r--r-- eric/staff    13446 2011-03-07 00:24 jgplsrc/ai.c
-rw-r--r-- eric/staff     8232 2011-03-07 00:24 jgplsrc/am.c
-rw-r--r-- eric/staff     7983 2011-03-07 00:24 jgplsrc/am1.c
-rw-r--r-- eric/staff     5809 2011-03-07 00:24 jgplsrc/amn.c
-rw-r--r-- eric/staff    19924 2011-03-07 00:24 jgplsrc/ao.c
-rw-r--r-- eric/staff    22363 2011-03-07 00:24 jgplsrc/ap.c
-rw-r--r-- eric/staff    24724 2011-03-07 00:24 jgplsrc/ar.c
-rw-r--r-- eric/staff     2608 2011-03-07 00:24 jgplsrc/ar.h
-rw-r--r-- eric/staff    12899 2011-03-07 00:24 jgplsrc/as.c
-rw-r--r-- eric/staff     2832 2011-03-07 00:24 jgplsrc/au.c
drwxr-xr-x eric/staff        0 2011-03-07 00:22 jgplsrc/bin/
-rw-r--r-- eric/staff     1110 2011-03-07 00:24 jgplsrc/c.c
-rw-r--r-- eric/staff     9012 2011-03-07 00:24 jgplsrc/ca.c
-rw-r--r-- eric/staff    26791 2011-03-07 00:24 jgplsrc/cc.c
-rw-r--r-- eric/staff    17671 2011-03-07 00:24 jgplsrc/cd.c
-rw-r--r-- eric/staff     8284 2011-03-07 00:24 jgplsrc/cf.c
-rw-r--r-- eric/staff     7115 2011-03-07 00:24 jgplsrc/cg.c
(略)

小さなファイルが何百とありますね。 テストのためのものもたくさんありますが。 今週末にでもビルドを試してみようかな。 ってどうビルドするのかまだぜんぜん見ていない。

reddit での反響。

J (Programming Language) Released Under GPL3 : programming


Since short file names are quite inscrutable, here is an index of source files.

http://sparcs.kaist.ac.kr/~tinuviel/temp/jgplsrc


yikes look at those filenames. wonder why they don't include this index as an h file 
or readme in the actual source?


Look at docs/ioj - there's a code tour inside.


ah thanks. i had grepped for cpdtsp.c since that was in the list from sanxiyn, but 
that happens to be one of the files iojFiles.htm doesn't list!


it looks like slackware software sets haha


My DRDOS 6 and MSDOS 3.3 virtual machines would approve except there is exactly 1 file 
that breaks the 8-3 rule: "vgranking.c"

So they didn't do it because of that. I don't even.

Ok, this easily tops the perl interpreter as the most impenetrable code base ever.


You clearly haven't seen Malbolge. :)


I bet a Malbolge interpreter is more readable or easier to understand than this J 
interpreter, unless it's written in Malbolge itself.

That said, I'm also joking a bit, in the sense that it seems looking at the source 
that the C code is written in a way to be as similar to J as possible, with all kinds 
of macros and terse single letter functions. To someone knowledgeable in J it may be 
easier to read but it's a bit of a clusterfuck to everyone else.

さくっと略


I tend to agree with this-- they don't do the best job selling it and sometimes come 
across as cultish. I've been meaning for a while to put together a big table of code 
snippets or simple expressions in MATLAB versus how they look in J. They are both APL 
descendants (MATLAB less genuinely so), and most people familiar with array 
programming these days probably are MATLAB users. But I think a short, quantitative 
list of ways that J is better than MATLAB would be a good quick overview for those who 
haven't heard of J.


Wikipedia link

http://www.jsoftware.com/help/primer/contents.htm

From the examples in Wikipedia:
* Quicksort simple version

 quicksort=: verb define
   if. 1 >: #y do. y
   else.
    (quicksort y <sel e),(y =sel e),quicksort y >sel e=.y{~?#y
   end.
  )

* Quicksort using tacit programming

  quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)


=:O

うはっ。読めねーw 雰囲気はまあわからんでもないか。

■_ C++ を嫌う C プログラマーたちへ

訳してる時間ねーーーっ

For C programmers that hate C++

For C programmers that hate C++
C++ を嫌う C プログラマーたちへ


Over the years, I've seen way too many C programmers declare that they hate C++. They 
have their reasons, I'm sure. It is my humble opinion, however, that their hatred is... 
wrong. It took me quite some time (years) to slowly understand what is good and what 
is bad about C++, and I think the best way to consolidate my C++ experience is this:

何年もの間、わたしは自分がC++を嫌っていると公言している多くのCプログラマーを
見てきました。彼らは彼らなりに理由があってそういっているのだろうと思います。
とはいうもののわたしの思うところでは、彼らの持つ嫌悪感というのは間違っている
のではないかと考えるのです。C++ について、なにが優れていてなにが劣っているのかを
理解するのはわたしにとっては数年かかるようなものでした。そして、
わたしの C++ の経験を consolidate (補強?) する最善の方法を考えついたのです:

C++ allows you to write less code, with no run-time overhead, and with more safety, 
than C does.

C++ はCよりも少ないコードで、実行時のオーバーヘッドなしに、また、より安全に
書くことを可能にします。

The less code you write, the better. As you gain experience by writing more and more 
code for your projects, you will inevitably realize that brevity is a virtue: You fix 
a bug in one place, not many - you express an algorithm once, and re-use it in many 
places, etc. (Greeks even have a saying, traced back to the ancient Spartans: "to 
say something in less words, means that you are wise about it"). And the fact of 
the matter is, that when used correctly, C++ allows you to express yourself in far 
less code than C does.

少ないコードで済ませることはとてもよいことです。
プロジェクトのためにコードをたくさん書けば書くほど経験を得るにつれて、
必然的に簡潔さは美徳であることを認識するようになります。
ひとつのバグを複数の箇所ではなく一箇所で修正する。
アルゴリズムを一度だけ表現し、それを複数の場所で再利用する。
などなど。
(Greeks even have a saying, traced back to the ancient Spartans:
"to say something in less words, means that you are wise about it").
そして重要な事実は、正しく使った場合には
C++ は C を使った場合よりも格段に高い表現力をもたらすということです。


Other languages offer this advantage, too - especially the ones from the functional 
programming world. But only C++ does this without costing you runtime speed. At all.

他の言語もまたこのアドバンテージを提供します。特に関数プログラミング世界から来た言語は。
けれども、C++ のみはこの実行時のスピードについてのアドバンテージの対価を
支払う必要がないのです。

Finally, compared to C, C++ is a lot more safe - that is, it catches more errors at 
compile-time.

結局のところ、Cと比べた場合にC++は格段に安全な言語、つまり、コンパイル時に
より多くのエラーを捕捉するものなのです。

Let's look at a simplified version of a problem I faced with my renderer: While 
drawing triangles on the screen, and depending on the currently selected drawing mode, 
the algorithm must interpolate different values across a triangle's scanline: It must 
start from an X coordinate x1, and reach an X coordinate x2 (from the left to the 
right side of a triangle), and across each step, that is, across each pixel it passes 
over, it must interpolate various "stuff".

さてここで、わたしが自分のレンダラーで直面したある問題を単純化したものを見てみること
にしましょう。スクリーン上に三角形を描画する間に、その時点で選択されている描画モード
に依存して、そのアルゴリズムでは三角形のスキャンラインと交差する異なる値を
interpolate しなければなりません。


    * When interpolating the ambient light that reaches the pixel:

        typedef struct tagPixelDataAmbient {
          float ambientLight;
          int x;
        } PixelDataAmbient;

        ...
        // inner loop
        currentPixel.ambientLight += dv;
        

    * When interpolating the vertex colors (called "Gouraud" shading, where 
      the "red", "green" and "blue" fields are interpolated
      by a step value at each pixel):

        typedef struct tagPixelDataGouraud {
          float red;
          float green;
          float blue;  // The RGB color interpolated per pixel
          int x;
        } PixelDataGouraud;

        ...
        // inner loop
        currentPixel.red += dred;
        currentPixel.green += dgreen;
        currentPixel.blue += dblue;

    * When rendering in "Phong" shading, neither intensity (ambientLight) nor color
      (red/green/blue) is the target - instead, a normal vector (nx,ny,nz) is interpolated at
      each step, and the lighting equation is re-calculated at each pixel, based on the
      interpolated normal vector:

        typedef struct tagPixelDataPhong {
          float nX;
          float nY;
          float nZ; // The normal vector interpolated per pixel
          int x;
        } PixelDataPhong;

        ...
        // inner loop
        currentPixel.nX += dx;
        currentPixel.nY += dy;
        currentPixel.nZ += dz;

        // lighting equation uses interpolated normal value...

So, how would we continue in C?

さて、C ではこのあとをどのように続けるのでしょうか?

Well, some C programmers would go "heck, lets write 3 functions that interpolate 
the values, and call them depending on the set mode".

"heck, lets write 3 functions that interpolate the values,
and call them depending on the set mode"
(値を interpolate する三つの関数を書いて、set mode に応じてそれらを呼ぶ)
しようとする C プログラマーたちも中にはいるでしょう。

But that makes us realize that we have a type problem - what is the type we work with? 
Are the pixels PixelDataAmbient? PixelDataGouraud? PixelDataPhong?

けれどもそれは、型の問題があることをわたしたちに思い知らせるのです。
わたしたちが使おうとしている型とはいったいなんでしょうか?
pixels は PixelDataAmbient でしょうか? それとも PixelDataGouraud でしょうか?
はたまた PixelDataPhong でしょうか?


Oh, wait, the efficient C programmer says, use a union!

ちょっと待って。有能な C プログラマーは union があると主張するでしょう。

  typedef union tagSuperPixel {
    PixelDataAmbient a;
    PixelDataGouraud g;
    PixelDataPhong   p;
  } SuperPixel;

..and then, you have a "poly"-function...

RasterizeTriangleScanline(
  enum mode, // { ambient, gouraud, phong }
  SuperPixel left,
  SuperPixel right)
{
  int i,j;
  if (mode == ambient) {
    // handle pixels as ambient...
    int steps = right.a.x - left.a.x;
    float dv = (right.a.ambientLight - left.a.ambientLight)/steps;
    float currentIntensity = left.a.ambientLight;
    for (i=left.a.x; i<right.a.x; i++) {
      WorkOnPixelAmbient(i, dv); currentIntensity+=dv;
    }
  } else if (mode == gouraud) {
    // handle pixels as gouraud...
    int steps = right.g.x - left.a.x;
    float dred = (right.g.red - left.g.red)/steps;
    float dgreen = (right.g.green - left.g.green)/steps;
    float dblue = (right.g.blue - left.g.blue)/steps;
    float currentRed = left.g.red;
    float currentGreen = left.g.green;
    float currentBlue = left.g.blue;
    for (j=left.g.x; i<right.g.x; j++) {
      WorkOnPixelGouraud(j, currentRed, currentBlue, currentGreen);
      currentRed+=dred;
      currentGreen+=dgreen;
      currentBlue+=dblue;
    }
  } else if (mode == ...

The code above must make the hairs on your neck stand up. Can you feel the chaos slipping in?
以下略 

500件近く。 For C programmers that hate C++ : programming

■_

■_

正規表現についての質問です。 ^/pc/($|index(\-[0-9]+)?\.html) これはどういう意... - Yahoo!知恵袋

正規表現についての質問です。

  ^/pc/($|index(\-[0-9]+)?\.html)

これはどういう意味になるんでしょうか? 

んー。html のあとに $ ついてないのは意図的なんだろうか。 入力の情報がもう少しないとなんともいえない部分はあるけど 微妙に間違っているような。 あと、- はエスケープする必要ねえッ

2011年03月08日

■_

家に帰ってきて、 夕食やら何やら済ませてそこから何時間あってそれで何ができるか とか考えるとなんというか暗澹たる気分にならなくもない。 日暮途遠。

■_

NEWSを見ると、バージョンが4.0になってんだけど 3.1.80とかいうのとどっちを信じれば? いやまあ 80ってのは αとかβってことなんだろうけど。

   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
   
   Copying and distribution of this file, with or without modification,
   are permitted in any medium without royalty provided the copyright
   notice and this notice are preserved.
 
Changes from 3.1.8 to 4.0.0
---------------------------

1. The special files /dev/pid, /dev/ppid, /dev/pgrpid and /dev/user are
   now completely gone. Use PROCINFO instead.

   特殊ファイル /dev/pid, /dev/ppid, /dev/pgrpid, /dev/user といったものは
   完全になくなりました。代わりに PROCINFO を使ってください。

2. The POSIX 2008 behavior for `sub' and `gsub' are now the default.
   THIS CHANGES BEHAVIOR!!!!

   'sub' や 'gsub' のデフォルトの振る舞いが POSIX 2008 のそれになりました。

3. The \s and \S escape sequences are now recognized in regular expressions.

   エスケープシーケンス \s および \S が正規表現中で認識されるようになりました。

4. The split() function accepts an optional fourth argument which is an array
   to hold the values of the separators.

   split() 関数は省略可能な第四引数を受け取るようになりました。
   この引数はセパレーター群の値を格納するための配列です。

5. New -b / --characters-as-bytes option that means "hands off my data"; gawk
   won't try to treat input as a multibyte string.

   -b / --characters-as-bytes オプションが、"hands off my data" を意味する
   ようになりました。gawk はその場合入力がマルチバイト文字列として扱おうとはしません。

6. New --sandbox option; see the doc.

7. Indirect function calls are now available.

8. Interval expressions are now part of default regular expressions for
   GNU Awk syntax.

9. --gen-po is now correctly named --gen-pot.

10. switch / case is now enabled by default. There's no longer a need
    for a configure-time option.

    switch / case がデフォルトで有効になり、configure 時にオプションで
    指定する必要はなくなりました。

11. Gawk now supports BEGINFILE and ENDFILE. See the doc for details.

    BEGINFILE と ENDFILE をサポートしました。詳しくはドキュメントを参照してください。

12. Directories named on the command line now produce a warning, not
    a fatal error, unless --posix or --traditional.

    --posix オプションもしくは --traditional オプションが指定されていない限り
    コマンドラインで与えられたディレクトリ名に対して fatal error ではなく
    警告を発します。

13. The new FPAT variable allows you to specify a regexp that matches
    the fields, instead of matching the field separator. The new patsplit()
    function gives the same capability for splitting.

    新しい変数 FPAT は、フィールドセパレーターにマッチする正規表現ではなく
    フィールドの内容にマッチする正規表現の指定を可能にします。新しい関数
    patsplit() はsplitting に対して同じ効果を与えます。

14. All long options now have short options, for use in `#!' scripts.

15. Support for IPv6 added via /inet6/... special file. /inet4/... forces
    IPv4 and /inet chooses the system default (probably IPv4).

16. Added a warning for /[:space:]/ that should be /[[:space:]]/.

    /[:space:]/ に対して /[[:space:]]/ ではないかという警告を出すようになりました。

17. Merged with John Haque's byte code internals. Adds dgawk debugger and
    possibly improved performance.

18. `break' and `continue' are no longer valid outside a loop, even with --traditional.

    --traditional をつけた場合であっても、ループの外側に置かれた break や
    continue は不正なものとなりました。

19. POSIX character classes work with --traditional (BWK awk supports them).

    --traditional を指定した場合でもPOSIXのキャラクタークラスが使えます

20. Nuked redundant --compat, --copyleft, and --usage long options.

21. Arrays of arrays added. See the doc.

    配列の配列が追加されました。詳しくはドキュメントを。

22. Per the GNU Coding Standards, dynamic extensions must now define
    a global symbol indicating that they are GPL-compatible. See
    the documentation and example extensions.
    THIS CHANGES BEHAVIOR!!!!

23. In POSIX mode, string comparisons use strcoll/wcscoll.
    THIS CHANGES BEHAVIOR!!!!

    POSIXモードの場合、文字列比較には strcoll や wcscoll を使用します。

24. The option for raw sockets was removed, since it was never implemented.

    raw ソケットのためのオプションは、実装されなかったので取り除かれました。

25. If not in POSIX mode, gawk turns ranges of the form [d-h] into
    [defgh] before compiling a regexp.  Maybe this will stop all the
    questions about [a-z] matching uppercase letters.
    THIS CHANGES BEHAVIOR!!!!

    POSIX モードでない場合、gawk は [d-h] という範囲指定を、正規表現を
    コンパイルするより前に [defgh] と変換します。これにより、おそらく
    [a-z] が大文字にマッチするという質問が止むことでしょう。

26. PROCINFO["strftime"] now holds the default format for strftime().

    PROCINFO["strftime"] は strftime() のためのデフォルトフォーマットを
    保持するようになりました。

27. Updated to latest infrastructure: Autoconf 2.68, Automake 1.11.1,
    Gettext 0.18.1, Bison 2.4.3.

28. Many code cleanups. Removed code for many old, unsupported systems:

    多くのコードをクリーンアップ。古いもの、サポートされていないものを削除。

	- Atari
	- Amiga
	- BeOS
	- Cray
	- MIPS RiscOS
	- MS-DOS with Microsoft Compiler
	- MS-Windows with Microsoft Compiler
	- NeXT
	- SunOS 3.x, Sun 386 (Road Runner)
	- Tandem (non-POSIX)
	- Probably others that I've forgotten
  

VC使ったWindows版のメンテナーいたはずだけどなあ。 知らぬ間に退任してたんだろか。

一個前のも。

Changes from 3.1.7 to 3.1.8
---------------------------
1. The zero flag no longer applies to %c and %s; apparently the standards
   changed at some point.

2. Updated to latest infrastructure: Autoconf 2.65, Automake 1.11.1,
   libtool 2.2.6b, Bison 2.4.2.

3. Failure to open a socket is no longer a fatal error.

4. dfa.h and dfa.c are now more-or-less in sync with GNU grep, for the first
   time in many years.

5. Gawk no longer includes its own copy of libsigsegv but it will use it if
   installed on the build system. The --disable-libsigsegv configure option
   is now gone.

6. The ' flag (%'d) is now just ignored on systems that can't support it.

7. Lots of bug fixes, see the ChangeLog.


  

■_ /

ふらっとC#,C♯,C#(初心者用) Part70

434 デフォルトの名無しさん [] 2011/03/05(土) 22:00:41.99 ID: Be:
    \が¥ってのはキツイな 

435 デフォルトの名無しさん [sage] 2011/03/05(土) 22:05:25.17 ID: Be:
    >>434
    あの辺は中途半端にガラパゴスでパソコンが普及しちゃったのが原因だっけ?
    アスキーコードの後半部分に半角カナとか勝手に拡張しちゃうし・・・ 

436 デフォルトの名無しさん [sage] 2011/03/05(土) 22:12:27.25 ID: Be:
    当時はまだマイコンと言っていてだな・・・ 

437 デフォルトの名無しさん [sage] 2011/03/05(土) 22:17:51.89 ID: Be:
    >>435
    むしろ日本はアメリカのポチだけあってASCIIとほぼ同じ割り当てじゃん。
    ヨーロッパなんか{}とかもないんだよw 

440 デフォルトの名無しさん [sage] 2011/03/05(土) 22:21:04.96 ID: Be:
    というか、昔持ってた技術評論社の「C言語辞典」によると、
    確か記号部分はISOでも各国が勝手に割り当ててよいルールになってたということだと思ったけど。

    もちろんこのルールより先に各国バラバラという現実があって、ルールはその事実の追認という可能性もあるけど 

441 デフォルトの名無しさん [] 2011/03/05(土) 22:23:17.16 ID: Be:
    一番大きかったのはCP/M86でパス区切り文字を”\”にしたことだね
    それのクローンであるMS-DOSも同じく”\”を採用

    UNIXと同じ”/”の何処が不味かったんだよ 

442 デフォルトの名無しさん [sage] 2011/03/05(土) 22:23:50.61 ID: Be:
    追認・・・
    難しい言葉使うんだな
    頭良さそう

    もしかして低学歴にゃプログマラは無理? 

443 デフォルトの名無しさん [sage] 2011/03/05(土) 22:28:12.87 ID: Be:
    Windowsは/もパス区切りとして認識するけどね
    コマンドプロンプトは駄目だけど 

444 441 [] 2011/03/05(土) 22:35:12.66 ID: Be:
    もしかするとCP/Mって名前だったから、/をパス区切り文字にするとOS名が表記できなかったからなのかな?
    それならばCP/Mって名前を付けたのが諸悪の根源? 

445 デフォルトの名無しさん [sage] 2011/03/05(土) 22:36:22.03 ID: Be:
    >>444
    ありえるw 

448 デフォルトの名無しさん [sage] 2011/03/05(土) 22:55:21.66 ID: Be:
    >>444
    意味が分からんわ
    文字列の出力とファイルのパスなんも関係ねぇ 

MS-DOS は「CP/M-86」のクローンじゃないし(CP/Mがベース)。 んで、パスの区切りが / でないのは、コマンドラインスイッチに / を使っていたのと コマンド名/A/E/X みたいな指定を使えるようにするため。 じゃあなかったかな。 システムコールのレベルでは / でも使えたりしたし(DOSのバージョンによってはまあ いろいろあるのはおいといて)。

C のエスケープ文字とかぶったのはまあ不幸でしたね。と。

■_

■_

infoから。

4.7 Defining Fields By Content
    (内容によってフィールドを定義する)
==============================

(This minor node discusses an advanced feature of `awk'.  If you are a
novice `awk' user, you might want to skip it on the first reading.)

Normally, when using `FS', `gawk' defines the fields as the parts of
the record that occur in between each field separator. In other words,
`FS' defines what a field _is not_, instead of what a field _is_.
However, there are times when you really want to define the fields by
what they are, and not by what they are not.

通常 'FS' を使ったときに 'gawk' はフィールドをフィールドセパレータの間にあるレコードの
一部分として定義します。言い換えると、'FS'はフィールド「である」ものではなく、フィール
ド「ではない」ものを定義するのです。ところが、何がフィールドであるかということで定義を
したい要求が何度となく出ていました。


  The most notorious such case is so-called "comma separated value" (CSV) data.
  Many spreadsheet programs, for example, can export their data into text files,
  where each record is terminated with a newline, and fields are separated by
  commas. If only commas separated the data,there wouldn't be an issue. The
  problem comes when one of the fields contains an _embedded_ comma. While there
  is no formal standard specification for CSV data(1), in such cases, most
  programs embed the field in double quotes. So we might have data like this:

  その最もよく知られている例が CSV (comma separated value) と呼ばれるデータです。
  たとえば多くのスプレッドシートプログラムで、データを各レコードが改行で終端され
  フィールドがカンマで分割されているテキストファイルとしてエクスポートできます。
  このときカンマだけがデータを分割するのであれば問題はありませんが、フィールドに
  カンマが“埋め込まれている”場合に困った事態になります。CSVデータに関する標準規
  格は存在しないのですが(1) 、大部分のプログラムはそういったフィールドをダブルクォ
  ートで囲みます。そのため、データが次のようなものになる可能性があります。

    Robbins,Arnold,"1234 A Pretty Street, NE",MyTown,MyState,12345-6789,USA

  The `FPAT' variable offers a solution for cases like this.  The value of `FPAT'
  should be a string that provides a regular expression.  This regular expression
  describes the contents of each field.

  変数 'FPAT' はこういったケースに対する解決策を提供します。'FPAT' の値は正規表現を
  表す文字列にするのがよいでしょう。その正規表現は各フィールドの内容を describes
  します。

  In the case of CSV data as presented above, each field is either
"anything that is not a comma," or "a double quote, anything that is
not a double quote, and a closing double quote."  If written as a
regular expression constant (*note Regexp::), we would have
`/([^,]+)|("[^"]+")/'.  Writing this as a string requires us to escape
the double quotes, leading to:

上記のようなCSVデータの場合、各フィールドは “カンマではないもの”もしくは
“ダブルクォートで始まり、ダブルクォートでないもの、そしてダブルクォートで
終わるもの”のようになります。固定正規表現として記述すれば `/([^,]+)|("[^"]+")/'
のようになるでしょう。これを文字列として記述する場合にはダブルクォートをエ
スケープする必要があります。


    FPAT = "([^,]+)|(\"[^\"]+\")"

  Putting this to use, here is a simple program to parse the data:

    BEGIN {
        FPAT = "([^,]+)|(\"[^\"]+\")"
    }

    {
        print "NF = ", NF
        for (i = 1; i <= NF; i++) {
            printf("$%d = <%s>\n", i, $i)
        }
    }

  When run, we get the following:
  実行すると、以下のような出力を得ます:

    $ gawk -f simple-csv.awk addresses.csv
    NF =  7
    $1 = <Robbins>
    $2 = <Arnold>
    $3 = <"1234 A Pretty Street, NE">
    $4 = <MyTown>
    $5 = <MyState>
    $6 = <12345-6789>
    $7 = <USA>

  Note the embedded comma in the value of `$3'.
 '$3'の中身にある埋め込まれたカンマに注意してください。

  A straightforward improvement when processing CSV data of this sort would be to
  remove the quotes when they occur, with something like this:

  この種のCSVデータを処理するときの straightforward な改良は、以下のようにしてクォ
  ートされたデータが出現したときにそれを取り除くというものです。


    if (substr($i, 1, 1) == "\"") {
        len = length($i)
        $i = substr($i, 2, len - 2)    # Get text within the two quotes
    }

  As with `FS', the `IGNORECASE' variable (*note User-modified::)
  affects field splitting with `FPAT'.

  'FS'を使った場合と同じく、'IGNORECASE' 変数は 'FPAT'を使ったフィールド
  分割に影響を及ぼします。

  Similar to `FIELDWIDTHS', the value of `PROCINFO["FS"]' will be `"FPAT"'
  if content-based field splitting is being used.

  `FIELDWIDTHS' と同様に、内容ベースのフィールド分割を使用しているときには
  `PROCINFO["FS"]' の値が`"FPAT"' となります。


    NOTE: Some programs export CSV data that contains embedded
    newlines between the double quotes.  `gawk' provides no way to
    deal with this.  Since there is no formal specification for CSV
    data, there isn't much more to be done; the `FPAT' mechanism
    provides an elegant solution for the majority of cases, and the
    `gawk' maintainer is satisfied with that.

    注意: ダブルクォートに挟まれた埋め込み改行を含む CSV データをエクスポート
    するプログラムも中にはあります。'gawk' はそういったデータを扱う手段を提供
    していません。CSV データに対する正式な仕様 (formal specification) という
    ものがないために改行を含んだデータをただ単に処理する以上のものはありません。
    'FPAT'機構は多くの場合に対して elegat な手法を提供しているので、'gawk' の
    メンテナーはそれで充分だと考えているのです。


  As written, the regexp used for `FPAT' requires that each field have a least
  one character.  A straightforward modification (changing changed the first
  `+' to `*') allows fields to be empty:

  すでに書いているように、'FPAT'に使用する正規表現は各フィールドに対して少なく
  とも一つのキャラクターがあることを要求しています。空のフィールドを可能にする
  ための straightforward な修正 (最初の '+' を '*' に変更する) は次のようなも
  のです:


    FPAT = "([^,]*)|(\"[^\"]+\")"

  Finally, the `patsplit()' function makes the same functionality
  available for splitting regular strings (*note String Functions::).

  最後に、'patsplit()'という関数は、通常の文字列の分割で同一機能を使える
  ようにするものです。

  ---------- Footnotes ----------

  (1) At least, we don't know of one.
  
`patsplit(STRING, ARRAY [, FIELDPAT [, SEPS ] ]) #'
    Divide STRING into pieces defined by FIELDPAT and store the pieces
    in ARRAY and the separator strings in the SEPS array.  The first
    piece is stored in `ARRAY[1]', the second piece in `ARRAY[2]', and
    so forth.  The third argument, FIELDPAT, is a regexp describing
    the fields in STRING (just as `FPAT' is a regexp describing the
    fields in input records).  It may be either a regexp constant or a
    string.  If FIELDPAT is omitted, the value of `FPAT' is used.
    `patsplit()' returns the number of elements created.  `SEPS[I]' is
    the separator string between `ARRAY[I]' and `ARRAY[I+1]'.  Any
    leading separator will be in `SEPS[0]'.

    STRINGを FIELDPAT の定義に従って分割してその分割結果の本体を配列 ARRAY
    に、セパレーター文字列を配列 SEPS に格納します。最初の piece は 'ARRAY[1]'
    に、二番目の piece は 'ARRAY[2]' に格納され、そしてそのあとも同様に続きま
    す。関数の第三引数 FIELDPAT はSTRING中のフィールドを describe する正規表
    現です (入力レコードに対する'FPAT'と同様のものです)。この引数は固定正規表
    現 (regexp constant) と文字列のいずれかにできます。FIELDPAT が省略された
    場合には 'FPAT' の値が使われます。'patsplit()' はその戻り値として生成され
    た要素の数を返します。'SEPS[I]' は 'ARRAY[I]' と 'ARRAY[I+1]' の間の
    separator string です。第一フィールドより前の部分は 'SEPS[0]' に格納されます。

    The `patsplit()' function splits strings into pieces in a manner
    similar to the way input lines are split into fields using `FPAT'.

    'patsplit()' 関数は 'FPAT'を使って入力行をフィールド群へと分割するのと
    同様の manner で 文字列を分割します。

    Before splitting the string, `patsplit()' deletes any previously
    existing elements in the arrays ARRAY and SEPS.

    文字列の分割に先立って、'patsplit()' は 配列 ARRAY および SEPS にある既存
    の要素をすべて削除します。

    The `patsplit()' function is a `gawk' extension.  In compatibility
    mode (*note Options::), it is not available.

    この'patsplit()'関数は 'gawk' の拡張です。互換モードでは使用できません。

  

2011年03月07日

■_

まとめのところで力尽きて翌日回しになることが多いなあ。最近。 どこもやる気の素は枯渇しているようだ。

■_ Optimizing VBA

色々検索しているうちに見つけたページ。 全部は(まだ)試してないけど、確かに効果あった。

range.Cells(c, r) の .Cells って要らなかったのか。

Optimize VBA

   Optimizing VBA
   VBA を最適化する

This page lists some suggestions and strategies for optimizing your Visual Basic For 
Applications (VBA) code, so that it will run faster.   There are few absolute rules 
for optimizing VBA;  you'll see the best increases in performance by streamlining the 
basic logic.


Accessing Cells In A Range
範囲中のセルにアクセス

You do not need to use the .Cells method to access specific cells in a range.  For 
example, you can use

ある範囲にある特定のセルにアクセスするのに .Cell メソッドを使う必要はありません。
たとえば

Range("MyRange")(1,2)   rather than
Range("MyRange").Cells(1,2)

後者ではなく前者のように記述できます

See Alan Beban's explanation of this method for more details.

Related to this is the shortcut method of refering to cells.  VBA will allow you 
reference cells with [A1] rather than Range("A1"). While the [A1] syntax is 
easier to type, it is slower to execute than the Range("A1") syntax.


Calculation Mode
計算モード

Normally, Excel will recalculate a cell or a range of cells when that cell's or 
range's precedents have changed.  This may  cause your workbook to recalculate too 
often, which will slow down performance.  You can prevent Excel from recalculating the 
workbook by using the statement:

    Application.Calculation = xlCalculationManual

At the end of your code, you can set the calculation mode back to automatic with the 
statement:

    Application.Calculation = xlCalculationAutomatic

Remember, though, that when the calculation mode is xlCalculationManual, Excel doesn't 
update values in cells.  If your macro relies on an updated cell value, you must force 
a Calculate event, with the .Calculate method, which may be applied to either a 
specific range (Range("MyRange").Calculate) or to the entire workbook 
(Calculate).

 
略
 

WITH Statements
WITH 文

If you are using several statement in a row that apply to the same object, use a WITH 
statement, rather than fully qualifying the object each time.  For example,

同一のオブジェクトに適用される複数のステートメントがあるのなら、
そのオブジェクトにアクセスするたびに完全修飾するのではなく
WITH文を使いましょう。


    With Worksheets("Sheet1").Range("A1")
        .Font.Bold = True
        .Value = 123
    End With


Worksheet Functions
ワークシート関数

You can use Excel's standard worksheet functions in your VBA code, rather than writing 
the functions in VBA.  Since these are fully executable instructions in native code, 
rather than interpreted VBA code, they run much faster.  For example, use

VBA のコード中で、VBAによって書かれた関数ではない Excelの標準ワークシート関数を使えます。
これらの関数はVBAのコードではなく完全なCPUの実行命令になっているので
格段に高速なものになっています。

    MySum = Application.WorksheetFunction.Sum(Range("A1:A100"))   

rather than

    For Each C In Range("A1:A100")
        MySum = MySum + C.Value
    Next C

■_

Optimize VBA のページからリンクが張られていたページ。

Cells Within Ranges

    Cells Within Ranges 

This page describes the Visual Basic procedures to access a particular cell in a range 
of cells, such as a named range.   For example, if you have a named range 
"MyRange", you may want to refer to cell "C5" relative to this 
range.

What follows is a reply written by Alan Beban to a newsgroup question.  Alan has been 
generous enough to allow me to reproduce his answer here.  What follows was posted by 
Alan Beban on March 17, 1998, to the microsoft.public.excel.programming newsgroup, and 
is  Copyright 1997, Alan Beban.  Thanks, Alan.


================================================
> > How do I refer to a particular cell within a range?

I assume you will get one or more responses referring you to the Cells Method, and 
that is a reasonable place to start studying, particularly for an illustration of 
referring to cells with a single index number. This response, however, deals with the 
Item feature of VBA:  documented as the Item Method in Excel5, and as the Item 
Property in Excel97.

Range("A1:B10").Item(5,3) refers to Cell C5, i.e., the cell in the 5th row, 
third column, starting with A1 as the upper left corner, the 1,1 cell. I treat the 
following as the shorthand version of the Item feature, although the documentation is 
not entirely clear; but documentation aside, it has the functionality of the Item 
feature:

Range("A1:B10").Item(5,3) は C5、つまり 5行目(5th row) の3桁目
(3rf colimn)のセルを参照します。このとき、開始位置はA1で左上の角、1行1桁のセルです。


Range("A1:B10")(5,3) refers to Cell C5. And if the name of A1:B10 is 
"MyRange", then Range("MyRange")(5,3) refers to Cell C5.

Range("A1:B10")(5,3) は C5セルを参照します。
ここでもし仮に A1:B10の名前が "MyRange" であったとすると、
Range("MyRange")(5,3) はC5セルを参照します。


It is not necessary for the cell to be within the range in order to be referenced this 
way. E.g., Range("A1:B10")(12,13) is a valid reference to Cell M12. Nor need 
the index numbers be positive;  e.g., Range("D4:F6")(0,0) refers to Cell C3, 
and Range("D4:F6")(-1,-2) refers to Cell A2; recall that this based on the 
fact that Range("D4:F6")(1,1) refers to Cell D4.

この方法で参照するのにセルが範囲に含まれている必要はありません。たとえば 
Range("A1:B10")(12,13) は正しい M12セルを参照する正当なものです。添え字の数
字が正である必要すらありません。Range("D4:F6")(0,0) は C3セルを参照しますし、
Range("D4:F6")(-1,-2) は A2セルを参照します。ここで 
Range("D4:F6")(1,1) がD4セルを参照するのを思い出してください。

以下略

Alan Beban
 Copyright 1997, Alan Beban


■_ 最速

Twitter / @Ryoma SHINYA: 最速 grep 公開しました. http://cod ... regen - Project Hosting on Google Code

公開されましたか。 見ておこう。

■_

8日には日本語の記事も出てきていてなんとなくまずった感。 7日に見つけてたんだよー ○| ̄|_

Nokia sells Qt commercial licensing and services business to Digia -- Engadget

Nokia sells Qt commercial licensing and services business to Digia
By Thomas Ricker posted Mar 7th 2011 5:32AM

Now that Nokia has shifted to a Windows Phone-centric smartphone strategy, it's only 
natural for the company to divest itself of responsibility with regard to the Qt framework
at the heart of Symbian and MeeGo development -- a platform Nokia acquired from Trolltech
back in January of 2008. We just got word that Digia will acquire the Qt commercial
licensing and services business from Nokia, including the transfer of some 3,500 desktop
and embedded customers actively using Qt today. Sebastian Nyström, Nokia Vice President,
Application and Service Frameworks, had this to say about the agreement:

Nokia はWindows Phone-centric なスマートフォン戦略にシフトしました。
(略)
わたしたちは Digia がNokia から Qtの商用ライセンスとサービスビジネスとを手に入れるだろうと
いう証言を得ました。それには今日Qtをactivelyに使っている組み込みユーザーや
3500本のデスクトップの移植が含まれています。

以下略

■_

2011年03月06日

■_

あの同人誌、暗黒通信団が関わっていたのか 発行同人誌リスト :暗黒通信団 『キュウベエに学ぶ営業テクニック』 

■_ Rのデバッグ支援機能

こんなにあったとは知らなかった。 R-Source から。

R-Source

便利なことに R にはデバッグを支援するための関数がいくつか用意されている.詳しくはヘルプを参照されたい.

関数

機能

browser()

評価の途中で変数を調べる.(デバッグ中に入力できるコマンド

→ c:関数の実行を継続,n:関数の残りの部分を一行ずつ実行,ls():生成されたオブジェクトを全て表示,関数中の変数や式:現時点の値を表示,where:現在のスタックを表示,return():関数評価に戻る,Q:終了)

debug()

デバッグモードに入る.デバッグ中に入力できるコマンドは browser() で使用できるコマンドと同じ.デバッグモードを抜ける場合は関数 undebug() を実行する.

trace()

関数の呼び出しを追跡する.追跡モードを止める場合は関数 untrace() を用いる.

traceback()

呼び出されたスタックを表示する.

debugger()

R 用デバッガを起動する.

try()

関数の途中でエラーが起きても,関数の残りを実行する.

stopifnot()

引数に与えた条件が満たされないときにプログラムをストップする.

system.time()

プログラムの実行時間を計る.

Sys.sleep()

プログラムの実行を指定秒数中断する.

■_ vs

Ruby。というよりRailsと。という気がしないでも。

Language War: PHP vs. Ruby | Nettuts+

Language War: PHP vs. Ruby

Jeffrey Way on Mar 3rd 2011

It's time; queue the “Going the Distance” theme from Rocky. In the red ring: Envato 
developer extraordinaire, Ryan Allen, who built the original FlashDen with his cold 
bare hands. In the blue corner: Michael Wales, a well known member in the PHP and 
CodeIgniter communities. The battle? PHP vs. Ruby. Fight!

Before We Begin

It must be noted that these sorts of debates are purely for fun and educational 
purposes. There are times when you'll choose PHP for a project, and there are times 
when you'd opt for Ruby. The goal of this series, however, is to learn how and when to 
make these sorts of decisions. Rather than “your language sucks,” these debates are 
meant to outline why you might, in certain situations, choose one over the other.

The Contenders

Ruby: Ryan Allen

Ryan Allen is a web software and systems engineer who's been working for Envato since 
forever. He built and supported the early versions of the Envato Marketplaces in Ruby 
on Rails, and now looks after the Tuts+ systems, amongst other things.

PHP: Michael Wales

Michael Wales is a web developer for US Government agencies, and is an active 
contributor to the PHP and CodeIgniter communities.

Michael Wales は US Government agencies のweb developer であり、かつ
PHP コミュニティ と CodeIgniter コミュニティに対するアクティブな contributor です。


And…Begin!
では…開始!

1 – How familiar are you with both PHP and Ruby?

(本文略)

2 – Do you feel that your language is more suited to beginners or advanced users? For example,
    if I'm relatively new to the industry, would I have more trouble learning PHP or Ruby?

    あなたの言語は、ビギナーと上級者どちらにより合わせられたものだと思いますか?
    たとえば、わたしが industry に相対的になじみが薄いものであったとしたら
    PHP と Ruby のどちらでよりトラブルに遭遇することになるでしょうか?
    #いまいち

(本文略)


3 - Many PHP developers move on to Ruby after a few years. Have you found this to be the case,
    and, if so, why do you think it's so common? What's the big “selling” point?

    多くのPHPデベロッパーが数年後にはRubyへ移行しています。あなたはそういったケースを
    見たことがありますか? また、見たことがあるのならそれは一般的なものだと
    考えていますか? 大きなセールスポイントとはなんでしょうか?

Ryan: The selling point for me (in 2005) was the Rails framework. I had tried my hand 
at web development with Python but being inexperienced I had somewhat of a tough time, 
not knowing what to do or where to look (but I managed to build some things, so take 
that!), but I really wanted to use Python day to day because I felt it had a better, 
more deliberate design and I liked the syntax. And because Snakes are cooler than 
Elephants.

    ActiveRecord was just so amazing!

Having never worked with anything else beyond ADODB in PHP, and trying and failing at 
making an ORM many times (I had no idea what an ORM was but I knew I wanted something 
that somehow mapped classes to database tables), when I first saw ActiveRecord it was 
like all my Christmases had come at once.

(略)

Michael: I think this is just a natural progression of developers (from Web 
Development to seeking overall knowledge of OOP languages and an overall Computer 
Science education) in general – I know it was the route I took.

    I think the largest downfall, to this day, is the practice of picking a language 
    and sticking to it to the death. That's not the way the real world works.

I consider myself a “Developer” – therefore, language is an ambiguous a 
qualification as the brand of television to a Best Buy salesperson. There are 
instances in which I pick PHP (if there is an extremely short timeline – outside of 
CRUD, it's the language I am most familiar in), there are others in which I pick Ruby 
(deployment via Capistrano or basic CRUD with Rails) and, even further, Python – which 
I prefer for Server Administration tasks and parsing of various files.

4 - Often times, we consider our current language of choice to be “better” than the previous.
    But is that always the case, or is it just “new”? Is it possible that your old code
    looks poor because you're now a more skilled developer?

(本文略)


5 - Are there instances when you might choose to use Ruby for one project, and PHP for 
    another (assuming you have 100% control over the choice)?

    One word: maintenance.

(本文略)


6 - If I'm more of a designer who only dabbles in development work from time to time, 
    would you still recommend that I choose Ruby over PHP? Keep in mind that the terminal 
    is a scary thing to some...

    わたしが開発だけをするのではなく、デザイナーとしての面がより大きかった場合、
    それでもあなたはわたしが PHP ではなく Ruby を選択することを勧めますか?



7 - What specifically does your language have that the other does not -- if anything?

    もしあるのなら、あなたの言語にあって相手の言語にはない特長とは何ですか?

    Ruby has hype, vibrancy, and sex appeal.

Ryan: I'd say something Ruby currently has that PHP does not is hype, vibrancy and sex 
appeal. Ruby is unequivocally sexy. Women love it. Men want to be like it. Godzilla 
fears it. I'd suggest hopping along to a Ruby User Group and you'd find a diverse 
group of people who just love to code, love making things and technology in general. 
When I began meeting people in the local Ruby community, it was the first time in my 
life I felt like I was with “my people.” I honestly thought I was the only 
programmer on the planet who cared about their work up until then. It was very 
refreshing and I've learnt a lot since then, mostly from the people I've met through 
these groups.

Here's a secret: if PHP released an official update with an alternate syntax (more 
Ruby/Python like), and wrapped the existing standard library in the style of the 
popular Ruby libraries (and made it consistent), and had backwards compatibility and 
ability to integrate with legacy code, it'd be a killer product. Don't tell anyone I 
said that.

Michael: Ease of deployment, a graceful introduction to the lower-level concepts of 
web development and over a century of documentation and tried-and-true best practices.

8 - It's common knowledge that PHP is far and away the most popular server-side language on
    the web. Yet, it's also the most ridiculed. Why is that? Certainly there's a reason why
    it's so widely used, right?

(本文略)

9 - PHP is often criticized for its sloppy nature. But, is this a reflection of the language
    itself, or the users who aren't familiar with quality code? There are plenty of ways to
    write clean MVC-based PHP.

    PHP はしばしばその sloppy な性質を指摘されています。しかしこれは、言語そのものを
    反映したものでしょうか? それとも質の良いコードに慣れ親しんでいないユーザーを
    反映したものでしょうか?

(略)

Michael: I think this is a reflection of the low-barrier to entry and the inherit 
curiosity of PHP developers to really understand what is going on. I had read/studied 
hundreds of white papers, blogs, articles on authentication systems – but it wasn't 
until I built my own that I truly felt as if I knew what was going on. I believe new 
PHP developers are eager to share what they've done with the rest of the world and are 
frequently slammed for doing so, because they didn't follow best practice or proven 
security patterns.

10 - Community and documentation are many times more important than the framework/language
     itself. How does Ruby or PHP's community compare to the other?

     コミュニティやドキュメントはフレームワークや言語それ自身よりも多くの場合に
     重要視されます。RubyとPHPのコミュニティを比べた場合にはどうでしょうか?

Michael: I think both PHP and Ruby have serious issues in their documentation – and 
for completely opposite reasons.

PHP has tons of documentation, thanks to its seniority – you can find the answer to 
any question with a quick Google search and it's going to work. Is it the best 
solution? Maybe, maybe not …

    Rails has been growing so quickly, that even I have a hard time keeping up.

Ruby has great documentation, but in reality this appears to be a framework vs. 
framework question, so we'll assume Rails. Rails has been growing so quickly, that 
even I have a hard time keeping up. Rails API documentation is great; but when it 
comes to third-party documentation (books, blog articles, StackOverflow responses) – 
they're all out-dated and while following along with this information it is very 
difficult to debug the problem and fix it.

In this respect, I believe PHP has the advantage as the individual frameworks 
(CodeIgniter, FuelPHP, Kohana, CakePHP, etc) can mitigate this effect to some degree – 
if you are using one of these frameworks it is simple to go find the definitive answer 
for what you are looking for.

略

Conclusion
結論

We've heard Ryan and Michael's thoughts, and you most certainly have your own views. 
Continue the debate in the comments!

ここまで Ryan と Micheal の意見を聞いてきました。読者の方々もそれぞれに自分の
視点というものを持っていることでしょう。議論はコメント欄で続けることにしましょう!

■_

ぺんでぃんぐ。

■_ 今日の丸投げ

このほかにもいくつか問題を丸投げ。

ポーランド記法が入力されたとき、その値を計算し、さらに逆ポーランド記法に変換... - Yahoo!知恵袋

ポーランド記法が入力されたとき、その値を計算し、さらに逆ポーランド記法に変換するアルゴ
リズムを設計せよ。値の計算には必ずスタックを用いること。

  a.アルゴリズムの概要を述べよ。
  b.アルゴリズムをフローチャートか擬似コードで示せ。
  c.例題を用いてアルゴリズムの動きを説明せよ。
  d.アルゴリズムの計算量について議論せよ。

ひそかに相談したいですけど、xxxxx@exapmle.com に送ってくれれば、BAに選ぶから、よろしくお願いします。 

最初、これはいったん構文木を組み立てないとだめかなあと思ったんですが、 入力のポーランド記法を + * 2 2 / 2 2 のようなものとして演算子はすべて二項演算子とすると ((+ 1 2 3) → 6 のようなことはできない)、 思ったより簡単にできそうな気が。

結局被演算子はどの記法でも登場順序は変わらないので、 演算子の登場順をひっくり返すためにスタックを使って適当に上げ下ろししながら 入力から出力へ演算子と被演算子を送ればいいと。 もう寝るから今はやらないけどな!w

■_

2011年03月05日

■_

入力過多で出力している余裕がない。

■_

  [ruby-dev:43276] iseq_compile_each()でのマジックナンバ
  [ruby-dev:43303] Re: iseq_compile_each()でのマジックナンバ
  [ruby-dev:43304] Re: iseq_compile_each()でのマジックナンバ

■_ 20 Software Development Best Practices

コメント欄の内容は省略。

CodeBalance: 20 Software Development Best Practices

20 Software Development Best Practices

Posted on 2011-02-26 by CB


Below are a compilation of 20 software development best practices:

   1. Always use source control system even if the project has only one developer. By doing
      that, you don't lose some or whole code immediately, can share same source file by
      multiple person and can take the whole advantage of coding histories.

      たとえ開発者がひとりだけのプロジェクトであったとしても、ソースコード管理システムを
      使うこと。そうすることによって、コードの一部(あるいは丸ごと)を即座に失ってしまう
      ということがなくなり、複数の人間によって同一のソースファイルを共有できるように
      なるのでコーディングの履歴についてアドバンテージを得られる。

   2. Follow coding standards and check that standard with automized tools.

      コーディング標準に従い、自動化されたツールによってチェックしなさい。

   3. Be consistent. If you do operations in a specific way, do that kind of operations in
      the same way (e.g. defining variable/method/class names, paranthesis usage etc.).

      一貫性を保ちなさい。
      (たとえば変数やメソッド、クラスの名前の定義、カッコの使い方などにおいて)
      固有のやり方で操作を行っているのなら、同一の方法で操作を行いなさい

   4. More code does not mean better code. Keep it simple and reduce complexity.

      better code よりも多くのことをコードにしないこと。
      シンプルであることを保ち、複雑さを軽減すること。

   5. Don't use magic numbers and strings directly in the code. Use constants. This method
      provides more modularity and understandability.

      マジックナンバーやリテラル文字列をコード中で直接使わないこと。定数を使いなさい。
      この手法は modularity と understandability を向上させます。

   6. Don't use comment lines to delete code, just delete. Version controling system will
      help you if deleted code is required.

      コメントにすることでコードを取り除かないこと。きっちりと削除しなさい。
      削除したそのコードが必要になったとしてもバージョン管理システムが助けてくれます。

   7. Delete unused methods and classes. Version controling system will help you if 
      deleted code is required.

      使っていないメソッドやクラスを削除しなさい。
      削除したコードが必要になったとしてもバージョン管理システムが助けになります。

   8. Catch specific exceptions instead of highest level class 'Exception'. This will 
      provide understandability and more performance.

      最高位のクラス 'Exeption' でではなく特定の例外クラスで例外を捕捉すること。
      これは understandability をもたらし、性能を向上させます。

   9. Use understandable and long names for variables. Loop variable names can be i, j,
      k, index etc., local variable names must be longer than loop variables, parameter 
      names must be longer than local variables and static variable names must be longer 
      than parameters;  proportional with scope size.

      理解しやすく長い名前を変数に使いなさい。ループ変数については i, j, k, index
      といったものを使ってもよい。ローカル変数はループ変数よりも長い名前でなければ
      なりませんし、パラメータ名はローカル変数よりも長い名前でなければなりません。
      そして、スタティック変数はパラメータよりも長い名前でなければなりません。
      スコープの大きさに応じて propotional にしましょう。

  10. Package related classes (that changed together and/or used together) together.

      (同時に変更したり一緒に使ったりするような) 関連するクラスをひとつのパッケージに
      まとめましょう。

  11. Use understandable comments. Bad comment is worse than no comment.

      理解しやすいコメントをつけましょう。悪いコメントはコメントがないよりも
      性質 (たち) が悪いものです。

  12. Use positive conditionals. Readability of positive conditionals are better than 
      negative ones.

      肯定形の条件を使いましょう。肯定形の条件の読みやすさは否定形のそれよりも勝っています。

  13. Use dependency injection to manage too many singletons.

      多すぎるシングルトンを管理するために依存性の注入 (dependency injection) を
      使いましょう。

  14. Use exceptions only for catching exceptions, not for control flow. Think as required
      and perform control flow with control statements/conditionals.

      例外は例外を補足するためだけに使いましょう。フローを制御するために使ってはいけません。
      要求と考えて、条件文や条件式を用いてフローを制御しましょう。
      #なんかちがう…

  15. Don't use so many arguments with methods. Keep the number at most 8-10. If more is
      required, review your design.

      メソッドにあまり多くの引数を持たせないこと。せいぜい8個から10個にとどめること。
      それ以上の数が必要になったのなら、設計を見直しなさい。

  16. Don't use method alternatives with boolean flag variables (public void
      someMethod(bool flag)). Write more than one method for each flag condition.

      ブール値のフラグ変数によって動作を変えるメソッド
      (public void someMethod(bool flag)) を使わないこと。
      フラグの状態に応じてひとつひとつメソッドを書きなさい。

  17. Method names must include "what is done by this method" information.

      メソッド名には「そのメソッドが行うこと」の情報を含めなければなりません。

  18. Think twice before defining a method as static and be sure if you really need to. 
      Static methods are harder to manage.

      あるメソッドを static として定義する前に良く考えなさい。そして
      本当にそうすることが必要なことを確認しなさい。
      static メソッドは管理するのが難しいのです。

  19. Avoid using methods with reference parameters. Use multi attributed object 
      parameters instead.

      参照パラメータを持つメソッドを排除しなさい。
      代わりに、multi attributed object パラメータを使いなさい。

  20. Interface method numbers must be minimized to decrease coupling/dependency.

      カップリングや依存性を減少させるために、インターフェースメソッドの数を
      最小にすること。

■_ our

Perl 6 の our にはこういう使い方もあったのかあ。

2011-02-20 - クラなんとか or くらなんとか or cla なんとかの日記

# our にすれば,class スコープに
augment class MyClass {
    our $c;
    method c { $c }
}


# 別名を付けて,上書き
augment class Str {
    .^add_method('real_chars', &chars);

    method chars {
        .real_chars > 5 ?? 'long' !! 'short'
    }
}

■_

2011年03月04日

■_

今月はイデオン劇場版BD箱とか絶望BD箱があるのに先月使いすぎたか。

■_ egrepの後方参照やらの話

opengroup (POSIX)の文書には サポートするものはこれこれであるとあるだけで 何をサポートしてないとは書いてないのですが、 サポートしている方を拾っていくとこうなると。

POSIX Basic and Extended Regular Expressions


POSIX Basic Regular Expressions 

(略)
 
The other BRE metacharacters require a backslash to give them their special meaning. 
The reason is that the oldest versions of UNIX grep did not support these. The 
developers of grep wanted to keep it compatible with existing regular expressions, 
which may use these characters as literal characters. The BRE a{1,2} matches a{1,2} 
literally, while a\{1,2\} matches a or aa. Some implementations support \? and \+ as 
an alternative syntax to \{0,1\} and \{1,\}, but \? and \+ are not part of the POSIX 
standard. Tokens can be grouped with \( and \). Backreferences are the usual \1 
through \9. Only up to 9 groups are permitted. E.g. \(ab\)\1 matches abab, while 
(ab)\1 is invalid since there's no capturing group corresponding to the backreference 
\1. Use \\1 to match \1 literally. 
 
POSIX BRE does not support any other features. Even alternation is not supported. 

POSIX Extended Regular Expressions 
 
(略)

The quantifiers ?, +, {n}, {n,m} and {n,} repeat the preceding token zero or once, 
once or more, n times, between n and m times, and n or more times, respectively. 
Alternation is supported through the usual vertical bar |. Unadorned parentheses 
create a group, e.g. (abc){2} matches abcabc. The POSIX standard does not define 
backreferences. Some implementations do support \1 through \9, but these are not part 
of the standard for ERE. ERE is an extension of the old UNIX grep, not of POSIX BRE. 

(略)

Copyright © 2003-2011 Jan Goyvaerts. All rights reserved. 

といいつつ、GNUでないUnixツールでこの辺がどのような実装されているのかは 良く知らんのですがね。

■_ 正規表現といえば

Henry Spencer。 検索してたらこれまで彼が公開した正規表現ライブラリをまとめていたページがみつかりました。

regex - Henry Spencer's regular expression libraries - arglist.com

regex - Henry Spencer's regular expression libraries 
 
There are three bodies of source code that can be referred to as "Henry Spencer's 
regular expression library". 

Henry Spencer 作の正規表現ライブラリとして参照できるソースコードはみっつあります。


Firstly the "old library" or the "book library". This dates back 
to around 1986 and was updated for the book Software Solutions In C, ed. Dale 
Schumacher, Academic Press, 1994 [ref: Usenet]. 

一つ目は "old library" もしくは "book library" と呼ばれる
ものです。これは1986年前後までさかのぼった時期のもので、1994年に
Software Solutions In C, ed. Dale Schumacher, Academic Press, 1994
のために更新されました。

(略)

The second is the "BSD library". This is a POSIX.2 compliant library that 
was included in 4.4BSD Unix. Spencer wrote that it was basically an alpha release, and 
pretty slow [ref: Usenet]. 

二番目は "BSD library" です。これは POSIX.2 に準拠したライブラリで
4,4BSD Unix に含まれていました。Spencer はこれを、基本的にはアルファリリースとして
書いていて、とても遅いものでした。

For more information on this library, see the README and COPYRIGHT files and two man 
pages regex(3) and regex(7). 

このライブラリについての更なる詳細は README や COPYRIGHT というファイル、また、
regex(3) と regex(7) の二つの man ページを参照してください。

(略)


The third is the "Tcl library". This was added to Tcl version 8.1 and 
supports wide-character Unicode. Although Spencer intended to release this library as 
a standalone package [ref: Usenet], I don't think he ever got around to it. However, a 
couple of ports are available: 

三番目は "Tcl library" です。
これは Tcl の version 8.1 に追加されたもので、wide-character Unicode を
サポートしています。Spencer はこのライブラリを独立したライブラリとしてリリース
しようとしていたのですが、わたしは彼がそうしようとしたことがあるとは考えていません。
とはいえ、二つの移植が利用可能になっています。

あれ。二番目のやつは動作速度遅いんだ。 確か on the fly で DFA 構築するタイプだったと思うんだけど。

■_ で

v7 のソースアーカイブを眺めていたら、egrep のソースが意外なもので書かれていたのに気がついた。 V7/usr/src/cmd/egrep.y .y って yacc ですかい! まあ、C のコードが結構埋め込まれてますけども。

V7/usr/src/cmd/egrep.y
/*
 * egrep -- print lines containing (or not containing) a regular expression
 *
 *	status returns:
 *		0 - ok, and some matches
 *		1 - ok, but no matches
 *		2 - some error
 */
%token CHAR DOT CCL NCCL OR CAT STAR PLUS QUEST
%left OR
%left CHAR DOT CCL NCCL '('
%left CAT
%left STAR PLUS QUEST

%{
#include <stdio.h>

#define MAXLIN 350
#define MAXPOS 4000
#define NCHARS 128
#define NSTATES 128
#define FINAL -1
char gotofn[NSTATES][NCHARS];
int state[NSTATES];
char out[NSTATES];
int line 1;
int name[MAXLIN];
int left[MAXLIN];
int right[MAXLIN];
int parent[MAXLIN];
int foll[MAXLIN];
int positions[MAXPOS];
char chars[MAXLIN];
int nxtpos;
int nxtchar 0;
int tmpstat[MAXLIN];
int initstat[MAXLIN];
int xstate;
int count;
int icount;
char *input;

long	lnum;
int	bflag;
int	cflag;
int	fflag;
int	lflag;
int	nflag;
int	hflag	= 1;
int	sflag;
int	vflag;
int	nfile;
long	blkno;
long	tln;
int	nsucc;

int	f;
int	fname;
%}

%%
s:	t
		={ unary(FINAL, $1);
		  line--;
		}
	;
t:	b r
		={ $$ = node(CAT, $1, $2); }
	| OR b r OR
		={ $$ = node(CAT, $2, $3); }
	| OR b r
		={ $$ = node(CAT, $2, $3); }
	| b r OR
		={ $$ = node(CAT, $1, $2); }
	;
b:
		={ $$ = enter(DOT);
		   $$ = unary(STAR, $$); }
	;
r:	CHAR
		={ $$ = enter($1); }
	| DOT
		={ $$ = enter(DOT); }
	| CCL
		={ $$ = cclenter(CCL); }
	| NCCL
		={ $$ = cclenter(NCCL); }
	;

r:	r OR r
		={ $$ = node(OR, $1, $3); }
	| r r %prec CAT
		={ $$ = node(CAT, $1, $2); }
	| r STAR
		={ $$ = unary(STAR, $1); }
	| r PLUS
		={ $$ = unary(PLUS, $1); }
	| r QUEST
		={ $$ = unary(QUEST, $1); }
	| '(' r ')'
		={ $$ = $2; }
	| error 
	;

%%
yyerror(s) {
	fprintf(stderr, "egrep: %s\n", s);
	exit(2);
}

yylex() {
	extern int yylval;
	int cclcnt, x;
	register char c, d;
	switch(c = nextch()) {
		case '$':
		case '^': c = '\n';
			goto defchar;
		case '|': return (OR);
		case '*': return (STAR);
		case '+': return (PLUS);
		case '?': return (QUEST);
		case '(': return (c);
		case ')': return (c);
		case '.': return (DOT);
		case '\0': return (0);
		case '\n': return (OR);
		case '[':
(略)

■_ sed

Index of V7/usr/src/cmd/sed ついでに sed。こちらは yacc のような意表をついたものを使われてはいませんでしたが、 v7 の時代には regex ライブラリって独立してなかったのですね。 awk, egrep, grep, sed それぞれのコードに埋め込まれていました。 POSIX 以前に正規表現ライブラリってあったはずだと思うのですが、 さてどこで入ったものか。

V7/usr/src/cmd/sed/sed1.c
(略)

advance(alp, aep)
char	*alp, *aep;
{
	register char *lp, *ep, *curlp;
	char	c;
	char *bbeg;
	int	ct;

/*fprintf(stderr, "*lp = %c, %o\n*ep = %c, %o\n", *lp, *lp, *ep, *ep);	/*DEBUG*/

	lp = alp;
	ep = aep;
	for (;;) switch (*ep++) {

	case CCHR:
		if (*ep++ == *lp++)
			continue;
		return(0);

	case CDOT:
		if (*lp++)
			continue;
		return(0);

	case CNL:
	case CDOL:
		if (*lp == 0)
			continue;
		return(0);

	case CEOF:
		loc2 = lp;
		return(1);

	case CCL:
		c = *lp++ & 0177;
		if(ep[c>>3] & bittab[c & 07]) {
			ep += 16;
			continue;
		}
		return(0);

	case CBRA:
		braslist[*ep++] = lp;
		continue;

	case CKET:
		braelist[*ep++] = lp;
		continue;

	case CBACK:
		bbeg = braslist[*ep];
		ct = braelist[*ep++] - bbeg;

		if(ecmp(bbeg, lp, ct)) {
			lp += ct;
			continue;
		}
		return(0);

	case CBACK|STAR:
		bbeg = braslist[*ep];
		ct = braelist[*ep++] - bbeg;
		curlp = lp;
		while(ecmp(bbeg, lp, ct))
			lp += ct;

		while(lp >= curlp) {
			if(advance(lp, ep))	return(1);
			lp -= ct;
		}
		return(0);


	case CDOT|STAR:
		curlp = lp;
		while (*lp++);
		goto star;

	case CCHR|STAR:
		curlp = lp;
		while (*lp++ == *ep);
		ep++;
		goto star;

	case CCL|STAR:
		curlp = lp;
		do {
			c = *lp++ & 0177;
		} while(ep[c>>3] & bittab[c & 07]);
		ep += 16;
		goto star;

	star:
		if(--lp == curlp) {
			continue;
		}

		if(*ep == CCHR) {
			c = ep[1];
			do {
				if(*lp != c)
					continue;
				if(advance(lp, ep))
					return(1);
			} while(lp-- > curlp);
			return(0);
		}

		if(*ep == CBACK) {
			c = *(braslist[ep[1]]);
			do {
				if(*lp != c)
					continue;
				if(advance(lp, ep))
					return(1);
			} while(lp-- > curlp);
			return(0);
		}

		do {
			if(lp == locs)	break;
			if (advance(lp, ep))
				return(1);
		} while (lp-- > curlp);
		return(0);

	default:
		fprintf(stderr, "RE botch, %o\n", *--ep);
	}
}

どこかで見た記憶があるようなラベル名。 これでは '.' は改行もマッチするようになっていますね。

■_

■_

これか Amazon.co.jp: Semantics of Programming Languages: Structures and Techniques (Foundations of Computing): Carl A. Gunter: 洋書 Amazon.co.jp: Semantics of Programming Languages: Structures and Techniques (Foundations of Computing): Carl A. Gunter: 洋書

2011年03月03日

■_

JのソースコードGPL化の話、日本語の記事で見ないなあ。 まあ自分の観測範囲が狭いってのもあるかも知れんですが。 Jスレでもなかったし。

■_

>

■_

Henry Spencer の regexpライブラリのソース(複数バージョンで) を見たりしたんだけど まとめている時間ががががが。

■_

絶望BD-BOXのその1、今月だったなあ。

2011年03月02日

■_

『プログラム意味論 (情報数学講座)(横内 寛文)』 復刊リクエスト投票
http://www.fukkan.com/fk/VoteDetail?no=47154
Twitter / 共立出版スタートレック蟻: 【「復刊」検討図書につきまして ...
http://twitter.com/1738310/status/10206811906899968
所蔵図書館マップ : プログラム意味論 (情報数学講座)
http://myrmecoleon.sytes.net/map/?isbn=4320026578

今図書館からこの本借りているんですが(土曜日には返さないといけない)、 さてどうなるか>復刊

ハードカバーの本ですがソフトカバーになってもいいから出ないかなあと。 それでもまたすぐに買えなくなるようだとぐんにょりですが。

■_ GPL化

[Jprogramming] J Source GPL

[Jprogramming] J Source GPL 
Eric Iverson eric.b.iverson at gmail.com 
Wed Mar 2 06:42:20 HKT 2011 


We are going to release J Source under GPL version 3 license. 
わたしたちは J のソースコードをGPL バージョン3 ライセンスの下でリリースします。


Users will be able to build their own jconsole and J Engine ( libj.so/libj.
dylib/j.dll). In particular, ports to new platforms (e.g., Linux/ARM) will no
longer depend on Jsoftware access to development systems.

ユーザーは自分専用の jconsole や (libj.so/libj.dylib/j.dll といった) J エンジンをビルドで
きるようになります。特に、(Linux/ARM のような) 新しいプラットフォームへの移植は
システムを開発するために Jsoftware のアクセスに依存しなくなります。


We'll continue to have commercial source licenses that aren't GPL and don't 
have GPL restrictions. 

わたしたちはGPLでなく、したがってその制限に縛られない商用ソースライセンスを
維持し続けます。

We'll continue to distribute binaries and systems for supported platforms 
that don't have GPL restrictions. 

A new forum will be set up for J Source discussions early next week. I'd 
prefer if discussions waited until then and to not clutter the programming 
forum.

来週の初めに、J Source のディスカッションのための新しいフォーラムを立てます。
それまでは(ソースについての)議論は控えてプログラミングフォーラムを
混乱させないことを望みます。

The reason for this early announcement is I would like a few hardy souls to 
take an early look at the release package. Be nice to sort out severe 
shortcomings and major embarrassments before general availability. 
 
If you would like to try your hand at building your own J binaries, send me 
an email and I'll reply (though perhaps not until tomorrow). 
 

reddit での反響。

J Source to be released under GPL3 : programming

Oh no... Oh no. 

God help us all. 
 

It will be ok. No one will be able to google it. 

 
They gave me some obfuscated shit looking like line noise... I want the real sources, 

dammit! 

 
Do you think they have any? 
 

That's good because I want to read it. 
 
 
This is by far the most striking news I have heard in the last couple of years. 
 
 
Awesome. As far as I know, the only (non-toy) open-source APL variant until now was A+, 
which doesn't seem to be very active. 

■_

関数型プログラミング言語Haskell Part13 

963 デフォルトの名無しさん [sage] 2011/03/02(水) 08:01:34.32 ID: Be: 
 Haskellwikiの 
 qsort [] = [] 
 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs) 
 は、==のテストが冗長な気がするのですが 
 qsort [] = [] 
 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (x <) xs) 
 として大丈夫ですよね? 
 
964 デフォルトの名無しさん [sage] 2011/03/02(水) 08:15:23.44 ID: Be: 
 >>963 
 入力リストの要素に重複がないなら同じだと思うけど、前者はそれがある場合に備えているわけで、べつに冗長ではないのでは? 
 
965 デフォルトの名無しさん [sage] 2011/03/02(水) 08:24:50.94 ID: Be: 
 なるほど、こう書いてしまうとまずいですね 
 List.nub+qsortを混ぜたような処理になるわけか 
 
966 デフォルトの名無しさん [sage] 2011/03/02(水) 08:30:45.27 ID: Be: 
 あれ、訂正。そうはならないけど、中途半端なバグありコードになってしまいますね 
 ありがとうございました 
 
967 デフォルトの名無しさん [sage] 2011/03/02(水) 12:43:09.98 ID: Be: 
 同値性テストに冗長性を感じたのに、 
 filter で2回もリストを辿ることに冗長性は感じないのかな 
 
968 デフォルトの名無しさん [sage] 2011/03/02(水) 20:59:11.07 ID: Be: 
 先生宿題のクイックソートができました 
 q[]=[] 
 q(x:xs)=arr (List.partition(<x))>>>first q >>> second q>>>arr((((((((((((((app .).).(&&&))(((app .).).(&&&)) (const id)).).).).)((flip.).) ((.).((.).))) .).).).) (((.).(.)).)flip(++)(:) x snd fst ) $ xs 
 
969 デフォルトの名無しさん [sage] 2011/03/02(水) 21:02:26.75 ID: Be: 
 やめろばか 
 
970 デフォルトの名無しさん [sage] 2011/03/02(水) 21:07:12.68 ID: Be: 
 >>968 
 テラワロスwww 
 どれくらい時間かかった? 
 
971 デフォルトの名無しさん [sage] 2011/03/02(水) 21:10:05.55 ID: Be: 
 >>968 
 やだ変態っ! 
 
972 デフォルトの名無しさん [sage] 2011/03/02(水) 21:27:24.31 ID: Be: 
 1時間ぐらいかかりました 
 
973 デフォルトの名無しさん [sage] 2011/03/02(水) 21:31:20.54 ID: Be: 
 >>972 
 1時間もアロー、アローでゴシゴシやってたのかwww 
 オマエみたいな変態は大好きだwww 
 
 
 
 
 
 
 
 研究室にはいらない。 
 

Haskell の修行が足りないので 968 が読めない ○| ̄|_

■_

2011年03月01日

■_

「誰が」その情報を発信したのかってのも重要よね(謎)

■_ 悲しくなってきた

21世紀のプログラミング (Programming in the 21st Cencury) と題した 風刺マンガ(?) http://metabox.it/ElqIm.png

■_

まだ回答がついてません。 まあこれだけでは情報が不足しているし、 問題の本を持っている人がどれだけいるかというのもあるでしょうし。

アルゴリズムです | OKWave
アルゴリズムC3巻(Rセイウィックの)の乱数のとこのp113以降の 
pq = 10^8p1q1 として~のところからよくわからないんですが 
誰か説明してくれないでしょうか? 

式変形はわかるんですが、そのあとのプログラム実装で 

  return (((p0*q1+p1*q0) % m1) * m1) + p0*q0) % m; 

ってとこの意味がよくわかりません. 
結局これはp * qのビットあふれを生じさせないように 
値を返すってことらしいですがなんでこれでうまくいく(?)んでしょうか? 
 

話を単純に2桁 × 2桁 とすると

    12
    34
  ------
     8
    4
    6
   3

上の桁同士の部分積は3桁目となるので無視。 そして、上の桁と下の桁の部分積二つについては、二つを足して 桁上がりが生じた部分を無視する。 ということになるので

 ((p0*q1+p1*q0) % m1) * m1)

たすきがけの二つの部分積を足して、その下位桁部分だけを残す。 そしてこれは最終的な積の上位桁になるので * m1 して、

+ p0*q0) % m;

下位桁同士の部分積を加えて、最終的な剰余を取る。と、

■_ $

sed - Stream EDitor (文字列置換) - 会津大学UNIXウィキ
閑話休題: perl には、バグというか変な仕様がありまして、

% perl -e '$_=join("",<>);s/$/TAIL/g;print;' < file

と $ を使用して文章末を置換しようとすると

<div>
This is div
</div>TAIL
TAIL

のように2度置換されてしまったりします。 php の perl コンパチブルな正規表現関数 preg_*** では、このおかしな挙動をわざわざ忠実に再現していたりします。
PHP - パターン修飾子 - m (PCRE_MULTILINE)。おかしな話ですね。

閑話休題の使い方が逆のような気がしますがそれはさておき。

これはもう過去の混乱(不統一)のなせる技というかなんというか。 sed の場合、その動作は 一行読み込む→改行を取り除く→スクリプトにしたがって処理する→改行を付加して出力 で、'.' は改行にもマッチしていたのですが、 一方 awk では改行はマッチの対象ではありませんでした (現在の gawkは改行もマッチします)。 同時に、$ についても文字列の末尾だけでなく改行の直前にもマッチするという 動作をするものがあったようです。 そして Perl もおそらくこの仕様を受け継いだのでしょうが、 そうすると複数行を読み込んでまとめて処理したいときにいろいろ困る。 あとは以下略。ということで。

Unix V7 の awk ではどうなってたっけか。

■_

■_

まったくやるきがございません~♪


一つ前へ 2011年2月(下旬)
一つ後へ 2011年3月(中旬)

ホームへ


リンクはご自由にどうぞ

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