ときどきの雑記帖 リターンズi戦士篇

I'd just be the catcher in the rye and all. I know it's crazy, but that's the only thing I'd really like to be. I know it's crazy.

The catcher in the rye
J. D. Salinger

著作権保護期間の70年延長に反対

検索エンジン経由でこられた方へ

このページの内容は日々更新されます。 そのため、検索エンジンに引っかかったものがここに残っているとは限りません。 同じ内容のものは zakkicho[0-9]+.html なページに多分あります。 特に逆ポーランド記法←→中置記法の変換に関して探している人は ここ とか ここ にあります。

最新エントリ (何日分あるかは不定)

2009年08月09日

■_

yacc の日でした(とかゆー)

・読んだ
プログラマーのジレンマ 夢と現実の狭間
ぶっちゃけ、読みたいけど時間がないという人は 9章(開発手法をめぐる旅)と10章(エンジニアとアーティスト)だけ読んどけばOK(暴論)

リチャード・ガブリエル が云っていることって聞き覚えがあるんだけどどこでだろう? 「開発者の訓練は、詩人や画家といった創造的な仕事をする人の訓練と同じように行うべきだと思う。 『そんなことはばかげている』と言われるかもしれない。しかし、たとえば、詩を専攻して美術学 修士号を取得するための教育を受けるときは何をするか。優れた詩の作品を研究するはずだ。 ソフトウェア工学を学ぶときに、そんなことをしているか。していない。 優れたソフトウェアのソースコードなど見ない。 優れたソフトウェアのアーキテクチャも見ない。その設計も見ない。 優れたソフトウェアデザイナーの生涯を学んだりはしない。自分が作ろうとするものに関する 文献など調べない。」 すべての作家が個人の「会社」をもっていて、メルビル会社の人間しか『白鯨』を読めず、 ヘミングウェイ会社の人間しか『日はまた昇る』を読めないようなものだ。 このような状況で、優れた文学が生まれることが想像できるだろうか。 このような条件下では、文学のカリキュラムも組めないし、文章術を教える方法もない。 それなのに、これと同じ状況でプログラミングを学ぶことを期待するのか ほかにもアラン・ケイの話とか。この二章だけ思いっきり全体で浮いているような気が するのだけどなんなんだろう。

・「教授」と「教示」
身も蓋もない書き方をしちゃうとですね、 質問掲示板みたいなところで使うのなら 「教えてください」でいーじゃん。とか。 わざわざ使い慣れない(ので意味の違いも分かってない)のに かっこつけるからわけわからんとになるわけで。

■_ 「が」の話

