ときどきの雑記帖 濫觴編

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

一つ前へ 2011年11月(上旬)
一つ後へ 2011年11月(下旬)

ホームへ

2011年11月20日

■_

別に読んでもためになるとは限らないけどプログラマーに勧める十冊(そのいち)
ローマ人の物語〈10〉― すべての道はローマに通ず
文庫だと二分冊になりますが、合わせて1000円。 ローマ人の物語〈27〉すべての道はローマに通ず〈上〉 (新潮文庫) ローマ人の物語〈28〉すべての道はローマに通ず〈下〉 (新潮文庫)
続く。かどうかは誰にもわからない。

一度行かねばならんかw とはいえこの種のメッセージが毎日ではないだろうし。 Twitter / @ytsuboi: 秋葉原のモス店員さん、凄いな。 http://t.c ...

ここかな? MOS BURGER|店舗案内

■_ PCRE

なんかいろいろ手が入っているらしいので調べる。 PCRE - Browse /pcre at SourceForge.net のディレクトリの日付を信じて目安にすると

8.20 	2011-11-02
8.13 	2011-11-02
8.12 	2011-01-15
8.11 	2010-12-13
8.10 	2010-06-25
8.02 	2010-03-19
8.01 	2010-01-19
8.00 	2009-10-19
7.9 	2009-04-11
7.8 	2008-09-05
7.7 	2008-05-07
7.6 	2008-01-28
7.5 	2008-01-11
7.4 	2007-09-23
7.3 	2007-08-28
7.2 	2007-06-19
7.1 	2007-04-25
7.0 	2006-12-19
6.7 	2006-12-07
6.6 	2006-12-07
6.5 	2006-12-07
6.4 	2006-12-07
6.3 	2005-08-24
6.2 	2005-08-24
6.1 	2005-06-23
6.0 	2005-06-23
4.4 	2004-10-12
5.0 	2004-10-12
4.5 	2004-10-12
4.3 	2003-05-28
4.0 	2003-05-28
4.2 	2003-05-28
4.1 	2003-05-28
3.9 	2002-02-07
3.8 	2002-02-07
3.7 	2001-10-31
3.5 	2001-10-31
3.4 	2001-10-31
3.3 	2001-10-31

7.x の最初の方まではたぶん読んでたような気がする。

■_

Why is Funding Perl Core Development So Difficult? - Modern Perl Books, a Modern Perl Blog

Why is Funding Perl Core Development So Difficult?
By chromatic on November 16, 2011 3:28 PM

PHP has Zend. Python has Daddy Googlebucks. Java has... let's call it the 1% of 
programming languages. C# has Microsoft. JavaScript has everybody who's ever written a 
web browser (except possibly the W3C).

PHP には Zned があり、Python には Daddy Googlebucks があり、Java は…
これはプログラミング言語の 1% と呼ばれるものがあります。
C# には Microsoft があって、JavaScript にはweb ブラウザーを書いたことのある
人すべてがいます(except possibly the W3C)。

I haven't used Windows for work purposes in ages, but I'm glad ActiveState exists — Perl 5
is much better on Windows for their assistance.

わたしは長いこと Windows を仕事のために使っっていません。しかし、
ActiveState が存在していて、Perl 5 が彼らの助力によってWindows上でより良いものに
になっていることは喜ばしいと思っています。


I'm also glad to see Perl Foundation sponsors, especially the ones who've contributed 
to the Fixing Perl 5 Core Bugs Grant.

また、Perl Foundation のスポンサー、特に Perl 5 Core Bugs Grant を fix するのに
貢献した人たちに会うことはわたしにはとてもうれしいことです。

Yet I wonder why it's so amazingly difficult to get full-time funding for new Perl 5 
core development. (Again, this is not to complain about funding for Nick Clark or Dave 
Mitchell, because their work is important and valuable and everyone who's contributed 
deserves gratitude.) I can't decide what I think, but I have some possibilities:

それでもまだ、新たな Perl 5 core development のための full-time funding を得ることが
amazingly に難しいということがわたしには不思議なのです
(繰り返しますが、これはNick Clark や Dave Mitchell の funding に対する不満ではありません)。

    * Perhaps Perl is just too effective. It's a tool you apply when you need to do
      something quick or dirty or now, and after that it just works and you forget about
      it. (There's a lot of code like this in the world. Then again, a lot of small
      businesses still run on Access and other 4GLs.)

      Perl は効率的過ぎるのかもしれない。
      Perl はあなたがなにかを手っ取り早くやらねばならないときに使う道具です。
      そして動いてしまえばそれについては忘れてしまうのです

    * Perhaps the dominant perception of Perl 5 is a life support system for the CPAN. 
      (Much of the evolution of Perl happens on the CPAN to be sure, and so volunteer
      effort goes there.)

      Perl 5 の dominant perception はおそらく、CPAN のためのシステムの leif support です。


    * Certainly it's too difficult to hack on the Perl 5 core, so the available contributor
      pool is not in what anyone might legitimately call a state of growth.

      Perl 5 のコアをハックすることはとても難しいので、
      

    * Perhaps new development in Perl 5 tends to be plumbing tasks and not big, 
      bet-the-company technical choices. (Even though my business relies completely on Perl 5
      for its technology stacks, I've long realized that I'm not representative of the 
      world as a whole.)

      おそらく、Perl 5 での新規開発は

    * Perhaps everyone assumes someone else will take care of it. (Larry hasn't had a 
      patron since 2000.)

      たぶん誰もが自分以外の誰かが面倒を見るだろうと思っている

    * Perhaps Perl 5 has reached minimum viable utility as it is and needs no more new features.
      (I have trouble believing this. I could certainly use better parallelism. 
      I've long wanted either or both of hygenic macros and continuations. I could use 
      multiple dispatch today. Grammars would be wonderful. Opaque objects would be grand. 
      Who doesn't want a JIT or more speed or lower memory usage?)

      Perl 5 は もはやこれ以上の新機能を必要としない minimum viable utility に到達してしまったのかもしれない
      (I have trouble believing this. I could certainly use better parallelism. 
I've long wanted either or both of hygenic macros and continuations. I could use 
multiple dispatch today. Grammars would be wonderful. Opaque objects would be grand. 
Who doesn't want a JIT or more speed or lower memory usage?)


    * Perhaps backwards compatibility is cannibalizing usage from current (and future) 
      releases. (Red Hat and CentOS, please feel free to join Perl 5 in the 21st century. 
      We're pretty sure this century will stick by now.)

      後方互換性が現在(と将来)のリリースを共食いしてしまっているのかもしれない

    * Perhaps TPF isn't effective at courting donors. (I hesitate to bring this up, because
      it sounds like criticism, but that's not the intent. I do believe TPF has successfully
      courted some donors, which is the reason why Nick and Dave have funding right now, and
      I have no desire to criticize the work or abilities or interests of volunteers doing
      things I have no desire to do, but it does seem fair to say that I haven't seen much
      effort in the past five years to talk to large Perl shops to express a coherent vision
      for core development.)

    * Perhaps (and I find this most likely) there's no coherent vision for Perl 5 core
      development. Jesse Vincent's Perl 5.16 and Beyond (video link) lays out a good and 
      effective and necessary philosophy for how to manage changes, but is there really 
      anything to get excited about? strict and warnings by default?

      Perl 5 の core development に対する coherent なビジョンがないのではないか?
      Jesse Vincent の Perl 5.16 and Beyond は

    * Perl 6 didn't save Perl. (Yes, yes, Milestones in the Perl Renaissance, but
     "Someday this will be amazing!" becomes less amazing the longer someday takes.)

      Perl 6 は Perl を救わなかった


It's no one thing and it's probably a combination of several things to various degrees. 
I hope that someone like the amazing Mike Pall of LuaJIT might come along and demonstrate
a powerful proof of concept of something exciting (better parallelism/concurrency, macros,
an improved parser, a working JIT, a no-XS extension mechanism, an 80% port of the sanest
parts of Perl 5 to a different virtual machine, whatever). Maybe that's Reini Urban, and
maybe it's someone we don't know about yet.

LuaJIT の amazing Mike Pall のような誰かが現れて exciting ななにかの
powerful proof of concept をデモンストレーションしないかと期待しているのです。



It's difficult to imagine someone new jumping in to the big wad of heavily-macroed C code
that's the current Perl 5 implementation and having all of the time, interest, and energy
to learn what's going on as well as the luck, skill, and patience to make substantive
changes without horribly breaking a dozen things elsewhere while successfully convincing
p5p that the changes are worthwhile and maintainable and won't be the subject of massive
imprecations and furrowed brows in two years.

Maybe I'm just a pessimist today though.

わたしは今、悲観的になっているだけなのかもしれません。

What do you think?
あなたの考えは?

This blog is licensed under a Creative Commons License.

だめだ、時間がねー

■_

■_

これも翻訳待ち :)

InfoQ: Mitchell Harper: University Education of Software Engineers is a Waste of Time

Mitchell Harper: University Education of Software Engineers is a Waste of Time

Posted by Michael Stal on Nov 15, 2011

Mitch Harper, co-founder of BigCommerce.com, claimed in a recent issue of the Sydney 
Morning Herald that university education might be the wrong way to become a software 
engineer. According to Harper, a self-educated software engineer without an university 
degree: universities leave their students rather unprepared for the realities of being 
a software engineer. He also mentioned the reasons for this assumption:

BigCommerce.com の co-founder である Mitch Harper は
Sydney Morning Herald の最近の issue で大学での教育はソフトウェアエンジニアを育てる
間違ったやり方ではないかと主張しました。



    (Australian) startups need graduates who can hit the ground running, who are proficient
    in PHP, Python and Ruby (among other modern programming languages), and who, ultimately,
    understand the practical side of software engineering as opposed to just the theoretical
    side which they learn at university.

(以下略)

■_ 気になる本

例の経路で得た新刊情報。

Amazon.co.jp: Naked Code: The Ultimate Guide to Programming in Any Language: Eldad Eilam: 洋書

内容説明
Learn to program in any language with this simple set of programming operations