まあいちいち指摘したりはしないんですが、 PCのUSBポートにUSBメモリを挿したのですが、USBメモリ「が」認識しません とかいわれると、非常に背中がむずがゆくなりますね。 機嫌が悪いときは「認識するのはPCであって、USBメモリじゃなかろ?」 と返すのですが、まず理解してもらえません(苦笑

■_ もちべーしょん

まあありがちといえばありがちなのかもしれないけど。

Pythonのお勉強 Part34 
355 デフォルトの名無しさん [sage] 2009/08/08(土) 19:41:22 ID: Be:
    BeautifulSoupって死んだんか・・・

358 デフォルトの名無しさん [sage] 2009/08/09(日) 01:40:12 ID: Be:
    >>355
    lxmlでどうにか 

359 デフォルトの名無しさん [sage] 2009/08/09(日) 02:03:21 ID: Be:
    >>355
    何の話だw 

360 デフォルトの名無しさん [sage] 2009/08/09(日) 14:53:36 ID: Be:
    >>359
    知らないのか?
    Python3.0でSGMLParserがなくなったんでBeautifulSoup3.1.0以降では
    SGMLParserの代わりにHTMLParserを使うようになったんで、
    これまでパースできたちょっと崩れたHTMLがパースできなくなってる。
    開発者は、もうツマンネーからこれ以上の対応をする気はねーよ、らしい。

    http://www.crummy.com/software/BeautifulSoup/3.1-problems.html

361 デフォルトの名無しさん [sage] 2009/08/09(日) 15:20:46 ID: Be:
    最後のほう生々しいこと書いてあるね

    BS使ってるモジュールがどれほどあるのか知らないけど
    Py3.0への移行の支障になったりして 

362 デフォルトの名無しさん [sage] 2009/08/09(日) 15:47:52 ID: Be:
    3.Xへの移行は年単位でかかるだろ…
    Zopeなんてどんだけかかるんだか 

366 デフォルトの名無しさん [sage] 2009/08/09(日) 18:40:44 ID: Be:
    ううむ、BSは巷のちょっと
    不作法なHTMLをパースさせるのに
    役立っていたんだがのう

    elemental treeって今のバージョンは
    その辺耐性あるのかしら。 

367 デフォルトの名無しさん [sage] 2009/08/09(日) 19:13:04 ID: Be:
    ElementTreeはXMLパーサですよ 


気になったので 360 のリンクをたどってみた。

Beautiful Soup: Having problems with 3.1.0?

Having problems with Beautiful Soup 3.1.0?

Version 3.1.0 of Beautiful Soup does significantly worse on real-world HTML than 
version 3.0.7a does. The most common problems are handling <script> tags 
incorrectly, "malformed start tag" errors, and "bad end tag" 
errors. This page explains what happened, how the problem will be addressed, and what 
you can do right now.

What happened?

(略)


This is the point where I'm supposed to ask for money. But money won't solve this 
problem. I'm always happy when someone sends me donations because of Beautiful Soup, 
and I used to describe these donations as "supporting Beautiful Soup development."
But that's not really accurate. To justify further Beautiful Soup development I need
time, not money. Gifts of money feel more like thank-yous for the work I've already done.

これがわたしがお金を求める理由です。しかしお金は問題を解決しません。
誰かから寄付されたときにはわたしはいつも happy になります。それは
Beatiful Soup と I used to describe these donations as "supporting Beautiful Soup development."
But that's not really accurate.
Beautiful Soup  将来を justify するのにわたしに必要なのは時間であって金銭ではありません。
Gifts of money feel more like thank-yous for the work I've already done.

I have a full-time programming job that pays well but isn't very flexible. If I get a 
$100 donation, I can't take an hour off from work and work on Beautiful Soup. If I 
take a day off, I'd rather spend it doing something other than programming. To make 
the time for Beautiful Soup development, I'd need enough money to make it my job, and 
that's too much money to ask for or to expect.

わたしはフルタイムで払いも悪くないプログラミングの仕事を持っていますが、それは
flexible なものではありません。もし100ドルの寄付を受け取ったとしても、
I can't take an hour off from work そしてBeautiful Soup のための作業をすることも
できません。もし一日の休みが取れたなら、わたしはプログラミング以外のことにそれを
使いたいのです。Beautiful Soup の開発のための時間を作るためには、わたしは
自分の仕事をつくるのに十分なお金が必要です。そして、それはお願いしたり期待するのには
高すぎる額なのです。


To summarize, Beautiful Soup is a hobby that I don't really enjoy and that's similar 
to the work I do all day. It's competing against other hobbies and committments I have, 
hobbies and committments that are more enjoyable and significantly different from my 
day job. So when I say you can do some of the work yourself, I'm not being snarky. 
That's a legitimate option for getting this code written faster.

まとめると、Beautiful Soup はわたしが心底それを楽しめるものではない
趣味であり、同時に日々の仕事と似たような作業であるのです。
ほかの趣味やわたしがコミットメントしているものと比較した場合、
趣味やコミットメントしているものはより楽しめるものであり、わたしの仕事とは
まったく異なった種類のものです。ですから、
わたしがあなたに、あなた自身で作業をすることもできますよと云ったときは
I'm not being snarky. That's a legitimate option for getting this code written faster.

Update: For easier access to the source, I've put Beautiful Soup 3.0 and trunk on 
Launchpad, so you can make and publish your own branches.

This document (source) is part of Crummy, the webspace of Leonard Richardson (contact 
information). It was last modified on Friday, March 13 2009, 22:19:24 Nowhere Standard 
Time and last built on Friday, June 12 2009, 23:27:49 Nowhere Standard Time.

Crummy is © 1996-2009 Leonard Richardson. Unless otherwise noted, all text licensed under a Creative Commons License.

訳つけようと思ったけど、すぐにそれっぽくはできない気配なのであとで余裕があれば。 とにかく、これにばかり時間をかけたくないということのようですね。

■_

Journal of scrottie (4167) Myth of rarity of "good Perl programmers" [ #39426 ]

I learned Java before I learned Perl. This was in the Java 1.1 days. Since then, I've 
been wooed by Java shops and slid into positions of authority where I was treated as 
an expert and a resource. Despite my Perl being much stronger and despite having far 
more credibility in the Perl community and accomplishments there, no such thing has 
ever happened with a Perl job. Indeed, I've found myself working to prove myself far 
beyond any reasonable point and still being treated with contempt and suspicion. I 
hear Perl people comment all of the time to the effect of that they're still trying to 
convince the company to use testing or POD or other such things. Java programmers on 
the other hand are able to pitch management and easily sell them on expensive 3rd 
party solutions or wide sweeping initiatives.

Forgive me, this is a post of generalizations. I'll write up some case studies, 
perhaps, if people care.

Really f'n smart Perl programmers I know get mundane jobs working on obscure pieces of 
infrastructure where they stay anonymous and unacknowledged in their company. Java 
programmers are turned into stars and sent on lecture tours. Google loves to recruit 
Perl programmers and make them do system administration, allowing Perl only very 
tacitly for code that no one else will ever touch but demanding Python, Java, or C++ 
for everything else. Google did a brilliant thing by acknowledging the tenacity and 
intelligence of those few worthy Perl programmers.

I've written about this before but looking at this situation again I'm reminded of my 
hypothesis -- the only reason companies hire Perl programmers to write non-trivial 
programmers beyond the scope of system administration automation is because Perl 
programmers are inexpensive and submissive. They do what they're told, don't talk back, 
don't require acknowledgement, don't make a stink about things like testing and 
security that management doesn't care about nearly as much as deadlines, they don't 
aggressively negotiate on their salary, they agree to absurd timetables and 
requirements, and they routine suspend their better judgment to attempt whatever 
management has proposed.

Looking at Perl jobs, I see sysadmin support style stuff, maintenance jobs where new 
code is written in something else, but mostly I see sleazy fly by night companies. I 
keep hearing from companies that it's hard to find good Perl programmers. I'm calling 
bullshit on that one. I know well Perl programmers who are doing great things in the 
community and generating news who are working essentially dead end jobs and are not 
being wooed by anyone. I worked at a large Perl shop where a well known Perl hacker 
and former pumpkin applied, worked, and was treated like absolute shit -- as I said, 
with contempt and suspicion.

For companies to lament the alleged lack of existence of good Perl programmers is just 
another facet of the cutting off the nose to spite the face behavior typical of the 
haughty attitude they harbor towards Perl programmers. The motive is far more to blame 
problems on the programmers they have than to actually attract good programmers.

Perl programmers get no respect and aren't about ready to demand it.

Again, I'm speaking in generalities. A few companies are doubtlessly above this, but 
there are far too few of them to employ the Perl talent. Writing a thousand times more 
Perl than Java in the past few years, I'm still more marketable as a Java programmer 
to a degree that far exceeds the relative demands for Perl or Java programmers. Only 
fundamental attitudes can account for this.

繰り返しますが、わたしは一般的なことを申し上げています。
中には上に書いたようなことがうそであるような企業も少数にしろあることでしょう。
しかしその数は Perl talent を雇うにはあまりにも少ないのです。

-scott

こっちも手ごわそうだな。あとで。

■_ 本日の巡回から

2009年08月08日

■_

・クラッキングバイブル 新装版
今度のは箱に入ってないんだ。

・ムック
大洋→横浜で60周年記念だかのムックが出ていた。 ちょっとだけ中を見てみたのだけど屋鋪と高木豊の対談があって、 その中で「俺たちがいくら打って点を入れてもピッチャーがだらしないから それ以上に点を取られて負けるんだ」みたいなことを言ったら山下大輔に 叱られたとかいう話があった。 山下大輔に叱られたあともぐだぐだいってたということだから、 そりゃあこいつらがいたんじゃダメだったろうなあという認識を新たにした。 屋鋪は好きな選手だったんだけどなあ。

・みつからない
「ぷよぷよのうた」がどの店にも置いてないでござる。 Amazonさんでぽちっとなコースかなあ。

・読んだ
「エコ罪びと」の告白-私が買ったモノはどこから来たのか? と 大搾取!。 なんというか暗澹たる気分に。

・長崎原爆
本屋で見かけてちょっとだけ中身を見た本で(タイトル失念)、 長崎にも投下された爆心地付近に原爆ドームのような建物(浦上天主堂?)が あって、戦後も1955年くらい(覚えてない)までは残っていたのだけど、 今はもう撤去されてしまって影も形もない。原爆ドームがある広島とない長崎と… でいろいろ書かれているようで財布に余裕があれば買ったんだけど。 いや、タイトルとか控えて図書館に行くべきか。 あと、なぜ長崎でそのようなことになったのかということも書かれていて、 なんともやりきれない気持ちに。

■_ Scalaのみらい



On Scala’s future | Zen and the Art of Programming
On Scala’s future

By Antonio Cangiano. Filed under Ruby, Scala 

Kenneth McDonald posted the following question about Scala's future in the Scala 
mailing list:

    I thought it would be interesting to find out people's predictions for how much 
    of the Java market Scala will eventually penetrate. It's nice to see Scala doing 
    reasonably well so far, so now’s your chance to make a prediction on the future of 
    Scala:

    a) Scala will remain a niche language, competing with Groovy, JRuby, etc.
       ニッチな言語にとどまり続ける
    b) Scala will become the dominant “second” language for the JVM.
       JVM 上の“第二の”支配的言語となる
    c) Scala will actually become big enough to compete with Java in many respects.
       Java に比肩しうる存在となる

    If none of these fit your outlook, feel free to make up your own answer.

In my opinion, the answer will be A (niche) or B (second language), depending on the 
community's ability to:

わたしの意見では、この設問に対する答えは A のニッチか B の第二言語で、コミュニティの
能力によってそのどちらかが決まると思う。

    * Promote Scala (and Liftweb);
      Scala のプロモーション

    * Simplify the process of switching from Java (e.g., by providing familiar tools) 
      as much as possible;
      Java からの移行プロセスの単純化

    * Provide worthy reasons to switch (e.g., killer apps). People rarely go to the 
      trouble of switching just because something is “nicer”, even if in reality it
      causes one to write more robust code that takes advantage of higher order
      abstractions and a “safe and coherent” type system. Liftweb and concurrency
      through the Actor model / Akka are definitely two examples of a step in the
      right direction, as they do a particularly good job of solving a specific
      problem and showcase the value of adopting Scala as a user, as well as a tool
      to implement libraries and reusable components.

The software development community is embracing dynamically typed languages like 
Python and Ruby, as well as functional programming. Languages like Python and Ruby 
simplify the development process for a beginner. They are easy to read, learn and use. 
Their adoption is therefore growing quickly. They also offer practical solutions to 
web development needs through frameworks like Rails and Django.

The paradigm shift to functional programming is much slower however. Functional 
programming done a la Scala, is undoubtedly advantageous for the competent software 
engineer, but moving from Java to Scala requires significant commitment and a higher 
degree of understanding about how to program, in my opinion. Are Java developers up to 
this? Some of them are, but I doubt that a majority of them would be. It should be 
noted that Scala has the potential to also attract developers who don’t program in 
Java, but rather come from a different background, such as the aforementioned Python 
and Ruby. These people may look into Scala as a more functional-oriented, robust and 
faster alternative.