Most people learn how to program by studying a high-level programming language such as
Java, C++, or C#. Naked Code presents a revolutionary new approach. This unique book
shows how the most complex concepts can be boiled down into a set of simple, accessible,
core programming operations. Author Eldad Eilam, writing in the engaging and
easy-to-follow style he used in his acclaimed book Reversing: Secrets of Reverse
Engineering, translates high-level code into the fundamentals, helping novice
programmers truly understand programming and helping experienced programmers deepen
their skills.

大部分の人は、プログラミングのやり方を Java や C++、C# のような高水準言語によって学びます。
Neked Code は革命的に新しいアプローチを提供します。この unique な本はほとんどの複雑なコン
セプトが単純で、accessible な core programming operations の集まりへと boild down できる
ことを示します。

    * Offers a revolutionary approach to learning how to program in any language

      任意の言語においてプログラミングの方法を学ぶ革命的なアプローチを提案します

    * Gives novice programmers and experienced developers a deeper understanding of how
      code works at the machine level

      初心者プログラマーと熟練した developer に machine level において動作するコードの
      深い理解を与えます

    * Lays the groundwork, then teaches higher-level programming languages by mapping
      human code to machine code

    * Walks readers through the design and building of two applications, a game application
      in C++ and a Web application in JavaScript

      読者はこの本を通じて二つのアプリケーションの設計と構築を行います。
      C++ でゲーム、JavaScript でWebアプリケーション

    * Explains concepts in the engaging and accessible style that made the author's
      acclaimed book, Reversing: Secrets of Reverse Engineering, so successful

Naked Code: The Ultimate Guide to Programming in Any Language is a revolutionary 
approach for novice and experienced programmers, alike.

登録情報

    * ペーパーバック: 648ページ
    * 出版社: Wiley; 1版 (2012/5/29)
    * 言語 英語, 英語, 英語
    * ISBN-10: 0470563133
    * ISBN-13: 978-0470563137
    * 発売日: 2012/5/29

ほぼ650ページか。結構厚いね。

■_

【アンチ】関数型言語は使えない【玩具】 

152 デフォルトの名無しさん [sage ] 2011/11/17(木) 23:21:28.94 ID: Be:
    にしてもCTMCPをやってる人って少ないよね。(ネットでは)
    一部の読んだ人って大学の輪講とかで使ってんのかな。 
【アンチ】関数型言語は使えない【玩具】 

157 デフォルトの名無しさん [sage] 2011/11/18(金) 04:11:37.15 ID: Be:
    関数型言語って役に立つな。
    スイスの海軍並に役に立つな。 

やっべ。ガウディ本(CTMCP)あと少しのところで止まってる

2011年11月19日

■_

・三つ被り
勉強会やら読書会が三つ被っているという事態。 泣く泣くひとつに絞って参加。

・逆王手
ついったでも見かけましたが、今回のドラゴンズのように3勝3敗に持ち込んだのを 「逆王手」と表現するのはどうにも変な気が。 ホークスが王手(あと一勝すれば優勝)かけているのは変わっていないのだし。

IT断食 BLT

■_

でまあ 速攻MinCamlコンパイラ概説 のソースコードを読んでみようという集まりに行ってきました。 メインの部分 (main.ml) を見て

let limit = ref 1000

let rec iter n e = (* 最適化処理をくりかえす (caml2html: main_iter) *)
  Format.eprintf "iteration %d@." n;
  if n = 0 then e else
  let e' = Elim.f (ConstFold.f (Inline.f (Assoc.f (Beta.f e)))) in
  if e = e' then e else
  iter (n - 1) e'

let lexbuf outchan l = (* バッファをコンパイルしてチャンネルへ出力する (caml2html: main_lexbuf) *)
  Id.counter := 0;
  Typing.extenv := M.empty;
  Emit.f outchan
    (RegAlloc.f
       (Simm.f
	  (Virtual.f
	     (Closure.f
		(iter !limit
		   (Alpha.f
		      (KNormal.f
			 (Typing.f
			    (Parser.exp Lexer.token l)))))))))

let string s = lexbuf stdout (Lexing.from_string s) (* 文字列をコンパイルして標準出力に表示する (caml2html: main_string) *)

(以下略)

字句解析して構文解析して型解析してK 正規形にしてα変換して(ひとつとばして) βリダクションして仮想機械の中間言語にしてレジスター割り当てして アセンブリ言語のコードを吐く。 というのがはっきりわかって面白かった。 個々の関数は読み返さないと良くわかっていない部分も多いのだけどw

というか

最新コンパイラ構成技法

これ読んでたはずじゃあ>わし

Amazon.co.jp: 最新コンパイラ構成技法: Andrew W. Appel, 神林 靖, 滝本 宗宏: 本

内容紹介
あの“名著”堂々の翻訳刊行!

本書は、プリンストン大学のコンパイラ講座の授業内容に沿ったコンパイラ構成法の教科書であ
りながら、不朽の名著『コンパイラ 原理・技法・ツール』(ドラゴンブック)に並び称される、
別名「タイガーブック」とも呼ばれる“Modern Compile Implementation in ML”の翻訳です。

ML(メタランゲージ)という理論的背景の非常にしっかりした言語を教材に、オブジェクト指向型
言語や関数型言語といった最新の言語のコンパイラをどのように構築・実装するかを懇切丁寧に
解説してある本筋に加え、ガベージコレクションやコンパイラの最適化など、他に類を見ない充
実した内容を誇り、研究者・専攻学生はもとより、ソフトウェア開発現場のメインストリームに
いるエンジニアにも待望の一冊となることでしょう。

もう一度読むか。

ところで、コードを読んでいるときに調べものをしていると ホワット・ア・ワンダフル・ワールド Treelang Hacking Guide (4) とか ヒビルテ(2006-09-12) とかいう方々の書き込みがびしびし引っかかって 自分の周回遅れ感がレベルマックスなんですが ○| ̄|_

メモ的に。

■_ Scala question, how to find answers : scala

みずしまさんのつくったあれは Q and A はないのでしたっけ?

日本語話者の場合は、ついったーで発言すると自動的にみずしまさんが捕捉して 回答をツイートしてくれる。 とかだったりw

Scala question, how to find answers : scala

I have some basic, newbie type questions about Scala that I'm having the damnedest 
time finding answers to through googling. Is there a better avenue for me?

For example I have a little program that does
* var lineArray = lines.split("\r?\n")
* .Before it was
* var lineArray = lines.split("\n")
* which did not work.
I found the answer (as in the correction I need to make) but I can't for the life of
me find why this happened.

In trying to figure this out googling: * scala "r?" -scalar * didn't do much 
good. The first question I had I asked the google group for scala which helped, but 
it's weird to email a group with every trifling thing. I'm looking for a message board 
or a good web reference or something. Ideally if someone could figure this answer out 
with research then show me how they did, I would happily follow their method of 
research the next time.

scala "r?" -scalar でぐぐっても良い答えはみつかりませんでした。
まず scala 向けの google group で尋ねてみたのですが、くだらない内容の
メールがたくさんありました。
わたしはメッセージボードか、そうでなければ優れた web reference のようなものを
探しています。誰かこの疑問に対する回答をその人の調べ方と一緒に教えてくれると
とても良いのですが。次回はそのやり方で自分もやってみようと思います。


http://stackoverflow.com/questions/tagged/scala


Scala API can answer a lot of questions. But it won't help your example since split is 
for java.lang.String. If you look there you will find split takes a regular expression. 
Googling regular expressions would answer what "\r?\n" is doing. It is 
optionally matching cartridge returns followed by a required line feed: line endings 
in Windows and Unix. Sorry if you already figured out as much.

Following all the implicit conversions, like from java.lang.String to 
scala.collection.immutable.WrappedString and back, can be tricky but if you look at 
scala.Predef you will find the most used ones.


FTFY: "cartridge returns" is a typo for "carriage return". Don't 
go googling cartridge return.

Just so you understand the issue, different platforms have different ideas about what 
marks the end of a line in a plain text document. The file you were parsing was 
presumably generated by a Windows program. "\n" would have worked fine on a 
file made by a Unix program. "\r\n" for windows. "\r?\n" for 
either. And internet protocols use a subtly different endline marker.


If you ask questions here, I'll do my best to help.


Thanks! I've posted to http://stackoverflow.com/questions/8188959/r-the-meaning-of-in-scala

■_

Tweenが広告でマネタイズに成功するたった1つの方法 - 酢ろぐ(ch3cooh.jp)

■_ 電書

値段もまあそれなりにするけれども、その大きさでなかなか買えないでいたり 買ったけど置き場所に困っているような本が電書になっているといいのになあと思ったり。 具体的にはこの辺。 ってまあ、読む環境もどうにかしないとなんですが (元の版型がでかいので、小さい画面だと厳しい)。

たとえばこの辺。