This, coupled with the current, limited popularity of Scala, leads me to believe that 
option C (let’s say ~50% marketshare) is not a realistic option for the foreseeable 
future. We are entering the long tail period of programming, where many lesser known 
languages will start gaining some traction. Achieving a “second language” status is 
still an ambitious and worthy goal. There are many formidable opponents aiming for 
that, including JRuby, Jython, Groovy, and Clojure, and the rewards for doing so would 
be substantial for everyone involved.

The real question is not how far Scala is capable of going in terms of adoption, but 
rather what can be done to ensure that it will achieve widespread acceptance, however 
that may be defined. Paying close attention to the success stories of Ruby and Python 
may give the community some insight as to what should be done. To a minor extent, 
fellow functional programming languages like Erlang and Haskell are doing a fine job 
marketing-wise and are gaining traction. As of 3.30 pm today, there are 147 members in 
the irc channel for Scala, and 576 for Haskell. This is not to say that one is better 
than the other, or even that Haskell is more popular than Scala in general, but rather 
that there may be something to learn from a “similar” language, that poses 
compatible challenges for those who intend to approach it.

Being based on the JVM, well integrated with Java, and to a certain extent being 
Java-like, are all major advantages that may help Scala’s ability to gain major 
popularity. And being ingrained in the Java world, will affect the way Scala’s image 
and the ways it can be promoted as well. Whereas Ruby has a somewhat anti-corporate 
spirit and image, and is tough to sell to the Enterprise world, Scala doesn’t face 
these challenges. As such it may appeal to a much larger category of developers and 
companies. However, a lot of work will be required to reach that tipping point. Scala 
is already an excellent language, as far as I can see, but it will be a combination of 
technical efforts and marketing to really decide Scala’s popularity.

Bookmark and share:

Add to Buzz Add to Del.icio.us Add to digg Add to DotNetKicks Add to DZone Add to 
Facebook Add to Google Bookmarks Add to Newsvine Add to reddit Add to Slashdot Add to 
Stumble Upon Add to Squidoo Add to SphereIt Add to Technorati Add to Twitter Add to 
Yahoo My Web


Copyright © 2005 - 2009 Antonio Cangiano • Powered by WordPress • Using Blue Zinfandel 
theme by Brian Gardner.

■_

C の生まれに関して。



C and the AT&T Unix Port -- A Personal History
C and the AT&T Unix Port -- A Personal History
C言語と AT&T Unix の移植

(略)

To Port a System

Then Dennis said another one of those simple, profound things, "Given the 
complexity of some of the applications in the Bell System, it would be easier to port 
the operating system to a new machine than to port the application to a new operating 
system." The existing operating systems at the time were mostly still punched 
card based (or based on card images copied to tape or disc), mass storage organization 
and command line syntax was completely unique for each system, interactive and 
back-ground jobs had different system calls to accomplish the same tasks, there was 
effectively no networking, and word-sizes of 16, 24, 32, 36, 60, and 64 were in use in 
the Bell System (not to mention several different byte orders). He didn't actually say 
"Unix is just a program", but I got the idea. He asked me if I could help 
evaluate machines for a 32-bit port of Unix, and build the compiler for the resulting 
port, and I enthusiastically agreed.

その時 Dennis は深遠な事柄を簡単に言い換えました。 「既にあるベルシステムの中のいくつ
かアプリケーションの複雑さを考えれば、 新しいオペレーティング・システムへアプリケーシ
ョンを移植するより、 新しいマシンへオペレーティング・システムを移植する方がより簡単で
あろう」 当時の Bell System の 既存のオペレーティング・システムのほとんどは まだパンチ
カード (あるいはテープやディスクにコピーされたカード・イメージ) に基づいたもので、 大
容量記憶装置の構成やコマンドラインのシンタックスは 各システムごと全く互換性がなく、 同
じタスクを遂行するのでも 対話形式とバックグラウンドジョブでは 異なるシステムコールを使
用し、 役にたつネットワークはなく、 ワードサイズは 16、24、32、36、60、64 が使用されて
いました。 (バイトオーダーが異なっていたことは言うまでもありません) 実際には彼が「Unix 
は単にプログラムである」 と言ったわけではありませんが、 私はアイデアを思いつきました。 
彼は私に Unix の 32-Bit 版のマシンでの評価を手助けを求めましたし、 その移植の成果とし
てコンパイラを作成することに、 私は熱狂的に同意しました。

(略)

The Impact on C
C に対する影響

Dennis and Ken set to work on the OS, to make it truly portable. It was necessary to 
clean up C quite a bit in order to write the OS. In the evolution from B to C, a lot 
of old B code had been carried over unchanged. This meant that the uses of types were 
very fast and loose, or missing altogether. Before C had the unsigned data type, 
people would assign values to character pointers to get unsigned arithmetic, for 
example.

Dennis と Ken は OS を本当にポータブルにするための作業に着手しました。 OS を書くために、
かなり多くの C を整理する必要がありました。 B から C へ発展する過程で、多くの古い B の
コードは 変更されることなく繰り越されていました。 これは型の使用が大変いい加減である、 
あるいは全く欠落していることを意味していました。 例えば C が符号なしのデータ・タイプを
サポートする以前は、 符号なしの演算を行うために、 文字のポインタに値が割り当てられてい
ました。

(略)

OS 記述のためというのがかなりのウェイトを持っていて Cの設計に影響したというのがうかがえますね。

■_ ヲチ

ひげぽんさん Lisp Scheme スレに登場。


Lisp Scheme Part27 
184 ひげぽん ◆Ngzcp/NZpA [sage] 2009/08/08(土) 00:04:50 ID: Be:
    Mosh 0.2.0 をリリースしました。
    http://mosh-scheme.googlecode.com/files/mosh-0.2.0.tar.gz
    http://mosh-scheme.googlecode.com/files/mosh-0.2.0-setup-win32.exe

    Mosh は R6RS に準拠した Scheme インタプリタです。
    0.2.0 では並列ライブラリなどが追加されています。

    リリースの詳細は http://d.hatena.ne.jp/higepon/20090807/1249655156 をご参照ください。

    もし良かったら使ってみてください。 

185 デフォルトの名無しさん [sage] 2009/08/08(土) 00:13:03 ID: Be:
    おっおっ! 

188 デフォルトの名無しさん [sage] 2009/08/08(土) 00:44:34 ID: Be:
    ~準拠とか、きちんとやろうとする人はすごいなあ 

191 ひげぽん ◆Ngzcp/NZpA [sage] 2009/08/08(土) 01:11:02 ID: Be:
    >>185
    >>186
    >>187
    >>188
    ありがとうございます!

    >>189
    まだ常用には向いていないです。
    (mosh shell)というライブラリが付属しているのですが
    機能が足りないです。

    >>190
    試していただいてありがとうございます。
    申し訳ないです。Windows XP でしか動作確認できていません。
    Windows 2000 では使えないWinSock で関数を使ってしまったみたいですね。
    取り急ぎバグとして issue 登録しておきます。 

204 デフォルトの名無しさん [sage] 2009/08/08(土) 01:57:54 ID: Be:
    充分に使いものになるレベルだと思う。
    細かいバグはまだまだあるけど、基本はしっかりしている。
    その細かい部分は多くの環境で使ってみないとなんとも言えないので、
    このスレで議論するのは意味があると思う。
    思うだけだけど。

    ところで --loadpath オプションでは複数のパスをコロンで区切って渡せる?
    Windows ではコロンはドライブレターの表記に使う。
    コロンに特別な意味があると絶対パスを使えないことになる。
    修正要。 

215 デフォルトの名無しさん [sage] 2009/08/08(土) 05:02:19 ID: Be:
    Mosh ver0.2 (Windows)
    エラーメッセージがEmacsで拾えなかった。STDERRへの出力に問題があるのでは?
    R6RSだとloadが無いけどどうするの?
    竹内関数、かなり速かった。

    mosh>(time (tak 12 6 0))

    ;;1.6406230926513672 real 1.625 user 0.0 sys
    12
    mosh>

    gosh> (time (tak 12 6 0))
    ;(time (tak 12 6 0))
    ; real 1.390
    ; user 1.391
    ; sys 0.000
    12
    gosh> 

216 デフォルトの名無しさん [sage] 2009/08/08(土) 05:17:43 ID: Be:
    別に宣伝するのは構わないが、もう少しスレで質問に答えたりすれば
    そんなに悪く言う奴もいなくなると思うが。ひげぽん、どうよ? 

220 デフォルトの名無しさん [sage] 2009/08/08(土) 07:45:26 ID: Be:
    >>215
    0x00 が出力されてるな。
    内部的には ucs4 を使ってるとかいう話があったので、
    変換がうまくいってないのかも。 