コンピュータプログラミングの概念・技法・モデル(IT Architect' Archiveクラシックモダン・コンピューティング6) (IT Architects’Archive CLASSIC MODER) 最新コンパイラ構成技法 実用 Common Lisp (IT Architects’Archive CLASSIC MODER) セーフウェア 安全・安心なシステムとソフトウェアを目指して (IT Architects’Archive)

■_

2011年11月18日

■_

かーねーがーないーーーーーーーー

ポイントフリーこえー スタートHaskell で concatMap のポイントフリー厨な定義を理解した! - わからん

■_ Do you still read source code to learn how to use an API?

IDEの進化もすごそうですねえ。

How much can the IDE predict what you will write in the next seconds?: Do you still read source code to learn how to use an API?

Do you still read source code to learn how to use an API?
あなたはAPIの使い方を学ぶのにまだソースコードを読んでるんですか?

We all agree that learning new APIs is a challenging and time consuming task. However, 
we can't get around this, right? It is the way how software development works nowadays. 
But it's also part of the fun we have when creating new software and make it work. 
However, sometimes we wish we would be little more efficient - especially when digging 
into the source code written by others to learn how to use an API, or when using code 
search to find code examples.

わたしたちはみな、新しいAPIを学ぶことが challenging であると同時に時間を消費する
task であることに同意するでしょう。
しかし、わたしたちはそれに対処することができない。本当に?
それは今日のソフトウェア開発のがまわっているやり方ではありますが、
新しいソフトウェアを作りそれが動くようにすることは楽しいことでもあります。
とはいえわたしたちは自分たちがもう少し効率良くなっていればと望むこともあります。
とくに、APIの使いかたを知るために他人の書いたソースコードに「もぐっている」
ときであるとか、コードの例を見つけるためにコード検索を使っているときがそうです。

Apparently, reading source code is valuable. But have you ever though about how the 
knowledge how others used an API could be leveraged to improve IDE services such as 
Code Completion, Code Search, or even API documentation?

ソースコードを読むことは valuable ではあるのですが、
他のひとがどのようにAPI を使って
コードの補完や検索、APIのドキュメントといった
IDE サービスを改良して効率を上げているのか知りたいとは思いませんか?

In early 2011, the Eclipse Code Recommenders project was created to tread new paths on 
how the next generation of IDEs could enable developers to share knowledge with each 
other over their IDEs and to improve tools like code completion, code-search, and even 
to enrich existing documentation by leveraging the knowledge of the masses.


Since it's inception, the project made an amazing progress. Many tools have been 
developed since such as:

    * Intelligent (context-aware) Code Completion,
      (コンテキストを考慮する) インテリジェントなコード補完

    * Dynamic (mined) Code Templates,
      動的なコードテンプレート

    * Code snippet search engines,
      コードスニペット向けの検索エンジン

    * Extended (mined) Documentation platform,

and a lot more. 9 Months later, we published v0.4 of Code Recommenders and presented it at
EclipseCon Europe. If you haven't heard about Code Recommenders yet, it's time to spent a
few minutes now to learn how IDEs will change your way of developing software in the next
year:

もしまだ Code Recommenders のことを知らないのなら、いまこそちょっとの時間を割いて
IDE がいかにあなたのソフトウェア開発の手法を変えるのかを知るときです。

EclipseCon なんてのがあるんですか

■_ Java の lambda は

入っても入らなくてもいろいろいわれてしまう。と。

Java8 Lambda Expressions – Perhaps not as sexy as intended? | Craig Tataryn's .plan

Java8 Lambda Expressions – Perhaps not as sexy as intended?

Posted by craig on Nov 15, 2011 in Blog

(略)

Java8 vs Scala Lambdas – Function Types vs. SAM

Given Scala's support for Function types, there is a convention Scala uses such that 
if an instance of a Class or Trait is being used as the subject of a function call 
then Scala makes sure the Class or Trait has implemented an appropriate apply method.

For instance, in Scala:

  class SquareInt {
     def apply(x: Int) = x * x
  }
  .
  .
  aval squareInt = new SquareInt
  squareInt(2)

On the last line above, Scala is really just calling the apply method on SquareInt.  
SquareInt isn't actually a proper function, but rather a Class instead.

Expanding on this convention, when Scala sees…

  val squareIt: (Int) => Double = (x) => x * x

… you can imagine Scala taking the following steps before compiling to byte-code:
バイトコードにコンパイルされる前に Scala が以下のようなステップを踏むことが想像できるでしょう

   1. Make the type of the squareIt variable a Function1
   2. Create a new anonymous Class definition that extends Function1
   3. Make the apply method of this new class accept an Int as a parameter and return a Double
   4. Make the body of the apply method contain everything on the RHS of the equal sign
   5. Instantiate a new instance of this class and assign it to the squareIt variable

This convention really boils down to: If you use the squareIt variable like a function 
[i.e. sqaureIt(2)], Scala simply invokes the apply method of the instance.  If no 
appropriate apply method exists, you get red-squigglies in your IDE or compile errors.

(略)

Not First Class but…

So no, functions aren't exactly “first class” in Java8, however the new Lambda 
syntax will absolutely help us make our code more readable. Silver lining found.

■_

とりあえずは日本語記事になるのを待つ。 で、その訳文を見て(ry

InfoQ: Google Dart Roundup: Dart to JS Compiler Frog, Pre-Built Editor/IDE Binaries, Type System Proposals

Google Dart has become easier to try with binary builds of the Dart editor. The
SWT/Eclipse-based tool includes the DartC compiler, project management, application wizards,
etc. and allows to run Dart applications compiled with DartC.

Google Dart はDart エディターのバイナリービルドを使うことがいっそう容易になりました・
SWT/Eclipse-based tool には DartC コンパイラー、プロジェクト管理、アプリケーションウィザード
などなどが含まれていて、DartC でコンパイルした Dart アプリケーションを実行できます。

The editor runs the type checker on all code and annotates code that contains problems; 
providing type annotations helps the type checker be more useful.

このエディターはすべてのコードに対して型チェッカーを実行し、問題を抱えているコードを
annotete します。
型アノテーションを与えることは型チェッカーをよりいっそう有用なものにする手助けをします。

DartC, shipped with the Dart Editor, is a Dart to Javascript compiler written in Java. 
The question "Why is DartC not written in Dart" can soon be retired thanks 
to a new project in the Dart repository: Frog is a Dart to Javascript compiler written 
in Dart.  The project is now part of the Dart repository and is improving and evolving 
very quickly; it can also serve as a growing example Dart codebase. 

Dart エディターとともに出荷されている DartC は、 Javaで書かれた Dart から Javascript
へのコンパイラーです。「なぜ DartC は Dart で書かれていないのか」という疑問は
Dart のリポジトリにある新しいプロジェクトをみれば即座に解消します。
Frog は Dart で書かれた Dart から Javascript へのコンパイラーです。
Frog プロジェクトは現在 Dartのリポジトリにあって、改良と進化が続いています。
これは成長しているDart のコードベースの一例としても serve できます。

(略)

■_

正規表現のマッチングでたまーに結果が出るまでに時間がかかりすぎることがある

php - Why does this regex take so long to find email addresses in certain files? - Stack Overflow

Why does this regex take so long to find email addresses in certain files?

I have a regular expression that looks for email addresses ( this was taken from another
SO post that I can't find and has been tested on all kinds of email configurations ...
changing this is not exactly my question ... but understand if that is the root cause ):

メールアドレスを見つけ出す正規表現があります
(これはStackoverflow にポストされたものからとってきたものですが
わたしには理解できませんし、メールアドレスの configuration すべてを試してはいません。
これを変更することがわたしの質問ではありません。とはいえこれがすべての原因であろう
とは理解しています)


  /[a-z0-9_\-\+]+@[a-z0-9\-]+\.([a-z]{2,3})(?:\.[a-z]{2})?/i

I'm using preg_match_all() in PHP.

わたしは PHP で preg_match_all() を使っています

This works great for 99.99...% of files I'm looking in and takes around 5ms, but
occasionally takes a couple minutes. These files are larger than the average webpage at
around 300k, but much larger files generally process fine. The only thing I can find in
the file contents that stands out is strings of thousands of consecutive "random"
alphanumeric characters like this:

これはわたしが検索に使ったファイルの 99.99...% ではとてもうまく動き、おおむね 5ミリ秒ほど要します。
しかしときおり数分かかることがあるのです。
そういったファイルは300kほどで、平均的なwebページよりも大きなものですが
もっと大きなファイルでも普通に処理しているのです。
時間の掛かるファイルの内容でわたしが気がついたただひとつのことは
次のような「ランダムな」英数字がたくさんあるということです。

  wEPDwUKMTk0ODI3Nzk5MQ9kFgICAw9kFgYCAQ8WAh4H...

Here are two pages causing the problem. View source to see the long strings.

    * http://www.ashrae.org/members/page/607
    * http://www.ashrae.org/publications/page/2010ajindex

Any thoughts on what is causing this?

--FINAL SOLUTION--

I tested various regexes suggested in the answers. @hakre's answer solved the problem 
and reduced processing time to a few hundred milliseconds. @FailedDev's answer helped 
and dropped this from a few minutes to a few seconds. Below is the final regex I used. 
It's @hakre's second suggestion.

  /[a-z0-9_\-\+]{1,256}+@[a-z0-9\-]{1,256}+\.([a-z]{2,3})(?:\.[a-z]{2})?/i

@mario: have you tested with case insensitivity? For me (PCRE 7.6) (ancient, I know), 
both Perl and pcregrep w/o case insensitivity are instantaneous, while pcregrep -i 
takes 5.5s on the possesive quantifier case (28s on the greedy case). Also, as 
expected, atomic greedy takes the same time as possesive. – ninjalj 11 hours ago

@ninjalj: Used /i and PCRE 8.12 (now dated too). Actually my previous test probably 
just failed (php.ini pcre.backtrack_limit likely). Run again. Using possesive approach 
really didn't help much. It was indeed using a reasonable quantifier {1,50} which had 
the best performance impact. 


You already know that your regex is causing an issue for large files. So maybe you can 
make it a bit smarter?

あなたはすでに大きなファイルに対してその正規表現が問題を引き起こすことはわかっている
のですから、自分でもう少し賢いものに修正できるのではないでしょうか?

For example, you're using + to match one or more chars. Let's say you have a string of 
10 000 chars. The regex must look 10 000 combinations to find the largest match. Then 
you combine it with similar ones. Let's say you have a string with 20 000 chars and 
two + groups. How could they match in the file. Probably 10 000 x 10 000 possibilities. 
And so on and so forth.

たとえばあなたはひとつ以上の文字にマッチさせるために + を使っています。
ここで、対象が一万文字の文字列としましょう。質問にあった正規表現では
最大限にマッチするものを見つけるために一万個の組み合わせを検査しなければなりません。
そして、同様の正規表現をあなたは組み合わせています。さて、
二万文字の長さを持つ文字列と二つの + グループを考えてみましょう。
ファイル中にあるそのような文字列にどのようにマッチできるでしょうか。
可能性としては一万×一万の候補が存在します。


If you can limit the number of characters (this looks a bit like you're looking for 
email patterns), probably limit the email address domain name to 256 and the address 
itself to 256 characters. Then this would be 256 x 256 possibilities to test "only":

おそらくメールアドレスのドメインとアドレス自身とをそれぞれ256文字に制限できます。
すると、256×256の候補だけを調べればよくなります。
 
   /[a-z0-9_\-\+]{1,256}@[a-z0-9\-]{1,256}\.([a-z]{2,3})(?:\.[a-z]{2})?/i

That's probably already much faster. Then making those quantifiers possessive will reduce
backtracking for PCRE:

これでもおそらくかなり高速になります。
さらに PCREにバックトラッキングを抑制させるために quantifiers を possessive なものにします:

   /[a-z0-9_\-\+]{1,256}+@[a-z0-9\-]{1,256}+\.([a-z]{2,3})(?:\.[a-z]{2})?/i

Which should speed it up again.

My best guess would be to try using possesive quantifiers :

  [a-z0-9_\-\+]+

to

  [a-z0-9_\-\+]++

This should fail the regex faster so it may improve performance in these situations.
これで正規表現がより早いタイミングで失敗するようになるので
今回のようなシチュエーションでの性能を改善かもしれません。

Edit:

Maybe atomic grouping could also help :
おそらく atomic grouping も同様に助けになるでしょう:

  /(?>[a-z0-9_\-+]++)@(?>[a-z0-9\-]++\.)(?>[a-z]{2,3})(?:\.[a-z]{2})?/

You should first go with option one. It would be interesting to see if there is any 
difference by also using option two.

Although there are slight differences between atomic grouping and possessive quantifiers,
you really only need to use one. Making all greedy quantifiers possessive should fix
Brian's problem, is my guess.

@BartKiers Yeah I had this conflict myself. I will edit the post accordingly. Maybe 
the OP could post some benchmarks using both options.


site design / logo © 2011 stack exchange inc; user contributions licensed under cc-wiki
with attribution required

■_

■_

星野之宣を語れ Part11

303 名無しんぼ@お腹いっぱい [sage] 2011/11/17(木) 14:00:04.34 ID:5cD7IwiJ0 Be:
    【宇宙】木星の衛星「エウロパ」の地表を覆う厚い氷の下に巨大な湖、生命存在の可能性高まる
    http://uni.2ch.net/test/read.cgi/newsplus/1321500379/

    エウロパンが参加したがってる模様です。 

304 名無しんぼ@お腹いっぱい [sage] 2011/11/17(木) 14:05:53.67 ID:gzOrdNjR0 Be:
    どっちかつーと2010年ネタだな。 

自分のあのニュースで2010年を連想した。

2011年11月17日

■_

やっぱり大きな画面の電書リーダーほしい…

■_ string

定着したといえばそれまでですが

正規表現 Part8

785 デフォルトの名無しさん [] 2011/11/16(水) 13:58:16.17 ID: Be:
    質問です。

    文字ストリング「"山田","太郎",,"",,"自宅TEL","03-4567-8901"」から、
    「"山田"」、「"太郎"」、「""」、「"自宅TEL"」、「"03-4567-8901"を取り出したいのですが、
    対象を「.+?」で指定すると、
    「"山田"」、「"太郎"」、「"",,"」、「","」が取り出されます。
    どのような指定にすれば良いのでしょうか 

786 785 [] 2011/11/16(水) 14:01:28.58 ID: Be:
    誤「.+?」⇒正「\".+?\"」です。 

787 デフォルトの名無しさん [sage] 2011/11/16(水) 14:04:34.81 ID: Be:
    .*?にする 

788 609 [sage] 2011/11/16(水) 14:49:26.15 ID: Be:
    >>785
    CSVは一つの正規表現では無理
    パースして順番にマッチしていかないと 

789 785 [] 2011/11/16(水) 16:16:51.38 ID: Be:
    >>787,789
    レスありがとうございます。



790 デフォルトの名無しさん [sage] 2011/11/16(水) 20:58:38.08 ID: Be:
    文字ストリング… 

791 デフォルトの名無しさん [sage] 2011/11/16(水) 21:04:31.23 ID: Be:
    バイトストリングとかあるから別につっかからなくても 


もともと string という単語そのものに「文字列」って意味はなかったですよね。 string of characters。文字の連なり。

■_ 四十周年

だそうで。 インテルのマイクロプロセッサが誕生40周年、その歴史をふり返る - GIGAZINE 世界初のマイクロプロセッサ「Intel 4004」が誕生40周年を迎える | パソコン | マイナビニュース 米国時間の2011年11月15日、1971年に登場し、世界初のワンチップマイクロプロセッサとして知られる 米Intel社の「Intel 4004」が、誕生40周年の節目を迎えた。Intelではこのことを記念し、貴重な写真や ビデオ・インタビュー、各界代表のコメントなどをまとめたアニバーサリーページを公開している。 40th Anniversary of the Microprocessor

わが青春の・・・: つらつらぐさ

 今、復刊せずにいったいいつ復刊するというのか!
400006021X	マイクロコンピュータの誕生―わが青春の4004
嶋 正利
岩波書店 1987-08-28


 アマゾンマーケットプレイス価格がプレミアムすぎる・・・。

#もっとも、今更売れるのか? という疑問も正しいかもしれず。うーむ。

ですよねー。文庫でどうか。

■_ C++ で

Boost 使えばさらにこんなに簡単に! とかやってほしいなあ > /dev/だれか

Implementing Scheme in C++ | Solarian Programmer

Implementing Scheme in C++
Posted on November 14, 2011 by Sol

The code for this tutorial is on GitHub: https://github.com/sol-prog/schm.

Implementing a high order programming language in a low level language, like C++ 
(Assembly is too low level for my background and C … well there are already a few 
Scheme implementations in C), has always been a fascinating subject for me. Writing a 
program that interprets other programs is a great and fun experience for anyone, it is 
almost like a rite or passage for a programmer.

My purpose in starting this series of articles is to better understand some of the 
fundamentals of the Scheme programming language and how an interpreter works. A 
secondary purpose will be to test my Scheme implementation on some of the examples and 
exercises presented in SICP (I will probably skip the Picture language presented in 
Chapter 2). This will allow me to redo some of the exercises from the book on my own 
Scheme implementation and in the same time on a mature implementation like Gambit 
Scheme, for comparison purposes.

The Scheme subset I've choose to start with, is inspired by an article of Peter Norvig 
(How to Write a (Lisp) Interpreter (in Python)). This will be my Scheme – zero 
implementation, only six special forms (quote, if, set!, define, lambda and begin) and 
a generic Number type, that will allow simple operations with integers and floats.

(略)

■_ 今日の十

当然読んでおくべき十個の論文だそうです

10 Papers Every Programmer Should Read (At Least Twice)

■_ それCOBOLで

脆弱性の実証コードをCOBOLで書いたらしく。

#608497 - gimp: four buffer overflows - Debian Bug report logs

Subject: gimp: four buffer overflows
Date: Fri, 31 Dec 2010 14:35:51 +0100

[Message part 1 (text/plain, inline)]

Subject: gimp: four buffer overflows
Package: gimp
Version: 2.6.11-1
Severity: important
Tags: security

Here is a PoC for four new buffer overflows in GIMP. Compile it with open-cobol.


(略)

[gimp-overflows-poc-in-cobol.cob (application/octet-stream, attachment)]

000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID.              GIMP-OVERFLOWS-POC-IN-COBOL.
000030 AUTHOR.                  NON-CUSTOMERS CREW.
000040*SHOE SIZE DECLARATION.   43.
000050
000060 ENVIRONMENT DIVISION.
000070 INPUT-OUTPUT SECTION.
000080 FILE-CONTROL.
000090     SELECT FILE01 ASSIGN TO "GIMP01.LIGHTINGPRESETS"
000100         ORGANIZATION IS LINE SEQUENTIAL.
000110     SELECT FILE02 ASSIGN TO "GIMP02.SPHEREDESIGNER"
000120         ORGANIZATION IS LINE SEQUENTIAL.
000130     SELECT FILE03 ASSIGN TO "GIMP03.GFIG"
000140         ORGANIZATION IS LINE SEQUENTIAL.
000150*    FOR THE 4TH OVERFLOW, SEE BELOW.
000160
000170 DATA DIVISION.
000180 FILE SECTION.
000190 FD FILE01.
000200 01 PRINTLINE   PIC X(800).
000210 FD FILE02.
000220 01 QRINTLINE   PIC X(800).
000230 FD FILE03.
000240 01 RRINTLINE   PIC X(800).
000250
000260 WORKING-STORAGE SECTION.
(略)
001470*   4. THE FUNCTION "read_channel_data()" IN plug-ins/common/file-psp.c HAS AN
001480*      OVERFLOW WHEN HANDLING PSP_COMP_RLE TYPE FILES. A MALICIOUS FILE THAT
001490*      STARTS A LONG RUNCOUNT AT THE END OF AN IMAGE WILL WRITE OUTSIDE OF
001500*      ALLOCATED MEMORY. WE DON'T HAVE A POC FOR THIS BUG.
001510
001520*      HAPPY NEW YEAR!!!               http://rock-madrid.com/
001530
001540        STOP RUN.

reddit での反響 →

Security vulnerability demonstration code submitted in COBOL : programming

Security vulnerability demonstration code submitted in COBOL (bugs.debian.org)


See? Cobol is not dead, it actually kills other software.


Alternatively, it's become a zombie and hungers for the flesh of the maintained.


Ph'nglui mglw'nafh Cobol R'lyeh wgah'nagl fhtagn.


I thought it waited in Xerox PARC.


Xerox PARC*


Is that Perl 6?


Everything is Perl 6.


Zombies are both dead and kill others.


I always thought zombies were undead. What do I know, though?


000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID.              GIMP-OVERFLOWS-POC-IN-COBOL.
000030 AUTHOR.                  NON-CUSTOMERS CREW.
000040*SHOE SIZE DECLARATION.   43.
000050

They have a weird sense of humour, I guess!

■_

2011/11/COMEFROM.md at master from raganwald/homoiconic - GitHub

■_

2011年11月16日

■_

元が大型本のを読むのはこれだとちときついかな。

■_

■_

More than sed and awk ― The EndeavourUnix tool tips ― The Endeavour

■_

宿題と予習がーっ

■_ このあとどうするんだろう

[ruby-core:41040] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp
[ruby-core:41045] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp
[ruby-core:41053] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp
[ruby-core:41054] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp
[ruby-core:41057] Re: [ruby-trunk - Feature #5588] add negation flag (v) to Rege...
[ruby-core:41065] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp
[ruby-core:41067] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp
[ruby-core:41068] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp
[ruby-core:41069] [ruby-trunk - Feature #5588] add negation flag (v) to Regexp

2011年11月15日

■_

近代麻雀買うの忘れた(行ったコンビニになかった)。

テザリングがうまくできない… なんで暗号化方式のところがグレーアウトして変更できないの

映画『戦国BASARA 劇場版』公式サイト|Blu-ray / DVD 新作映像「足軽ダンス劇場版」 これだけ欲しいぞw

いい値段するなあ ◆新品非売品◆戦国BASARA 足軽ダンス 全巻購入特典 DVD - Yahoo!オークション

■_ 近刊

こんなのが。 Amazon.co.jp: Learning Regular Expressions: Michael Fitzgerald: 洋書 あまぞんさんのページを見ても内容がよくわからんので、オライリーのページへ

Learning Regular Expressions - O'Reilly Media

Regular expressions remain a difficult part of the puzzle when learning how to program. 
Commonly used for sifting through large chunks of text, regexes are incredibly powerful
although they may appear daunting to the newcomer. And variations among languages and
environments make them even harder to master.

Loaded with examples, this introductory guide walks beginners step-by-step through the 
fundamentals of regular expressions, and helps you decipher complex patterns.

    * Break down regular expressions into comprehensible parts
    * Learn common usage patterns through simple, easy-to-follow examples
    * Discover how finding unique patterns can help you avoid repetitive, hand-editing of text
    * Use common command-line tools such as grep and sed
    * Compare how regular expressions are implemented in different languages and environments

んー、何ページかでも見てから決めたいなあ。

■_

■_ あとで

hacker news でのお話。 Isaacs: try/catch is an anti-pattern | Hacker News

Isaacs: try/catch is an anti-pattern | Hacker News
This seems to be exactly the attitude of Go:

"We believe that coupling exceptions to a control structure, as in the 
try-catch-finally idiom, results in convoluted code. It also tends to encourage 
programmers to label too many ordinary errors, such as failing to open a file, as 
exceptional.

Go takes a different approach. For plain error handling, Go's multi-value returns make 
it easy to report an error without overloading the return value. A canonical error 
type, coupled with Go's other features, makes error handling pleasant but quite 
different from that in other languages.

Go also has a couple of built-in functions to signal and recover from truly 
exceptional conditions. The recovery mechanism is executed only as part of a 
function's state being torn down after an error, which is sufficient to handle 
catastrophe but requires no extra control structures and, when used well, can result 
in clean error-handling code."

http://golang.org/doc/go_faq.html#exceptions

In Go, if there's a programmer error, call panic(); if there's a non-programmer error, 
return it as a second return value.

[Added] Plus, it's obvious to see where people ignore errors:

  f, _ := os.Open("filename")

"_" is a throw-away variable to indicate that this value won't be used in 
the code. It's obvious that the programmer decided to ignore the error.

  f, err := os.Open("filename")

If you don't use "err" later, this won't compile.

  f, err := os.Open("filename")
  if err != nil {
    // handle error
  }

This code handles error.

Go ってこんなんあるの。

2011年11月14日

■_

ふと、ソースコードのインデントの起源ってどれ? というのが気になった。

Algol 辺りでは間違いなく採用されている印象があるのだけど、 パンチカードだとインデントつけたコードの入力は厳しい(というかカラムがもったいない?) ですよねえ。 TSS 環境で使ってたるやつか。

いや待て、Lisp は?

■_ 拡張精度

とあるついった上でのやり取り。

Twitter / @kagami_hr: 全然関係ない話だが浮動小数点のこと. 前に gcc ...

全然関係ない話だが浮動小数点のこと. 前に gcc で x=1.3; y=x; の直後に x==y が偽となった。
x は 64bit メモリー内, y は浮動小数点レジスタ 80bit で比較されていた。この流儀のコンパイラ
実装ではソートの比較メソッドが不安定になるのでは(続く

Twitter / @kagami_hr: (続き) 大分前の gcc なので今はどうなのか分か ...

(続き)
大分前の gcc なので今はどうなのか分からない。
だがこのような事態に対処する絶対に安全な比較メソッドの記述方法が分からない。
Twitter / @kagami_hr: 真の不等式 < については保証されていると思 ...

真の不等式 < については保証されていると思っていいのかなあ。
Twitter / @kagami_hr: 浮動小数点で等号は良くないとされているが結果の安定性 ...

浮動小数点で等号は良くないとされているが結果の安定性は保証して欲しいところだ。
Twitter / @tenapi: 比較する前に、なんでもかんでも265バイトくらいの巨 ...

比較する前に、なんでもかんでも265バイトくらいの巨大な浮動小数点表示にキャストしちゃうとか…
RT @kagami_hr: (続き) 大分前の gcc なので今はどうなのか分からない。
だがこのような事態に対処する絶対に安全な比較メソッドの記述方法が分からない。

Twitter / @kagami_hr: @tenapi それで結果の安定性が保証されるか良く ...

@tenapi それで結果の安定性が保証されるか良く分かりません。それから当然計算時間も重要です。
Twitter / @bolero_MURAKAMI: STL のソートの場合デフォルトで operator ...

STL のソートの場合デフォルトで operator< のみが使われるから問題ないのでは。
Twitter / @kagami_hr: @bolero_MURAKAMI でもメモリー上で全 ...

@bolero_MURAKAMI でもメモリー上で全く同じパターンの浮動小数点の片方がレジスタに入ると等しいつもりが < になったりするような気がします。
Twitter / @kagami_hr: いやまあ昔はまった話なので今のコンパイラで等号や不等 ...

いやまあ昔はまった話なので今のコンパイラで等号や不等号の一貫性が保証されているのなら良いのですが。
Twitter / @_w_dee: IEEE floatだと精度拡張時に数値が変わること ...

IEEE floatだと精度拡張時に数値が変わることはありません
RT @kagami_hr: @bolero_MURAKAMI でもメモリー上で全く同じパターンの浮動小数点の片方がレジスタに入ると等しいつもりが < になったりするような気がします。
Twitter / @kagami_hr: @_w_dee 例えば 64 bit の浮動小数点が ...

@_w_dee 例えば 64 bit の浮動小数点が 80 bit に拡張された場合等号が成立するのでしょうか。
Twitter / @tenapi: 実数のイコールは一般には決定不能 (Π_1-完全) ...

実数のイコールは一般には決定不能 (Π_1-完全) なので、不動小数点数で確実に比較するのは難しいでしょうねえ。
Twitter / @kagami_hr: @tenapi あ。蛇足ですみませんが問題にしている ...

@tenapi あ。蛇足ですみませんが問題にしているのは比較が正しいかどうかではなく結果の一貫性です。
Twitter / @tenapi: @kagami_hr とすると、内部表現を一貫させる ...

@kagami_hr とすると、内部表現を一貫させるのが一番、というか、他に方法がないでしょう。
Twitter / @kagami_hr: @tenapi そのようです。昔のコンパイラでは色々 ...

@tenapi そのようです。昔のコンパイラでは色々あったようですが最近のでは大丈夫のようです。
仕事の関係で10年前のコンパイラが必要なのが辛いところです。でも今まで実害がなかったので大丈夫です。たぶん。
Twitter / @nrsyh: @kagami_hr 1.モードレジスタで拡張倍精度 ...

@kagami_hr
1.モードレジスタで拡張倍精度を切ればいい(仮数部の精度が統一される)
2.そもそもSSE使わないのが悪い
3.gccだと最適化オプション付けてれば80bit精度にはならなかったような(うろ覚えだけど…) [lab]
Twitter / @kagami_hr: @nrsyh ありがとうございます。 ...

@nrsyh ありがとうございます。
Twitter / @nrsyh: @kagami_hr あんまり関係ないけど浮動小数点 ...

@kagami_hr あんまり関係ないけど浮動小数点数演算については tinyurl.com/3pfv78h が詳しいです. [lab]
Twitter / @kagami_hr: @nrsyh 大変参考になります。かさねがさねありが ...

@nrsyh 大変参考になります。かさねがさねありがとうございます。
Twitter / @alohakun: @kagami_hr 現在のコンパイラでも全く保証さ ...

@kagami_hr 現在のコンパイラでも全く保証されてません。浮動小数点数は等号で比較できません。
誤差 ε を設定して、不等号で判定するしか無いですね。
[MSDN > VisualStudio 2010 > 浮動小数点数の精度の低下] http://msdn.microsoft.com/ja-JP/library/c151dt3s.aspx
Twitter / @kagami_hr: @alohakun 今回の目的 (ソートの比較関数) ...

@alohakun 今回の目的 (ソートの比較関数) に関して等号の成立条件より、
例えば配列 1000 個の倍精度浮動小数点が (以降変更されず) 存在して
a[i] と a[j] の等号も考慮した不等式に一貫性があれば良いのです (続く
Twitter / @kagami_hr: @alohakun それから比較関数として推移律の成 ...

@alohakun それから比較関数として推移律の成立も必要なので ε 誤差許容は良くないと思います。
Twitter / @kagami_hr: . @alohakun きちんとした規格において同一 ...

. @alohakun きちんとした規格において同一ビットパターンの浮動小数点について常に
同一で推移的な結果を返す実装は可能だと思います。浮動小数点を整列 (「等しい」
と判定した二つの数値の順序は問わない) するには必須だと思います。
正直大小等号の「正しさ」はどうでも良いです。
Twitter / @kagami_hr: いままあ。全然正しくないとそりゃ困りますけど。 ...

いままあ。全然正しくないとそりゃ困りますけど。
Twitter / @unkstar: @kagami_hr @rednaxelafx え? ...

@kagami_hr @rednaxelafx え?i686-apple-darwin11-llvm-gcc-4.2で偽じゃないよ?
Twitter / @kagami_hr: @unkstar 不勉強ですみません。それは規格とし ...

@unkstar 不勉強ですみません。それは規格として保証されているのでしょうか。
Twitter / @kagami_hr: 浮動小数点の (特にソートでの) 比較で一貫性と推移 ...

浮動小数点の (特にソートでの) 比較で一貫性と推移性を保証するためには整数値にハッシュしてその値をキーにするのが良いらしい。

なんか論点が錯綜している感じがするのだけど、最初の x=1.3; y=x; の直後に x==y が偽となった というのはこういうことですよね? → 浮動小数点演算ではまった話 - bkブログ

浮動小数点演算ではまった話 - bkブログ

浮動小数点演算の途中の結果を変数に代入すると結果が変わる というのはなかなか不可解な挙
動です。 レジスタとメモリで共通のサイズ・形式で浮動小数点数を格納するプロセッサ ではこ
のようなことは起きないはずです。

What Every Computer Scientist Should Know About Floating-Point Arithmetic の D.11.1 に
この「変数にいったん入れると結果が変わる問題」に関する解説が載っています。 

先ほどのついったのやり取りでもでてきたものですが(あっちは原文ですけど) この辺りですね

浮動小数点演算について

現在の IEEE 754 実装

(略)

拡張ベースシステムにおける演算動作が単精度 / 倍精度システムにおける動作とどう異なるか
を確認するために、212ページの C による例を考えてみます。

  int main() {
      double  q;

      q = 3.0/7.0;

      if (q == 3.0/7.0) printf("Equal\n");
      else printf("Not Equal\n");

      return 0;

}

この例では、定数 3.0 と 7.0 が倍精度の浮動小数点数として解釈されており、式 3.0/7.0 は、デ
ータ型double を継承します。単精度 / 倍精度システムでは、使用する上で倍精度がもっとも効率
的な形式であるため、この式は倍精度で評価されます。そのため、倍精度に正しく丸められた値
3.0/7.0 が q に代入されます。次の行で、式 3.0/7.0 は再び倍精度で評価されます。その結果は
当然 q に代入したばかりの値と等しいため、プログラムは予測どおり「Equal」と出力します。
(略)

80 bit float number problem

ソートの場合、↑の同じようなことになる計算を比較でしなければいい話のような気がするんですがどうなんでしょ。

■_ lambda がきた

つーても開発版ですが

Java Platform, Standard Edition 8 Developer Preview Releases — Java.net

Java™ Platform, Standard Edition 8 Developer Preview with Lambda Support

This page provides a Developer Preview of OpenJDK with Lambda (JSR 335) support. The 
Lambda project aims to support programming in a multicore environment by adding 
closures and related features to the Java language

For documentations and other details, please see the Lambda project page.

Please note:

The Lambda project has used source files that are not yet available in JDK8; therefore, 
these preview builds are created using the latest OpenJDK 7 source repository. This 
project will merge into OpenJDK 8 when the source files are available.

These bundles are meant to allow developers to try the Lambda features without making 
their own compilations. If you are looking for the latest JDK 8 builds, please 
download from here.

License Agreement:

(以下略)

試している余裕はナッシングw

そして盛り上がる reddit。

Developer build of Java 8 with lambda support now available! : programming

My favorite part:

    *Note: Solaris 64-bit requires users to first install the 32-bit version.

So on Solaris, you really do install twice to get the 64-bit version!


any explanation for this? dependent libraries or what?


Do lamdas act as closures (i.e. see the variables in scope)?


Yes. And they behave the same way as anonymous classes in that you can only close over 
final values.

Where the hell is my helmet? How do you expect me to conduct a radioactive experiment 
if my only protection against radiation is a suit that has my head exposed. I MEAN, I 
DON'T WANT TO GET BRAIN CANCER. Jesus, I should have taken that job at aperture 
science. I doubt they are as incompetent about safety as you guys!!


Or just use Scala...


Scala is so much more than "Lambdas in Java".

■_

■_ アレ

なんか突っ走ってるなあ

[ruby-core:40982] [ruby-trunk - Bug #5625][Open] Remove profanity and pejorative...
[ruby-core:40983] Re: [ruby-trunk - Bug #5625][Open] Remove profanity and pejora...
[ruby-core:40983] Re: [ruby-trunk - Bug #5625][Open] Remove profanity and pejora...
[ruby-core:40987] [ruby-trunk - Bug #5625] Remove profanity and pejoratives
[ruby-core:40987] [ruby-trunk - Bug #5625] Remove profanity and pejoratives
[ruby-core:40987] [ruby-trunk - Bug #5625] Remove profanity and pejoratives
[ruby-core:40987] [ruby-trunk - Bug #5625] Remove profanity and pejoratives
[ruby-core:40996] Re: [ruby-trunk - Bug #5625][Third Party's Issue] Remove profa...
[ruby-core:40997] [ruby-trunk - Bug #5625] Remove profanity and pejoratives
[ruby-core:40999] Re: [ruby-trunk - Bug #5625][Open] Remove profanity and pejora...


Negated regular expressions in Oniguruma and Ruby - The Terminal Programmer
http://snk.tuxfamily.org/log/oniguruma-negated-regexps.html

Comparing ruby:trunk...sunaku:5588_regexp_v for sunaku's ruby - GitHub
https://github.com/sunaku/ruby/compare/5588_regexp_v

いまビルド環境が中途半端な状態なので試せないのだけど

Comparing ruby:trunk...sunaku:5588_regexp_v for sunaku's ruby - GitHub
+ assert_no_match(/a(?v:b)c/, "abc")
+ assert_match(/a(?v:b)c/, "ac")
+ assert_match(/a(?v:b)c/, "axc")
+ assert_match(/a(?v:b)c/, "axbc")
+ assert_match(/a(?v:b)c/, "axbcbc")

/a(?v:b)c/ が "ac" とか "axbc" とか "axbcbc" にマッチするのはやりすぎでしょう。

■_

ああもう、あれとかあれとかあれとかやってる時間がね~~っ

2011年11月13日

■_

・黄色い表紙のニクいヤツら
この週末くらいはまだあるだろうと思ってたらもうなかったーーーっ

「科学の花嫁」、読みたいが値段がちと… 図書館にもなかった○| ̄|_
科学の花嫁 (叢書・ウニベルシタス)
科学の花嫁 (叢書・ウニベルシタス)

■_ TAPL読書会

うあ。ちとまじめにまとめようと思ってたのに時間がががが。

明日こそ…?

■_ PowerShell

xml をごにょごにょしたいのですが、

<Sample>
<Items>
<Item>
    <Name>Orange</Name>
    <Amount>5</Amount>
</Item>
<Item>
    <Name>Apple</Name>
    <Amount>7</Amount>
</Item>
<Item>
    <Name>Strawberry</Name>
    <Amount>4</Amount>
</Item>
<Item>
    <Name>Persimmon</Name>
    <Amount>10</Amount>
</Item>
</Items>
</Sample>

PS C:\Users\xxx\Documents\cococ data> [xml]$xml = get-Content "./sample.xml"
PS C:\Users\xxx\Documents\cococ data> $xml

Sample
------
Sample


PS C:\Users\xxx\Documents\cococ data> $xml.sample

Items
-----
Items


PS C:\Users\xxx\Documents\cococ data> $xml.sample.items
format-default : メンバー "Item" は既に存在します。
    + CategoryInfo          : NotSpecified: (:) [format-default]、ExtendedTypeS
    ystemException
    + FullyQualifiedErrorId : AlreadyPresentPSMemberInfoInternalCollectionAdd,
   Microsoft.PowerShell.Commands.FormatDefaultCommand

PS C:\Users\xxx\Documents\cococ data> $xml.sample.items.item

Name                                    Amount
----                                    ------
Orange                                  5
Apple                                   7
Strawberry                              4
Persimmon                               10


item という名前のエントリがあるとこうなってしまうという。 困った。

■_

昨日の free() - Standard C Memory - C Programming Reference - eLook.org 関連で。

I really enjoy subtle humor in library reference pages : programming

  data *willy;
  willy = (data*) malloc( sizeof(willy) );

They could have at least allocated the correct amount of memory.


It is not necessary, but it doesn't hurt, either.


If you forget to include a prototype for malloc, the cast suppresses a compiler warning
informing you of undefined behavior. So yes, it can hurt.


"undefined behavior"? What compiler does that occur with?

If I use gcc, I get a warning in both cases ("incompatible implicit declaration"),
but not an "undefined behavior" warning.

If I use Visual C, I get two warnings in each case ("'malloc' undefined" in 
both cases, "differs in levels of indirection" for one, "'type cast' : 
conversion from 'int' to 'FOO *' of greater size" for the other), but neither is 
"undefined behavior".


"Undefined behaviour" is a term in the standard, that means that the 
compiler doesn't have to be able to compile the code to anything meaningful. As it 
happens, most compilers do define the behaviour in this case, but it's not required by 
the standard. (On platforms where int and void * are different sizes, such as some 
64-bit platforms, it's possible that you'd only get half the pointer you asked for if 
the compiler wasn't special-casing, though.)

Having the cast makes code more difficult to maintain (later when your void* pointer 
turns into anything else, you would prefer to get an error, rather than have something 
cast into the wrong type (or if the future change means that the type now matches, you 
don't get an error).

(also, it prevents people from accidentally compiling your code with a C++ compiler, 
which is always nice :-)


Each of your disadvantages can be recast as an advantage:

    * if you change the type of your variable, you may like a warning when you forget to
      change the malloc, rather than discovering it after hours or even days of searching 
      for your mysterious memory overrun error.

    * if you work in both C and C++ (I do - I do a lot of embedded work, but am also required
      to work with MFC under Windows), then you may like the code to work unchanged both
      places.

  willy = malloc(sizeof(*willy));

There, problem solved.


Yep, that usually works (beware arrays!).


There is no reason you can't use a C compiler for your C code and a C++ compiler for 
your C++ code (and a C++ linker to pull it all together).


Have you ever tried doing that with Microsoft Visual C/C++?

It's the first thing I tried.

Yes, by default it uses the file extension to decide which language to compile with. 
If you want, you can override it on a per-file basis (this is true in at least 2005, 
2008 and 2010).

I know that MS doesn't seem to like the idea of people using C (there doesn't seem to 
be a way to create a new .c file in a project using the Visual Studio gui), but it 
does work.

C で、malloc の戻り値をキャストすべきか否かで激しい争いがあるとかないとか。

■_

2011年11月12日

■_

Kindle の設定まだやってない。 や、wifi 経由でなにやらやらないといけないのだけど、 そのためのセッティングがががが。 一時期使えるようにしていたのだけど、 とあるアクシデントでルーター入れ替えたときに面倒くさくて設定していない (有線のポートだけ使っている)という。

TAPL 読書会
やった。

■_ In the Real World Memorization is Overrated

「外部記憶」を活用しましょう。的な。

The Codist

 the codist - programmerthink
In the Real World Memorization is Overrated
Published: 11/08/2011

I find it amusing reading stories of programmer interviews where the candidate is expected
to know everything off the of their head. If you repeatly can't answer questions about
programming syntax or parameters and the like but only answer "I usually look it up"
you won't ever get a job.

(略)

The internet has made it possible to learn or "remember" anything. Google 
has become a second brain, allowing you to find explanations and examples of virtually 
anything you need to do.

The real talent lies in being able to find what you need (often you have no clue what 
the right search terms are), evaluate what you find to see if it applies and whether 
it is correct, and then adapt it to your situation. Add in your experience on how to 
build an application and you can do anything.

That's the key to programming today, especially in things you've never done or even seen.

Memorization is for college students taking tests. A skilled programmer knows how to 
acquire knowledge for the problem at hand, apply it successfully and then move on to 
the next. Details live in short-term memory only.

(略)
Copyright © 2007-2011 Andrew Wulf Mail 

「記憶すること」は学生がテストを受けるためのものである。と。

■_ それ factor で

Re: Factor: wc -l

Re: Factor

Thursday, November 10, 2011
wc -l

The wc program is a utility that can count the number of lines in a file. It has a 
number of options that are described on its man page that can change its function to 
count characters or word or produce the length of the longest line.

wc プログラムはファイルの行数を数えられるユーティリティです。
このプログラムはマニュアルページに書かれているように、
キャラクターや単語を数えたり最長ファイルの長さを生成するように
機能を変更できるオプションを数多く持っています。

For the last month, Joe Groff has been improving the performance of Factor's I/O libraries.
Yesterday, we were investigating slow performance when doing lots of small reads from a
file. Joe was able to make a number of nice speedups, which will be in the next release
of Factor.

先月までに Joe Groff は Factor の I/O ライブラリの性能を向上させました。
昨日、わたしたちはひとつのファイルから small reads を数多く行ったときの
slow performance を検査しました。
Joe はいくつかの nice speedups をさせることができ、それは Factor の次のリリースに
反映されるでしょう。

After suggesting that we use wc -l as a benchmark to aspire to, we came up with several
approaches with varying performance. I want to demonstrate these, using timing information
from running it on my computer. Although the Factor image file is binary data, we are going
to count the number of newline characters in it.

    Note: some of these require the latest development version of Factor to run.

Our "gold standard" will be wc -l, which takes just over 0.1 seconds:

    $ time wc -l factor.image
     6149212 factor.image

    real 0m0.111s
    user 0m0.090s
    sys 0m0.020s

Our first attempt in Factor is the shortest amount of code but takes 5.8 seconds (you 
can time this by running "USE: system [ image wc-file-lines ] time"):

最初に試したものは、もっとも短いコードではありますが 5.8秒かかりました。

    : wc-file-lines ( path -- n )
        binary file-lines length ;

We don't really need the lines, just their count, so perhaps just increment each-line 
in a loop. This is an improvement at just over 3 seconds:

実際には行を読む必要はなくて数えるだけでいいので、
ループ中で行ごとに数え上げていけばいいでしょう。
これによって 3秒を超えるくらいには改良されました。

    : wc-each-line ( path -- n )
        binary [ 0 [ drop 1 + ] each-line ] with-file-reader ;

Trying to use read-until to look for the next newline, is a bit slower at 3.4 seconds:
次の改行を見つけるために read-until を使ってみましたが、かえって少し遅くなって
3.4秒かかりました。

    : wc-read-until ( path -- n )
        binary [
            0 [ "\n" read-until [ drop 1 + ] dip ] loop
        ] with-file-reader ;

Instead of reading each line at a time, we can just read 65,536 byte blocks and count 
the number of newlines. This takes about 1.5 seconds:

一度に一行ずつ読むのを止めて、65536バイトのブロックを読んで改行の数を数えるように
できます。これは 1.5秒かかりました。

    : wc-each-block ( path -- n )
        binary [
            0 [ [ CHAR: \n = ] count + ] each-block
        ] with-file-reader ;

Since we are only counting characters in each block, we don't need to allocate and copy
the bytes out of the I/O buffer. Instead, we can look at a slice. This takes about 1 second:

ブロックごとにキャラクタを数えるだけなので、入出力バッファーのための
割り当てやコピーは必要ありません。
代わりに、スライスに注目します。
今回は1秒かかりました。

    : wc-each-block-slice ( path -- n )
        binary [
            0 [ [ CHAR: \n = ] count + ] each-block-slice
        ] with-file-reader ;

The stream functions (such as read) operate on an input-stream dynamic variable, which 
introduces some overhead. If we remove that, the compiler can eliminate some of the 
dynamic dispatches. taking 0.320 seconds:

(read のような) ストリーム関数は input-stream dynamic variable に対して操作しますが
これは多少のオーバーヘッドをもたらします。
もしこのオーバーヘッドを除去すれば、
コンパイラーはダイナミックディスパッチの一部を eliminate できます。
所要時間は 0.320 秒となりました

    : wc-fast ( path -- n )
        binary <file-reader> [
            0 swap [
                [ CHAR: \n = ] count +
            ] each-stream-block-slice
        ] with-destructors ;

If we make an assumption that the number of lines in a file will fit into a fixnum, 
then we can get a bit faster at 0.240 seconds:

もしひとつのファイルに含まれる行の数が fixnum で表現できる範囲に収まると仮定できれば、
多少高速化できて、0.240秒となりました

    : wc-faster ( path -- n )
        binary <file-reader> [
            0 swap [
                [ CHAR: \n = ] count + >fixnum
            ] each-stream-block-slice
        ] with-destructors ;

And, if we cheat and just run the wc -l process directly, we can get to 0.210 seconds:

    : wc-system ( path -- n )
        "wc -l " prepend utf8 [
            readln " " split harvest first string>number
        ] with-process-reader ;

Overall, not too bad! Factor is getting within shouting distance of programs written 
in "faster" languages. Probably with a few more hours, we could close the 
gap, but thats enough for today.


■_

洋書の新刊情報を流してくれる twitter アカウントがありまして、 それでしったのですが食指が動きそうなタイトルがちらほら。 Amazon.co.jp: The Art of Coding: Dustin Boswell, Trevor Foucher: 洋書

どんな本かとみてみれば

Amazon.co.jp: The Art of Coding: Dustin Boswell, Trevor Foucher: 洋書

As programmers, we've all seen source code that's so ugly and buggy it makes our brain 
ache. And let's be honest, we've all written code like that. With this book, you'll 
learn to write code that's easy to read and understand. You'll have more fun and your 
coworkers will love you. The Art of Coding focuses on the nuts and bolts of programming,
with simple and practical techniques you can use every time you sit down to write code.
You'll find tips throughout the book, with easy-to-digest code examples, helpful
illustrations, and cartoons for fun. * Learn to pick variable names that are "dense
with information" * Organize your loops and conditionals so they're easy to
understand * Make your comments short and sweet * Recognize when your code is doing too
many things at once * Write tests that are concise, but thorough * Master the art of
breaking hard problems into many smaller ones 

プログラミングの nuts と bolts にフォーカスと。

オライリーだしこのあたりはすぐに訳されるかなあ。 買うなら電書でいってみようか。 とはいえいっぺん中身を見てからにはしたい。

もういっこ。こっちは結構お高めの本だった。 Amazon.co.jp: Energy-Aware Memory Management for Embedded Multimedia Systems: A Computer-Aided Design Approach (Chapman & Hall/CRC Computer & Information Science Series): Florin Balasa, Dhiraj K. Pradhan: 洋書

Amazon.co.jp: Energy-Aware Memory Management for Embedded Multimedia Systems: A Computer-Aided Design Approach (Chapman & Hall/CRC Computer & Information Science Series): Florin Balasa, Dhiraj K. Pradhan: 洋書

内容説明

Energy-Aware Memory Management for Embedded Multimedia Systems: A Computer-Aided Design
Approach presents recent computer-aided design (CAD) ideas that address memory management
tasks, particularly the optimization of energy consumption in the memory subsystem. It
explains how to efficiently implement CAD solutions, including theoretical methods and
novel algorithms.

The book covers various energy-aware design techniques, including data-dependence analysis
techniques, memory size estimation methods, extensions of mapping approaches, and memory
banking approaches. It shows how these techniques are used to evaluate the data storage of
an application, reduce dynamic and static energy consumption, design energy-efficient
address generation units, and much more.

Providing an algebraic framework for memory management tasks, this book illustrates how
to optimize energy consumption in memory subsystems using CAD solutions. The algorithmic
style of the text should help electronic design automation (EDA) researchers and tool
developers create prototype software tools for system-level exploration, with the goal
to ultimately obtain an optimized architectural solution of the memory subsystem.

自分の興味のある方面とはちと違うような気がする。

■_ もしもプログラミング言語を二つ選ばなければならなければ

Twitter / @OReillyMedia: If I had to pick two langu ...

If I had to pick two languages today, JavaScript and Erlang. JavaScript for
nearly everything, & Erlang for hardened parallel critical. SSL

Erlang は日本で本が出たときにちょっと触った程度だなあ。

■_

【板尾】劇場版電人ザボーガー【古原】 
753 名無しより愛をこめて [sage] 2011/11/10(木) 23:12:07.77 ID:G1Fe0Vts0 Be:
    明日19:30からロフトプラスワンでこんなイベントが

    映画『電人ザボーガー』公開&大ヒット記念・作曲家・福田裕彦トークライブ ~特撮音楽大放談!~
    www.loft-prj.co.jp/PLUSONE/schedule/lpo.cgi 

754 名無しより愛をこめて [sage] 2011/11/11(金) 02:33:58.80 ID:9VrToHfYO Be:
    >>753
    ものすごく行きたいんだが、仕事がなあ…

755 名無しより愛をこめて [sage] 2011/11/11(金) 13:22:49.32 ID:y1OGt1rb0 Be:
    >>753
    地方の人間なんでUSTREAMで中継ないかなあ・・・。 

756 名無しより愛をこめて [sage] 2011/11/11(金) 17:09:24.81 ID:5MrgSyTX0 Be:
    せめて土曜であったら翌日の戦隊魂と抱き合わせで行ったのだが。 

761 名無しより愛をこめて [sage] 2011/11/12(土) 15:33:41.25 ID:gkwAJKk/0 Be:
    >>753
    目茶苦茶面白かった。
    前半は福田さんの特撮ファン&1音楽人生回顧。
    幼稚園の頃に見た「マタンゴ」がものすごくトラウマになったと。これが一番面白かった。
    後半がロボ芸者とザボーガーの音楽話。
    ザボーガーは原BGMと今回用にリメイクしたBGMを続けて音源を流して、
    どうリメイクしたか、変更した箇所はどういう意図で変えたかの解説。
    音楽担当者の詳細なコメントを直接聴く機会なんてそうそうない。
    どうしても時間が押して、全部流しきれなかったのが残念。
    出る予定の無いサントラの発売祈願署名やっていた。
    出ることになったら又イベントやりたいと言っていたので、出来るといいなあ。 

765 名無しより愛をこめて [sage] 2011/11/13(日) 00:46:27.98 ID:8n/ZmOKSO Be:
    >>761
    報告乙です
    仕事ほっぽっても行くべきだったなw


署名ってほかでも受け付けているのかな。 ロフトプラスワンに入る人数だけでは少ないような。 ってどこなに渡すための署名ではない?

■_

■_ おや

なにかおかしい

free() - Standard C Memory - C Programming Reference - eLook.org

Currently At: Programming Reference > C Reference > Standard C Memory > free()

free()

Syntax:

 #include <stdlib.h>

Description:

The free() function deallocates the space pointed to by ptr, freeing it up for future use.
ptr must have been used in a previous call to |malloc()|, |calloc()|, or |realloc()|.

Example:

  typedef struct data_type {
    int age;
    char name[20];
  } data;

  data *willy;
  willy = (data*) malloc( sizeof(willy) );
  ...
  free( willy );

イメージで貼り付けたほうがよかったかな。

■_

Tim O'Reilly - Google+ - Does anyone else find that each successive release of Mac…

2011年11月11日

■_

通勤ラッシュ時に、 電車を降りるの降りないので喧嘩になって遅延させたりとか ライターでコートに火をつけるとか物騒すなあ。

■_ v

例の、(rubyでの)正規表現のマッチングで v (iinvert) フラグを追加してくれといっていた御仁。 パッチを書くというのは偉いと思うんだけど、 その修正方法はちと危ういのではなかろうか。

ruby-trunk - Feature #5588: add negation flag (v) to Regexp - Ruby Issue Tracking System

[ruby-core:40878]#8
Akira Tanaka が3日前に更新
2011/11/9 Suraj Kurapati <sunaku@gmail.com>: > * We can pass '(?v:)' in embedded
regexp but it does not take effect. > The resulting regexp object's #options field does
not reflect 'v'. The option can be embedded to middle of a regexp: /foo(?v:bar)baz/ I think
it doesn't work. -- Tanaka Akira

(さくっと略)

[ruby-core:40930]#12
Suraj Kurapati が約15時間前に更新
I did it! ^_^ Please take a look: https://github.com/sunaku/ruby/compare/5588_regexp_v 
There are a few issues remaining with the implementation: * Store snegate on STACK 
support nested embedded negated regexps. * Find a better way to double-pop the stack 
in OP_NEGATE_END handler in regexec.c; currently it puts undefined values into s, p, 
etc. when the stack is popped for the second time in "goto fail" handler. 
After that, I need to make Ruby parser accept /.../v as a literal regexp flag. Thanks 
for your consideration.

[ruby-core:40932]#13
Suraj Kurapati が約15時間前に更新
Allow me to explain the current embedded negated regexp implementation. When parsing 
an embedded negated regexp (?v:r), we expand them into this: 
OP_NEGATE_START(?:r)?OP_NEGATE_END.*? Here, OP_NEGATE_START and OP_NEGATE_END are 
opcodes in compiled pattern. When the regexp engine (see match_at() in regexec.c) 
reaches OP_NEGATE_START, we store the current state of input (up to which character of 
the input string have we consumed/matched so far?) in the "snegate" variable. 
The regexp engine then continues onward and eventually reaches OP_NEGATE_END. At this 
point, I compare the current state of input with "snegate". This tells us if 
the original embedded negated regexp (?v:r) has matched anything. Now we perform the 
negation: If (?v:r) matched something, then treat this as a mismatch (prevent 
backtrack and goto fail). Otherwise, continue processing (the ".*?" after 
OP_NEGATE_END will take care of consuming any non-matching characters so that we can 
still proceed). assert_no_match(/a(?v:b)c/, "abc") assert_match(/a(?v:b)c/, 
"axc") assert_match(/a(?v:b)c/, "ac") assert_match(/a(?v:b)c/, 
"axbc") I hope this helps you understand my approach. Please correct me if I 
made a mistake. Thanks for your consideration.

でいくつか変更箇所を見た (前回のコミットとの差分じゃなくて、いくつか前のものとの差分って見られないかしらん)。

Comparing ruby:trunk...sunaku:5588_regexp_v for sunaku's ruby - GitHub

Showing 12 commits by 1 author.

98cb7b90 	sunaku 	http://redmine.ruby-lang.org/issues/5588
7892a27c 	sunaku 	begin (?v:...) negate opcodes
3e68c7f9 	sunaku 	enable IS_DYNAMIC_OPTION for NEGATE flag passing
8ba3de34 	sunaku 	Revert "begin (?v:...) negate opcodes"
dcb09415 	sunaku 	wrap enclose body inside prec_read anchor (?=)
1d98389c 	sunaku 	expand (?v:r) into (?:rN)? and propagate OP_NEGATE
a384e71d 	sunaku 	emit 2 negate delimiters; need to consume .*? before continuing
b1614d57 	sunaku 	impl consuming of excess in passed (?v:...) case
d1098ef4 	sunaku 	remove debugging printfs
5240618b 	sunaku 	fix whitespace TAB expansion
9e03999e 	sunaku 	add test case for embedded regexp matching
31678acb 	sunaku 	delete more debugging prints

彼(だよね?)は v の対象が固定文字列、それも短いものしか想定していないっぽいけど 対象のチェックをせずに expand (?v:r) into (?:rN)? and propagate OP_NEGATE を やっている感じなので(読んでないところでやってたらごめんなさい)、 ここに意地悪な正規表現放り込んだりするとおかしなこと(たとえばパフォーマンスバグのような) になるんじゃなかろうか。

v を伴った部分正規表現の入れ子もチェックしてないから、こっちでも意地悪できそう。

■_ lambda

Java 8 の。 reddit で話題に。

Java 8 Lambda Expressions and Virtual Extension Methods : programming

Java 8 Lambda Expressions and Virtual Extension Methods (openjdk.java.net)


Only have to wait till 2013.


Hey, the next version of Java will be almost at the level C# was in 2008.


Legacy is a chain that can hold you back more and more as the years go by. The alternative
is a clean break like Python 3 did. Personally I think their best bet is to continue focus
on the JVM and bring up a fresh new language on top of that.

© 2011 reddit inc. All rights reserved.

Legacy is a chain。なるほど。

JEP 126: Lambda Expressions and Virtual Extension Methods

JEP 126: Lambda Expressions and Virtual Extension Methods
Author	Joseph D. Darcy
Organization	Oracle
Owner	Brian Goetz
Created	2011/11/1
Updated	2011/11/7
Type	Feature
State	Posted
Component	--/--
Scope	SE
JSR	335
Discussion	lambda dash dev at openjdk dot java dot net
Start	2011/Q4
Blocks	107, 109
Effort	XL
Duration	XL
Reviewed-by	Brian Goetz
Endorsed-by	Brian Goetz

Summary

Add lambda expressions (closures) and supporting features, including method references, 
enhanced type inference, and virtual extension methods, to the Java programming language
and platform.

ラムダ式 (クロージャ) と、メソッド参照や拡張型推論、仮想拡張メソッドを含むサポート機能の
プログラミング言語 Java とプラットフォームに対する追加。

Goals
目標

The primary features of lambda expressions and virtual extension methods, along with their
set of secondary supporting features, further several platform goals:

    * Simplifying the creation and consumption of more abstract, higher-performance libraries
      より抽象的で高性能なライブラリの creation と consumption の単純化

    * Supporting smoother library evolution with migration compatibility
      migration compatiblity (移行互換性?) を伴ったよりスムースなライブラリの進化のサポート

Besides adding a now-common feature to the Java programming language, lambda expressions
open up possibilities for improved multicore support by enabling internal iteration idioms.

The supporting language features around lambda include virtual extension methods, which
will allow interfaces to be evolved in a source and binary compatible fashion.

In addition to language changes, coordinated libraries and JVM changes will occur as well.

Note that the active and ongoing Project Lambda OpenJDK project pre-dates the JEP process,
as does the corresponding JSR, JSR 335, which is targeted for Java SE 8 (JSR 336).

Non-Goals

The language features of function types and general control abstraction are not goals 
of adding lambda expressions to Java. However, the intention is to not preclude the 
addition of such features in the future.

© 2011 Oracle Corporation and/or its affiliates
Terms of Use · Privacy · Trademarks

■_

■_

The Balanced Developer | Viget Extend

The Balanced Developer

In preparation for a recent team offsite, I spent some time thinking about what I hold 
dear as a software developer. One idea I kept coming back to is the notion of balance. 
I see balance manifesting itself several ways in the work of a successful developer, 
some of which follow.


■_

きんどるさんのセットアップまだやってねー


一つ前へ 2011年11月(上旬)
一つ後へ 2011年11月(下旬)

ホームへ


リンクはご自由にどうぞ

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