221 デフォルトの名無しさん [sage] 2009/08/08(土) 07:58:57 ID: Be:
    (error "a") だけでも再現する。
    (display "a" (standard-error-port)) でもやっぱりおかしい。
    stderr への出力全般がダメっぽいな。 

222 ひげぽん ◆Ngzcp/NZpA [sage] 2009/08/08(土) 11:08:02 ID: Be:
    >>192
    >>194

    すみません。

    >>198
    >>200
    R6RS にも準拠したし俺俺Lisp を脱したかなと思って宣伝してみたのですが
    不愉快だったらすみません。

    >>203
    方向性は実用です。ライブラリを増やしたり速度を気にしたりするのも実用を目指してのことです。

    >>204
    ありがとうございます。そういっていただけると助かります。

    > ところで --loadpath オプションでは複数のパスをコロンで区切って渡せる?
    はい。使えます。
    なるほど。Windows の場合は ; を区切り文字とするように修正します。

    >>209
    そうですね。
    ここに対策が載っていたので修正します。
    http://yanchde.gozaru.jp/winsock2/freeaddrinfo.html

    >>213
    Gauche 並はまだまだ遠いです。がんばります。

223 ひげぽん ◆Ngzcp/NZpA [sage] 2009/08/08(土) 11:09:33 ID: Be:
    >>215
    > エラーメッセージがEmacsで拾えなかった。STDERRへの出力に問題があるのでは?
    Windows では標準出力、エラー出力で WriteConsole 関数を使っているのですがそれがまずいのかもしれません。
    Emacs は Meadow とかでしょうか?(試してみたいので)

    > R6RSだとloadが無いけどどうするの?
    REPL から動的にコードをロードしたいという意味でしょうか?
    ライブラリ形式で保存しておいて (import library-name) はどうでしょう。

    > 竹内関数、かなり速かった。

    まだ Gauche より若干遅いですね。がんばります。

    > 216
    > 別に宣伝するのは構わないが、もう少しスレで質問に答えたりすれば
    > そんなに悪く言う奴もいなくなると思うが。ひげぽん、どうよ?

    可能な限りがんばります。

224 ひげぽん ◆Ngzcp/NZpA [sage] 2009/08/08(土) 11:12:49 ID: Be:

    >>217
    いえバグの内容を指摘してもらえるだけで十分ですよ。

    >>219
    すみません。
    どれくらいの段階になったらよいでしょう?
    言語処理系は完成の定義が難しいですよね。

    >>220
    >>221
    ありがとうございます。
    内部コードは UCS4 でそれを UTF16 にして WriteConsole に渡しています。
    cmd.exe でも出力されていないとかだったらかなりまずいですね。 

225 デフォルトの名無しさん [sage] 2009/08/08(土) 12:35:58 ID: Be:
    >>224
    cmd.exe の上ではちゃんと表示される。

    >>223
    > Emacs は Meadow とかでしょうか?

    俺は >>215 じゃないけど、少なくとも GNU Emacs 23.1.1 では再現することを確認した。
    具体的には GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600) of 2009-07-30 on SOFT-MJASON

    >>215
    > R6RSだとloadが無いけどどうするの?

    そんなこと言ったらそもそも repl だって R6RS には無いぞ。
    Haskell みたいに repl では定義を禁止にしたら意味論の破綻はないかも。
    そう考えると R6RS って動的な性質が制限されてて Lisp 系言語っぽくないよね。

    とりあえず emacs から使う分にはファイル範囲を全選択して C-c C-r でいいんじゃね? 

226 デフォルトの名無しさん [sage] 2009/08/08(土) 12:40:45 ID: Be:
    >>224
    http://msdn.microsoft.com/ja-jp/library/cc429845.aspx
    WriteConsole 関数は、コンソールハンドル以外にリダイレクトされている標準ハンドルを渡すと失敗します。

    emacs に限らずリダイレクトしたらダメってことだよな。
    使えないなぁ…。 

236 デフォルトの名無しさん [sage] 2009/08/08(土) 14:46:56 ID: Be:
    >>235
    gauche は gauche 使ってるよ。
    svn trunk も常に「最も最近のリリース版」を使ってビルドできるようになってる。 

237 デフォルトの名無しさん [sage] 2009/08/08(土) 14:47:40 ID: Be:
    (たまにミスってるときもあるけど) 

237 がなんとなく shiro さんの書き込みのような気がしたんだけどまさかねw

Perlについての質問箱 41箱目
18 デフォルトの名無しさん [sage] 2009/08/07(金) 17:38:40 ID: Be:
    PHPのob_start()のように、出力を一時的にバッファリングすることはできますか。

    ob_start();
    print "aaa\n";   #なにも表示されない
    $output = ob_get_clean(); # $output eq "aaa\n"

    よろしくお願いします。

21 デフォルトの名無しさん [sage] 2009/08/07(金) 18:23:27 ID: Be:
    >>18
    STDOUTを書き換えればできたと思う。
    ソース、おぼろげな記憶。 

23 デフォルトの名無しさん [sage] 2009/08/07(金) 18:35:39 ID: Be:
    >>18
    ファイルに退避させることはできるな。
    #!/usr/bin/perl

    *TAIHI = *STDOUT;
    open(IN, '>/tmp/foo');
    *STDOUT = *IN;
    print "hello, world!\n";
    *STDOUT = *TAIHI;
    print "hi, there!\n";

    メモリに退避する方法は良く分からん。open2使ったけど
    うまくいかんかった。 

24 デフォルトの名無しさん [sage] 2009/08/07(金) 18:49:03 ID: Be:
    #!/usr/bin/perl
    use IPC::Open2;

    *TAIHI = *STDOUT;
    $pid = open2(\*OUT, \*IN, 'cat');
    *STDOUT = *IN;
    select STDOUT;
    print "hello, world!\n";
    *STDOUT = *TAIHI;
    close(IN);

    print "hi, there!\n";

    $output = join("", <OUT>);
    print $output;

    こうか。結構めんどいな。つーかINとOUTを逆にしてて動かないだけだった。 

25 デフォルトの名無しさん [sage] 2009/08/07(金) 18:49:47 ID: Be:
    あーselect STDOUTっての要らないから取っといて。 

26 デフォルトの名無しさん [sage] 2009/08/07(金) 18:53:10 ID: Be:
    5.8.0からin-memoryバッファをopenできるようになったよ

    use strict;
    my $buffer;

    sub ob_start
    {
    open(MEM, ">", \$buffer) or die;
    select(MEM);
    }
    sub ob_get_clean
    {
    select(STDOUT);
    return $buffer;
    }

    ob_start();
    print "hogehoge\n";
    print ob_get_clean(); 

あまり知られてないか、これは。

C++相談室 part71
330 デフォルトの名無しさん [sage] 2009/08/08(土) 17:58:04 ID: Be:
    return で返される値は
    返り値
    戻り値
    など色々呼び名があると思いますが、
    C++用語としてはどれが正しいでしょうか? 

332 デフォルトの名無しさん [sage] 2009/08/08(土) 18:31:18 ID: Be:
    >>330
    いちおう、 JIS 規格では「返却値」。
    ほとんどの場合はどれでも通じるから、どれが正しいとも正しくないとも思わないけどね。 

333 デフォルトの名無しさん [sage] 2009/08/08(土) 18:33:05 ID: Be:
    >>332
    返却値ですか。
    ありがとうございました。 

JIS 規格は「バック参照」って謎訳があるしなあw

■_ 本日の巡回から

2009年08月07日

■_

・ムダヅモ無き改革 Vol.2
げと。帯にアニメ化とありますな。 大魔法峠と同じ制作陣かなあ。

・YAPC
ちけっとげと。でもさー ついに YAPC Asia 2009 のチケット販売が開始しました。 ( http://imepita.jp/20090806/566260 ) って表現がすげー気になる。 「チケット販売を開始しました」とか 「チケット販売が始まりました(開始されました)」 じゃないのかなあ。

■_ 一行野郎が一杯

まだシリーズの途中ですが。 Famous Perl One-Liners Explained, Part I: File Spacing - good coders code, great reuse Famous Perl One-Liners Explained, Part II: Line Numbering - good coders code, great reuse から、スクリプトの部分だけ抜き取り。 さて、それぞれのスクリプトがどういう動作をするかわかりますか? 答えは元記事をどうぞ。


perl -pe '$\="\n"'

perl -pe '$_ .= "\n" unless /^$/'

perl -pe '$\="\n\n"'

perl -pe '$_.="\n\n"'

perl -pe '$_.="\n"x7'

perl -e 'print "foo"x5'

perl -pe 's//\n/'

perl -ne 'print unless /^$/'

perl -00 -pe ''

perl -00pe0

perl -00 -pe '$_.="\n"x4'

perl -pe '$_ = "$. $_"'

perl -pe '$_ = ++$a." $_" if /./'

perl -ne 'print ++$a." $_" if /./'

perl -pe '$_ = ++$a." $_" if /regex/'

perl -ne 'print ++$a." $_" if /regex/'

perl -ne 'printf "%-5d %s", $., $_'

perl -lne 'END { print $. }'

perl -le 'print $n=()=<>'

perl -le 'print scalar(()=<>)'

perl -le 'print scalar(@foo=<>)'

perl -ne '}{print $.'

perl -le 'print scalar(grep{/./}<>)'

perl -le 'print ~~grep{/./}<>'

perl -le 'print~~grep/./,<>'

perl -lne '$a++ if /^$/; END {print $a+0}'

perl -le 'print ~~grep{/^$/}<>'


@hi_saito さんは awk で書いてみるといいと思う (一行野郎にはできないのもあるけど)。

■_ 放言方言

The Old New Thing : The great thing about regular expression engines is that there are so many to choose from

Back in the days before perl ruled the earth, regular expressions were one of those 
weird niche features, one of those things that everybody reimplements when they need 
it. If you look at the old unix tools, you'll see that even then, there were three 
different regular expression engines with different syntax. You had grep, egrep, and 
vi. Probably more.

perl が地球を支配する以前、正規表現は weird でニッチな機能の一つでした。
そして、自分が必要としたときに誰もがそれを再実装するもののひとつだったのです。
古い unix toolsを調べてみれば、あなたはそこには相異なる構文を持った
三種類の正規表現エンジンがあることに気がつくでしょう。まずは grep, egrep, vi
ですが、おそらくもっとあることでしょう。

The grep regular expression language supported character classes, the dot wildcard, 
the asterisk operator, the start and end anchors, and grouping. No plus operator, no 
question mark, no alternation, no repetition counts. The egrep program added support 
for plus, question mark, and alternation. Meanwhile, somebody went back and added 
repetition counts to grep but didn't add them to vi; somebody else added the  and 
metacharacters to vi but didn't add them to sed. POSIX added repetition counts 
to awk but changed the notation from \{n,m\} to {n,m}. And so on.

grep が受け付ける正規表現ではキャラクタークラス、ドットを使ったワイルドカード、
アスタリスク演算子、開始と終了のそれぞれのアンカー、グループ化があります。
プラス演算子やクエスチョンマーク、選択はサポートしていません。egrep では
プラス演算子とクエスチョンマーク演算子、それに選択のサポートが追加されています。
さて、ある人が grep に繰り返し回数の指定を追加しましたが、それは vi には追加
されませんでしたし、別のある人が and のメタキャラクターを vi に追加したのですが
それは sed には追加されませんでした。POSIX は繰り返し回数の指定を awk に
追加しましたがその表記は \{n,m\} から {n,m} のように変えられました。

No two programs use the same regular expression language, but they overlap 
sufficiently that you can often get by with the common subset and not have to worry 
about which particular flavor you're up against.

同一の正規表現を使っているプログラムはありません。しかしかなりの部分で
重なっているので、共通のサブセットを決めることが大抵の場合は可能であり
自分が使おうとするものについて心配しなければならないことはあまりありません。

Until you wander into the places where they differ.
違いが問題となる場所に来てしまうまでは。

    From: John Jones
    Subject: Problem with regular expression

    I'm trying to write a regular expression to match blah blah blah.

    From: Jane Smith
    Subject: RE: Problem with regular expression

    I think this will match what you want: ^Z@1&*B*!34

I just ran my hand randomly over the keyboard to generate that fake regular expression. 
The scary thing is, at first glance, it is not obviously not a regular expression!

    From: Chris Brown
    Subject: RE: Problem with regular expression

    Try $)(#$C)*#

    From: John Smith
    Subject: RE: Problem with regular expression

    Thanks, everybody, for your suggestions, but I can't get any of them to work. For 
    example, I can't get any of them to match against this string: blah blah blah blah.

    みんな、助言をありがとう。でもこれ以上はもう無理だ。たとえば
    blah blah blah blah といった文字列にマッチさせることができない。

At this point, people chimed in with other suggestions, confirming that John doubled 
the backslashes, that sort of thing. John posted his test program, and then the reason 
was obvious.

    From: Jane Smith
    Subject: RE: Problem with regular expression

    Oh, you're using CAtlRegExp. In that class, \w doesn't match a single character; 
    it matches an entire word. You want to use \a instead.

    ああ、CAtlRegExp を使っているのですね。これの \w は一文字にマッチするんじゃなくて
    単語全体にマッチするんですよ。あなたが使いたいのは \a ですね。

Published Thursday, August 06, 2009 7:00 AM by oldnewthing

あれ、vi に and の機能とかあったっけ?

■_ 本日の巡回から

■_

おかしいな。なんでこんなに時間が経つのが早いのだろう。 アレもコレも片付ける時間はあったはずなのに。


過去の雑記帖

  1. 2009年8月(中旬)
  2. 2009年8月(上旬)
  3. 2009年7月(下旬)
  4. 2009年7月(中旬)
  5. 2009年7月(上旬)
  6. 2009年6月(下旬)
  7. 2009年6月(中旬)
  8. 2009年6月(上旬)
  9. 2009年5月(上旬)
  10. 2009年5月(中旬)
  11. 2009年5月(下旬)
  12. 2009年4月(上旬)
  13. 2009年4月(中旬)
  14. 2009年4月(下旬)
  15. 2009年3月(上旬)
  16. 2009年3月(中旬)
  17. 2009年3月(下旬)
  18. 2009年2月(下旬)
  19. 2009年2月(中旬)
  20. 2009年2月(上旬)
  21. 2009年1月(上旬)
  22. 2009年1月(中旬)
  23. 2009年1月(下旬)
  1. 2008年
  2. 2007年
  3. さらに前
この文書の無断転載はご遠慮ください(リンクはご自由にどうぞ)。

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