■_
いいネタが思いつかない
一つ前へ
2011年6月(上旬)
一つ後へ
2011年6月(下旬)
いいネタが思いつかない
まだまだ知らないものがたくさんあるなあ
June 19 2011: Reading files :: Strangely Consistent June 19 2011: Reading files Tomorrow we'll be writing a game. (略) If split looks through a string for the things it wants to throw away, its cousin comb sifts through a string for the things it wants to keep: #えーと、split は対象となる文字列中の切り取りたい部分に注目するのに対し、 #その親戚である comb は文字列中の残したい部分に注目する ってかんじ? say join " ", "abc123def456".split(/\d+/); # "abc def" say join " ", "abc123def456".comb(/\d+/); # "123 456" A very useful special case of comb is when you want all the individual characters of a string: comb が非常に有用である special case は文字列の個々のキャラクターすべてを必要とする 場合である: say join " ", "Hello World".comb(); # "H e l l o W o r l d" Hang around for tomorrow's game. Because we're reading from file, the actual game is nice and short.
C Programming - Advanced Test : programming でだいぶ盛り上がってるんですが、結構昔のページなんですよねえ。 なんか見覚えがあるような気も。
Advanced Test in C Advanced Test in C: The 0x10 Best Questions for C Programmers This test was written by Ashok K. Pathak, a researcher at Bharat Electronics Limited (CRL), Ghaziabad. Ashok has an M.E. from Motilal Nehru Reginal Engineering College, Allahabad, and is the author of a book titled “Advanced Test in C and Embedded System Programming”. This test appeared as an article on programmersheaven.com. It is reproduced here with modifications, which are as follows: * Javascript-based scoring and answer display functionality was added. Javascript を使った採点と解答の表示機能が追加されました。 * Minor errors in questions 3, 13, and 14 are corrected. 設問3、13、14 にあった細かなエラーは修正済みです。 * All necessary headers are introduced with #include. 必要なヘッダーはすべて #include で指定してあります、 * Declarations of main are C99 compliant. main の宣言は C99 準拠になりました。 * Data type sizes are supplied only where necessary (questions 9 and 14). データ型の大きさは必要とされる大きさのみ提供されます(設問9と14)。 * Questions 9, 10, and 12 have more convincing wrong choices. * Code spacing and indentation are more consistent. コードの spacing とインデントをより一貫性のあるものにしました。 * Spacing of printf output has been corrected in a few places. * All code is syntax highlighted (TextPad-style). * Minor stylistic adjustments were made. * Answers are re-worded for clarity, accuracy, and completeness. If you find any mistakes, please let me know: もしなにか間違いを見つけたら、どうぞお知らせください: — Steve Kobes, 8/25/04 Jump to question: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1. Consider the following program: #include <stdio.h> #include <setjmp.h> static jmp_buf buf; int main(void) { volatile int b = 3; if (setjmp(buf) != 0) { printf("%d\n", b); exit(0); } b = 5; longjmp(buf, 1); } What is the output of this program? このプログラムの出力はどうなるでしょうか? (a) 3 (b) 5 (c) 0 (d) none of the above Show answer
てなかんじの問題がたくさん。
歴史的事情?
整数定数の先頭に0をつけると8進数として扱われる……という仕様は使っていますか? - Yahoo!知恵袋 整数定数の先頭に0をつけると8進数として扱われる……という仕様は使っていますか? コンパイラ言語では先頭に0をつけなければいい話ですが、スクリプト言語だと文字列を数値化 するときにわざわざ先頭の0を削除する必要があるので、8進数扱いする仕様は邪魔に感じます。 どうしても必要なら、16進数なら0xをつけるのに合わせて、8進数は0じゃなくて0o(octetのo) とかにすればいいのにと思います。BASHスクリプトで使った場合の失敗談です。逆に10進数のつもりで使って、0900がエラーになって、「なんじゃこのエラーは」ということになりました。 >8進数は0じゃなくて0o(octetのo)とかにすればいいのにと思います。 激しく同意します。 (細かくいうと間違えないよう0tがいいかもしれませんが。)Copyright (C) 2011 Yahoo Japan Corporation. All Rights Reserved.
つ Python
というのはさておくとしても、どうなんですかねえ。
うっかり「デスクトップ」にしてしまうと、机の上で使うパソコンになってしまい、目的別に円卓上に複数のパソコンを揃え、 TPOに併せてモニターとキーボード/マウスをつなぎ替えて使うという、わが家のようなディスクトップパソコンとは違うものになってしまうので、困っています。
Rubular is a Ruby-based regular expression editor. It's a handy way to test regular expressions as you write them.
今はもう履歴管理システムにべったり頼ることに抵抗は無いのですが、それでも一抹の不安があります。ソースコードのtarballと、リポジトリと、どちらが長く生き残るかということです。
だがしかし、だ。性能比較で見たとおり物量で勝っているので次回は抜かれる恐れがある。そしてIBMのPOWER7 Blue_Watersの存在だ。今回も登録されていない。IBMは隠し球を持っている。
この記号は、右方向のみらしく、左向きがありません。
Like French generals building the Maginot line after WWI, Microsoft keeps fighting the last war over again. And like the French, the company will get slaughtered if it doesn’t break its self-reinforcing positive feedback loop and start realizing how the world has changed.
まず手をつけるなら最も低いレイヤーのユニットテスト
特許にしろ国際標準にしろ、それ単体だけで考えていたのではいけないのだろうと私は思います。 自社製品を広めていく大きな戦略の中の手駒として、特許をどう使うか、標準化をどう使うか、を決めていかなければならない。
ちゃっちゃとまとめたり訳したりする能力がほしい今日この頃。
Rants, Raves and Ridicule: A Generic Quicksort in Scala A Generic Quicksort in Scala So, I decided to create a quicksort algorithm in Scala that showcases how to write 'generic' collection methods. That is, how can we write an external method that works across many types of collections *and* preserves the final type. Well, here's how you do it:
Shed Skin - A (restricted) Python-to-C++ Compiler: Shed Skin 0.8, Programming Language Benchmark I'm happy to announce the release of Shed Skin 0.8, a (restricted-)Python-to-C++ compiler. It must be one of the best releases so far, with help and feedback from many directions.Pen and paper While tinkering with the Rubinius VM, I found it useful to have pen and paper around whenever I was coding. Given a set of VM instructions, I'd go instruction after instruction, drawing what the stack should look like at each step. I'd freak out at net stack underflow errors, try to follow along the instructions that were being executed, keeping track of the stack size and spotting that extra (or missing) pop. As a last resort, I'd also go crying in the #rubinius IRC channel on Freenode :)
Technical Discovery: Python Enhancement Proposals I Wish I Had Time to Champion Python Enhancements I Want ・Adding additional operators ・Overloadable Boolean Operations ・Allowing slice object literals outside of []
別に何が変わったということもなく。
正規表現 Part8 192 デフォルトの名無しさん [sage] 2011/06/18(土) 19:08:41.62 ID: Be: https://github.com/k-takata/Onigmo Onigmo is a regular expressions library forked from Oniguruma. だそうだ。perlの名前参照とか\R,\Kなどが使えるようになってるっぽい。
というのを見かけて、リンク先へ。
k-takata/Onigmo - GitHub README README 2011/06/11 Onigmo (Oniguruma-mod) -- (C) K.Takata <kentkt AT csc DOT jp> https://github.com/k-takata/Onigmo Onigmo is a regular expressions library forked from Oniguruma. Some of new features introduced in Perl 5.10+ can be used. Some patches are merged from Ruby 1.9.2. Oniguruma's README follows: (略)
Onigmo というのは O N I G のあとに何か続く名前ということで決めたのだろうか?
Oniguruma-mod
… でもないかな?
Perl 6 で一番好きな機能を挙げろといわれたらこれかなあ(Rulesも捨てがたいけど)。
June 18 2011: Junctions :: Strangely Consistent June 18 2011: Junctions We've seen junctions a bit already. They showed up as a sidekick to the slightly longer logical operators: if $answer == 1 || $answer == 3 { ... } if $answer == 1 | 3 { ... } # same thing There's a third way to write it too, and that's by using a function form: if $answer == any(1, 3) { ... } (略) Just to have this said: it's common for people to look at junctions, think they're really cool, and then expect them to do the following: ジャンクションを見た人はたいていそれが cool な機能であると考えて、さらに次のような こともできると期待してしまいます: if any(@contestants).won { # do something with the winner } But we can't. Junctions answer questions like "does any of these..." or "do all of these..."; they don't pick out the things that match or fail to match and hand them back to you. Their purpose is to treat several things as a unit. If you find you wanted to tease out values of that unit, what you wanted was probably something more like this: しかしこれはできません。ジャンクションは "does any of these..." や "do all of these..." のような 質問に対しては答えますが、実際にマッチしたものやマッチに失敗したものを取り出したりは しないのです。ジャンクションの目的はいくつかのことがらをひとつの unit のように扱う ことです。もし、条件にかなった unit の値を tease out したいのであれば、あなたが 本当にやりたかったのはおそらく次のようなことでしょう: my $winner = @contestants.first({ .won }); if $winner { # do something with $winner } And with that, we're all set. See you tomorrow with more blogging.
結構知らない(覚えていない)実装があるなあ。
Implementations / Perl 6 Implementations There is no official or reference Perl 6 implementation, as exists with Perl 5. Instead, there is a language specification that began with Apocalypses and evolved through Exegeses and Synopses. (略) This page is about the various partial implementations that exist, which can parse and execute Perl 6. Virtual machines and runloops are excluded because they do not deal with Perl 6 source code. Perl 5 にはあった、公式なあるいは参照実装としての Perl 6 の実装というものはありません。 その代わり、Apocalypses に始まり、Exegeses や Synopses と続いた言語仕様があります。 (略) このページでは現状で Perl 6 の構文解析や実行ができる various partial implementation について説明します。仮想マシンや runloops は Perl 6 で書かれたソースコードを 扱うものではないので除外しています。 * Rakudo is currently the most feature-rich and most actively developed implementation. It runs on Parrot, a virtual machine for many dynamic languages. * Niecza is currently the fastest implementation, the active development is lead by Stefan O'Rear. * Pugs was the leading implementation from 2005 until about 2007. It runs on GHC Haskell and helped to develop the test suite. * viv is a derivation of STD.pm for testing and bootstrapping purposes. A utility called "gimme5" creates viv by translating STD.pm into Perl 5. This is possible because Larry very carefully wrote STD.pm in a translatable subset of Perl 6. * Mildew is a Perl 5 based compiler that embeds viv, and can emit code for several runtime engines, including JavaScript and SMOP. * Sprixel started out with viv as the source code parser and Google's V8 JavaScript engine as a runtime interpreter. Currently Sprixel is undergoing a complete rewrite. The new version is being in C# and will probably run on both Mono and the .NET Framework. It will include its own regex engine and Perl 6 grammar parser. * Elf is a compiler written in Perl 6 with Perl 5 and Lisp backends. * vill connects STD.pm to the LLVM (Low Level Virtual Machine) compiler tools. * Perlito, formerly known as MP6 (mini Perl 6), is a Perl 6 subset build by Flavio Glock for bootstrap purposes. * KindaPerl6 (kp6) * v6 is a Perl 6 compiler for Perl 5. Historical Implementations are definitely closed projects.
ついでなのでヒストリカルなほうも。
Historical Implementations / Perl 6 Historical Implementations Topaz Topaz was Chip Salzenberg's attempt to reimplement Perl 5 in C++ in the late 1990s. Topaz was abandoned after the Coffee Mug Incident. Sapphire Simon Cozens tested around 2000 how to reimplement Perl. Ponie (Perl (5) On New Interpreter Engine) had aimed to implement the Perl 5 language on Parrot. It was developed 2003-2006 by Arthur Bergman and Nicholas Clark. Ponie had the potential to integrate Perl 6 and Perl 5 code in the same process. That would have been useful for language bootstrap purposes, and also to make lots of the Perl 5 based CPAN libraries available to Perl 6 users. Some thought at one point even it might become Perl 5.10.. It was discontinued because emulating all of the idiosyncracies of Perl 5 was daunting, and the developers were presumably daunted.
Topaz と Ponie は記憶にあった。Ponie は書かれているように Perl 5 を実装するものだけど。
操作性を Unify(統一)した、Windows Ubuntu 両方のOSで動く必須ツールを開発しています。
As an example I will take 18 revisions (from CVS) from a small GIMP# plug-in and show what I did to gradually reduce the size.
A間さんの本は二度と買わないと思ってましたが、またつつきたくなるような話が (んな時間的金銭的余裕があるかというと…)。
なべてこのよはこともなし
他人様のblog の、それもコメントをきっかけに書くのもどうかなあとか思って 自重してみたり。
例によって reddit 経由で。 Advice from an old programmer : programming
Advice From An Old Programmer — Learn Python The Hard Way, 2nd Edition Advice From An Old Programmer¶ You have finished this book and have decided to continue with programming. Maybe it will be a career for you, or maybe it will be a hobby. You will need some advice to make sure you continue on the right path, and get the most enjoyment out of your newly chosen hobby. (さくっと略) To this I have one just piece of advice: they can go to hell. The world needs more weird people who know how things work and who love to figure it all out. When they treat you like this, just remember that this is your journey, not theirs. Being different is not a crime, and people who tell you it is are just jealous that you have picked up a skill they never in their wildest dreams could acquire. You can code. They cannot. That is pretty damn cool. © Copyright 2010, Zed A. Shaw. Last updated on Jun 17, 2011. Created using Sphinx 1.0.7.
あ、Zed。でも Copyright 2010 と思ったら
Advice from an old programmer : programming This is an inspiring post. I blogged on this about an year ago, surprisingly with the same title :D http://blog.abhiomkar.in/2010/06/19/advice-from-an-old-programmer/
ということらしく。
正規表現の文字クラスの実装方針がいろいろ揺れてるみたいです (locale にどう対応するかとか)。
[bug-gawk] Final gawk 4.0 beta test tar ball now available From: Aharon Robbins Subject:[bug-gawk] Final gawk 4.0 beta test tar ball now available Date: Fri, 17 Jun 2011 11:16:38 +0300 Hi All. http://www.skeeve.com/gawk/gawk-3.1.86.tar.gz The primary change here is the implementation of Rational Range Interpretation and documentation thereof. Please try this out. I would like to make the real release next week sometime. AS ALWAYS: *P*L*E*A*S*E* report bugs to `bug-gawk AT gnu.org'; it's ok to post here too, but at least CC the bug address so that I see the mail. Thanks, Arnold
ぼちぼちいじるか。
いま神さん(65歳)は、パソコン教室に通って懸命に勉強中です。
正規表現 Part8 180 デフォルトの名無しさん [] 2011/06/17(金) 01:19:28.83 ID: Be: 巨大なファイルとか、一度に全部変数に読み込みたくない場合 正規表現に途中までマッチしたとか、もうちょっと食わせれば完全に マッチするとか知ることできれば便利だと思うのですがそのような方法はありますでしょうか? 181 デフォルトの名無しさん [sage] 2011/06/17(金) 05:08:04.43 ID: Be: > もうちょっと食わせれば完全にマッチする エスパーな小人をパソコンにいれるとか。 182 デフォルトの名無しさん [sage] 2011/06/17(金) 07:06:16.71 ID: Be: java.util.regex.MatcherのhitEnd(), requireEnd()とか、PCREのpartial matchingとか?
お、PCREにそんな機能あったんだ。 一時期 GNU sed で使われた Rx ってライブラリにもあったけど ライブラリ自体がほっぽり出されたからなあ。
ネタ探しをしないとですね。
先読みのところを調べてたら気がついた
void ExternalDeclaration() : {} { ( LOOKAHEAD( FunctionDefinition() ) FunctionDefinition() | Declaration()) } void FunctionDefinition() : {} { [LOOKAHEAD(DeclarationSpecifiers()) DeclarationSpecifiers()] Declarator() [ DeclarationList() ] CompoundStatement() }
LOOKAHEAD の引数(?)って、関数の戻り値みたいんで指定できるのね。 あれ、でも↑ だと void だ。
D はよくわからん。
Implementing Pure Functions | Dr Dobb's Journal A while back, I wrote an article explaining how the D programming language's "pure" annotation could be applied to functions. A pure function does what you'd expect — the compiler enforces purity of the function. The function may not have any side effects, may not rely on any mutable data, and is statically checkable.
というのがあって。
import std.stdio; pure int square(int x) { writefln("square(%d)", x); return x * x; }
これは writeln が「不純」なので square も「純粋」にはなれず
import std.stdio; int square_debug(int x) { writefln("square(%d)", x); return x * x; } pure alias int function(int) fp_t; pure int square(int x) { auto fp = cast(fp_t)&square_debug; return (*fp)(x); }
裏技を使ってこうできる。が、
import std.stdio; pure int square(int x) { debug writefln("square(%d)", x); return x * x; }
debug などというものを持ち出してきて「解決」…でいいのかな?
詳しいことは元記事の本文をどぞ:)
#3 まだ終わってねえ
意図的に日本語にしていない部分があります(しっくりする表現が思いつかなかったとか)。 そゆことで。
mikeash.com: Friday Q&A 2011-06-03: Objective-C Blocks vs. C++0x Lambdas: Fight! Friday Q&A 2011-06-03: Objective-C Blocks vs. C++0x Lambdas: Fight! Blocks are perhaps the most significant new language feature introduced by Apple in years, and I've written a lot about them before. The new C++ standard, C++0x, introduces lambdas, a similar feature. Today, I want to discuss the two features and how they are alike and how they differ, a topic suggested by David Dunham. ブロックはおそらく、ここ数年のうちに Appleによって導入された最も significant な新しい言語 機能です。これについては以前に多くのことを書いています。C++ の新標準 C++0x では類似の機能 である lambad を導入しました。今日は、これら二つの機能であるとかどれだけ似たものであるのか あるいはどれだけかけ離れたものであるのかについて論じます。 トピックは David Dunham が提案したものです。 Terminology 用語 I will refer to Apple's blocks extension as "Objective-C blocks" even though this is not entirely correct. They are actually an addition to C (and can even be used in C++), with some extra behaviors to make them more useful in Objective-C. However, they are deeply intertwined with Objective-C in their implementation, and "C blocks" is vague, so I think that "Objective-C blocks" is the best way to refer to them here. 正確ではない部分もありますが、ここでは Apple のブロック拡張を“Objective-C のブロック”と見な します。実際にはこれは Objective-C において自身を一層有用にさせるちょっとした追加機能 (some extra behaviors) を持っている C に対する (C++でも使用可能な) 追加です。 しかし、その実装においてブロックは Objective-C と深く結びついているので、 “C のブロック”というのは vague (あいまい、ぼんやりとした) です。 ですからわたしは、ここでは "Objective-C のブロック" とするのがブロックを表す 最善のやり方であろうと考えたのです。 C++0x lambdas are part of C++ only and can't be used from C. Presumably they can be used in Objective-C++ if the compiler supports C++0x. C++0x の lambda は C++ のみの一部であり、C から使うことはできません。 Presumably they can be used in Objective-C++ if the compiler supports C++0x. For a generic term to refer to both Objective-C blocks and C++0x lambdas, I will use "anonymous function". Objective-C のブロックとC++0xのlambda を指す一般的な用語として、 “無名関数”("anonymous function") を使うことにします。 Syntax 構文 Both Objective-C blocks and C++0x lambdas have the same basic goal: to allow writing anonymous inline functions. Called closures, blocks, lambdas, or just anonymous functions, these are a common feature in higher level languages. They are extremely useful for building convenient, succint libraries for things like array iteration, multithreading, delayed computation, and many others. Objective-C のブロック、C++0xのlambdaの両方とも同一の basic goal を持っています: 無名のインライン関数 (anonymous inline functions)を書くことを可能にする クロージャ、ブロック、ラムダ、あるいは単に無名関数と呼ばれるそれは、 より高水準の言語 (higher level languages) においては一般的な機能です。 As lower level languages, C and C++ had no concept of anonymous functions. To add them, new syntax had to be created. Because of this, Objective-C blocks and C++0x lambdas ended up with somewhat different syntax. An empty Objective-C block looks like this: 比較的低水準の言語である C や C++ は無名関数というコンセプトを持っていませんでした。 この無名関数を追加するためには新しい構文を作り出さねばなりませんでした。 このために、Objective-C のブロックと C++0x の lambda は異なる構文となってしまいました。 空の Objective-C ブロックは次のような外見です: ^{} Whereas an empty C++0x lambda looks like this: []{} So far not much different. They both use the standard C {} symbols to separate a block of code, with a special symbol to indicate that this is a block or lambda, not a normal C block. In both cases, the {} section takes normal code. それほど違いはありません。両者ともコードのブロックを分けるために標準の C の {} シンボ ルを使っていて、さらに通常のブロックではなくブロックや lambda であることを示す特殊なシ ンボルを伴っています。そしてどちらの場合も {} セクションは通常のコードを取ります。 The anonymous function can take arguments by writing them in parentheses, in the style of function arguments, after the leading bit: leading bit の後に関数形式でカッコの中に引数を書くことにより無名関数は引数を取れます: ^(int x, NSString *y){} // ObjC, take int and NSString* [](int x, std::string y){} // C++, take int and std::string In both languages, a value can be returned, and the return type can be inferred from the return statement: どちらの言語でも一つの値を返すことが可能で、さらに その戻り値の型は return 文から推測可能です: ^{ return 42; } // ObjC, returns int []{ return 42; } // C++, returns int Here, the two features begin to diverge. With C++0x lambdas, the return type can only be inferred if the lambda contains a single statement, and that statement is a return statement. So while the above is valid, this is not: ここから二つの機能の diverge が始まります。 C++0x の lambda ではそれがただ一つの文からなっているときにのみ 戻り値の型の推測が可能で、さらにその文は return 文でなければなりません。 ですから、上の例は vaild なものですが、次の例は違います: []{ if(something) return 42; else return 43; } In a more complicated lambda with an inferred return type, the return type is always inferred to be void. The code above will therefore produce an error, because it's invalid to return 42 from something with a return type of void. inferred return type を持ったもっと複雑な lambda ではその戻り値の型は常に void である と推測されます。戻り値の型が void であるなにかが 42 を返すことは invalid なので上記の 例ではエラーが発生します。 In contrast, Objective-C blocks do return type inference no matter how complicated the code is inside of the block. If no return statements are present, the type is inferred as void. Otherwise, it examines all of the return statements in the block. If they all return the same type, then the return type of the block is inferred to be that same type. If they conflict, an error is generated. Thus, the equivalent Objective-C example to the invalid C++0x lambda example works fine: 対照的に、Objective-C のブロックはその内部にあるコードがどれほど複雑であるかは関係なく 戻り値型の推測を行います。もし return 文がブロックになければ、そのブロックの型は void であると推測されます。そうでなければ、ブロックの中にあるすべてのreturn文を検査します。 すべてのreturn文が同一の型を返していれば、ブロックの戻り値の型はその型と同じものである と推測されます。衝突があった場合にはエラーが発生します。したがって、先の C++0x lambda の invalid な例と等価な Objective-C での例は正しく動作します: ^{ if(something) return 42; else return 43; } Both features also allow the explicit declaration of a return type. This is essential with C++0x lambdas, where it's the only way to have a complicated lambda return a value. It's merely a convenience in Objective-C, but often useful to avoid having to cast in return statements. どちらの機能も戻り値の型の explicit な宣言が可能です。これは C++0x lambda の essential で、ある値を返す複雑な lambda を持つための唯一の方法です。これは Objective-C では単に covenience にすぎませんが、return 文の cast を取り除くのにしばしば有用です。 With Objective-C blocks, the return type is declared immediately after the ^. In C++0x, the return type is declared by placing ->type after the lambda's argument list. Here are those two examples with explicit return types, which allows it to work in both languages: Objective-C のブロックでは戻り値の型は ^ の直後で宣言されます。 C++0x では lambda の引数リストの直後に -> を置くことで戻り値の型が宣言されます。 ここで、それぞれの言語で動作する explicit な return typeを持った 二つの例を挙げます: []()->int { if(something) return 42; else return 43; } ^int { if(something) return 42; else return 43; } Note that an arguments declaration is required for C++0x lambdas, although it can be empty, if an explicit return type is declared. Objective-C blocks can declare either a return type or an argument list separately, or have both together. For completeness, here is the same example with an argument list: 戻り値の型を explicit に宣言している場合には、引数がなかったとしても引数宣言が必須であること に注意してください。Objective-C のブロックでは戻り値の型や引数リストを分割してもまとめても宣 言できます。 For completeness, 引数リストを持った例を挙げます: ^int (void) { if(something) return 42; else return 43; } Finally, both Objective-C blocks and C++0x lambdas are called in the same way: use the standard () operator on an expression of the appropriate type. Pass arguments if they are required. This calls the anonymous function. Finally, Objective-C のブロックと C++0x の lambda はどちらも same way で呼び出されます: 適切な型の式に対して標準の () 演算子を使います。 要求されていれば引数を渡します。 これは無名関数を呼び出します。 Type 型 Objective-C blocks introduce a new class of language-level types to represent block types. They match the standard (but tricky) syntax for C function pointer types, but with a ^ in place of the *: Objective-C のブロックではブロック型を表現するために言語レベルの型として新しいクラスを導入しました。 それは (トリッキーではあるものの) C の関数ポインター型を表す標準の構文とマッチするものですが、 * が ^ で置き換っています: void (*)(int) // function pointer taking int and returning void void (^)(int) // block taking int and returning void These types can be used for function/method parameters, return types, local variables, instance variables, etc. これらの型は、関数やメソッドのパラメーター、戻り値の型、ローカル変数、 インスタンス変数等々で使用できます。 C++0x takes a completely different approach. Lambdas have a unique anonymous type which implements operator(). In other words, you can call it, but otherwise you don't have an accessible type the way Objective-C blocks do. In order to store them in variables, pass them to functions, or return them from functions, C++ templates or the C++0x auto keyword (which infers the type of a variable from the type of its initializer) must be used. C++0x は全く異なるアプローチを採用しました。 lambda は operator() を実装している unique な無名型を持ちます。 言い換えると、呼び出すことは可能なのですがそれ以外では、 Objective-C のブロックのような accessible type をあなたは持っていません。 lambda を変数に格納したり、関数に渡したり、あるいは関数から返すためには C++ のテンプレートもしくは C++0x の予約語 auto (変数の型をその initializer の型から推測します) を使わなければなりません。 Captured Variables 捕獲変数 One of the most significant features of these anonymous functions is the ability to capture variables from the enclosing scope. For example: これら無名関数の最も significant な機能の一つが 無名関数を囲むスコープにある変数を捕獲する能力 (ability) です。 例をあげましょう: int x = 42; void (^block)(void) = ^{ printf("%d\n", x); }; block(); // prints 42 The two constructs handle variable capture significantly differently, so I'll take them one at a time. 二つの constructs の handle variable capture は significantly differently なので、一つずつ説明します。 Objective-C blocks can capture variables from the enclosing scope by simply referring to them within the block, as seen above. By default, all captured variables are copied at the point where the block is created and cannot be modified from within the block. これまで見てきたように、Objective-C のブロックはそのブロックを囲むスコープの中で 単に参照することで変数の捕獲ができます。 デフォルトでは、ブロックが生成された時点で捕獲されたすべての変数はコピーされ、 そしてブロックの中から変更することはできません。 If a block captures another block variable, that block's memory is automatically managed. It's copied and released as necessary. Objective-C object pointers are also automatically managed by retaining and releasing them as necessary. This deep, implicit integration with Objective-C memory management makes a lot of tasks significantly easier, because most of the time blocks automatically do the right thing with the variables they capture. あるブロックが別のブロックの変数を capture したときそのブロックのメモリーは自動的に管理されます。 Objective-C のオブジェクトポインターもまた、必要に応じて retain と release をすることで 自動的に管理されます。この deep な implicit integration with Objective-C のメモリ管理は 多くのタスクを significantly に簡単にします。 それは、ほとんどの場合でブロックは捕獲した変数を使って自動的に正しいことを行うからです For cases where the block needs to be able to modify a captured variable, the variable must be declared with the special__block qualifier to mark it as being mutable: ブロックが捕獲した変数を変更できるようにする必要があるケースでは、 その変数が mutableであることを示すために 特別な __block qualifier をつけて宣言しなければなりません __block int x = 42; void (^block)(void) = ^{ x = 43; }; block(); // x is now 43 It is important to note that the automatic memory management of block and object pointers does not occur for variables qualified with __block, so the programmer needs to make sure that everything is built to tolerate that. For primitives like x above, there is no concern. ブロックやオブジェクトポインターの自動メモリ管理は __block で修飾された変数に対しては行われない ことに注意を払うことは重要で、プログラマーはすべてが built to tolerate that であることを make sure する必要があります。 上記の例の x のようなプリミティブに対しては concern はありません。 It should come as no surprise that C++0x lambdas offer considerably greater flexibility but also considerably greater complication in this area. The overall philosophy of C++ appears to be to give the programmer as many tools and choices as possible, which has its pros and cons. C++0x の lambda が consideably greater flexibility だけではなく considerably greater complication in this area も offer していることは should come as no surprise。 (長所も短所も含めて) 可能な限り多くのツールと選択肢をプログラマーに与えるために The overall philosophy of C++ は appears しています。 The initial [] which begins a C++0x lambda controls how local variables are captured. If it's left empty like that, then no variables can be captured at all. In order to capture variables, it's necessary to tell the compiler what you want to do. C++0x の lambda の頭にある [] はローカル変数がどのように捕獲されるのかを control します。 [] が空のままであれば捕獲できる変数はありません。 変数を捕獲するためには、コンパイラーに自分が何をしたいのかを伝える必要があります。 The most explicit way to do this is to list the variables to be captured inside the []. Any variable listed directly by name is captured by value. Any variable listed with a leading & is captured by reference. For example: これを行う最も explicitなやり方は []の内側に捕獲する変数を列挙することです。by name で 列挙されたすべての変数は by value で捕獲されますが、& が前置された変数は by reference で捕獲されます。例をあげましょう: int x = 42; int y = 99; auto lambda = [x, &y]{ y = 100; }; lambda(); // y is now 100 It's not possible to modify x in this case, as a lambda's operator() is const by default. However, this can be overridden by declaring it to be mutable: この場合 x を変更することはできません。 lambda の operator() がデフォルトで const であるので しかし、mutalbe であると宣言することでこれを上書きできます: int x = 42; int y = 99; auto lambda = [x, &y]() mutable { x++, y++; printf("%d, %d\n", x, y); }; lambda(); // prints 43, 100 printf("%d, %d\n", x, y); // prints 42, 100 lambda(); // prints 44, 101! Because x is captured by value, changes made from within the lambda are not seen outside of it. There are essentially two copies of x at this point, and neither one affects the other. x は by value で捕獲されているので、lambda の内側でなされた変更は lambda の外側には及びません。 本質的にはこの時点で x の実体が二つ存在していて、 それぞれは他方に影響することはありません。 It can be inconvenient to list every variable to be captured, so it is possible to specify a default capture behavior by putting either = or & within the []. For example: 捕獲するためにすべての変数を列挙するのは不便ですが、[] の中に = か &を置くことに よってデフォルトの捕獲動作を指定できます。 例を挙げましょう: int x = 42; int y = 99; auto lambda = [&] { x++, y++; }; lambda(); // x, y are now 43, 100 It's even possible to combine the two, to have a default capture with exceptions: デフォルトの捕獲に例外を置くためにこれら二つを組み合わせることも可能です: int x = 42; int y = 99; int z = 1001; auto lambda = [=, &z] { // can't modify x or y here, but we can read them // ここでは x と y は変更できない。読むことはできる。 z++; printf("%d, %d, %d\n", x, y, z); }; lambda(); // prints 42, 99, 1002 // z is now 1002 By allowing each lambda to specify how it captures things, the C++0x system allows more flexibility. With Objective-C blocks, a given variable is either __block or it's not. Every block which captures that variable must capture it in the same way. C++0x lambdas allow each lambda to make its own choice on how to capture. The mutable keyword even allows them to capture by value but retain the ability to change the copied value internally. The downside is considerably increased complexity. それぞれの lambda でどのように捕獲を行うかを指定できるようにすることで、C++0x のシステ ムはより柔軟性を持ったものになります。Objective-C のブロックでは、与えられた変数は __block かそうでないかのいずれかです。そのような変数を捕獲しているすべてのブロックは同 様のやり方でもって該当する変数を捕獲しなければなりません。C++0x の lambda では各 lambda がそれぞれ自分がどのように捕獲するかを選択できるようにしています。予約語 mutable は by value での捕獲を可能にしますが、内部的にコピーした値を変更する能力 (ability) を retain します。この downside は considerably に複雑さを増加させます。 ます。 Memory Management メモリー管理 Both Objective-C blocks and C++0x lambdas start their lives as stack objects. After that point, however, they diverge significantly. Objective-C のブロックとC++0xの lambda の両方ともスタックオブジェクトとしてその生涯が 始まります。しかしある時点で、それらは significantly に diverge します。 Objective-C blocks are also Objective-C objects. Like all Objective-C objects, they are stored by reference, never by value. When a block literal is written, the block object is created on the stack, and the literal expression evaluates to the address of that block. Objective-C のブロックは Objective-C のオブジェクトでもあります。すべての Objective-C オブジェクトと同様にブロックは by reference で格納され、by value で格納されることは決 してありません。ブロックリテラルが書かれたとき、ブロックオブジェクトはスタック上に生成 されます。そしてリテラル式は evaluates to the address of that block. In order for a block to outlive its slot on the stack, it must be copied. Because the value is just a reference, simply assigning it with = is not enough: あるブロックが outlive its slot on the stack するためにはコピーされなければなりません。 スタック上に置かれているのは単なる reference なので、 = を使った単純な代入では不十分です: void (^block)(void); { block = ^{ printf("hello world"); }; } block(); // bad! Instead, it must be copied, either by using the Objective-C copy method, or the C Block_copy function: 単純な代入ではなしに、Objective-C の copy メソッドか C の Block_copy 関数を使うかして コピーしなければなりません: void (^block)(void); { block = ^{ printf("hello world"); }; block = [block copy]; } block(); // good! Blocks follow standard Objective-C reference counting semantics. Each copy must be balanced with a release or autorelease, and each Block_copy must be balanced with a Block_release. The first copy gets the block onto the heap, subsequent ones simply increment the reference count. When the last live reference is released, the block is destroyed, and any captured objects or blocks are released. ブロックは Objecive-C の標準である参照カウント方式のセマンティクスに従います。それぞれ のコピーは release か autorelease を使ってバランスさせなければいけませんし、Block_copy はそれぞれが Block_relase とバランスしていなければなりません。最初のコピーはブロックを ヒープに得ますが、後続のコピーは単純にヒープに置かれたものの参照カウントを増やすだけで す。最後まで生きていた参照がリリースされたときにそのブロックは破棄されて、すべての捕獲 オブジェクトおよび捕獲ブロックはリリースされます。 C++0x lambdas are stored by value, not by reference. They can be copied onto the heap if needed, but the process is entirely manual. All captured variables are stored as member variables within the anonymous lambda object, so when the lambda is copied, those get copied as well, firing the appropriate constructors and destructors. C++0x の lambda は by reference ではなく by value で格納されます。必要があればヒープに コピーできますが、そのための手続きは完全に手作業です。すべての捕獲変数は無名 lambda オ ブジェクト内にメンバー変数として格納されます。そのため、lambda がコピーされたときには 捕獲変数も同様にコピーされて、適切なコンストラクターやデストラクタ―が実行されます。 One extremely important aspect of this behavior is that variables which are captured by reference are stored as references within the lambda object. They get no special treatment in this respect. This means that a lambda which accesses one of those variables after the original enclosing scope has been destroyed is engaging in undefined behavior and will likely crash. Compare this to __block variables, where the storage is transparently moved to the heap and is guaranteed to live at least as long as the block does. この動作のひとつの extremely important な aspect は、by reference で捕獲された変数が lambda オブジェクトの中で reference として格納されるということです。それらの変数は this respect において 特別な扱いを受けません。これはつまり、original enclosing scope が破棄された後でそういった変数のどれか一つにでもアクセスする lambda は未定義動作を engaging してたぶんクラッシュするだろうということです。これを __block 変数と比較すると、 storage の場所がヒープへと transparently に move し、少なくともブロックと同じ長さの寿 命が gurantee されます。 On the other hand, as long as nothing is captured by reference, a C++0x lambda can be returned without any extra work. The return will copy it and the copy will continue to function. With Objective-C blocks, they must be explicitly copied before returning, otherwise they become immediately invalid. その一方で、 by reference で捕獲されていないので C++0x の lambda は一切 extra work をすることなく return できます。 The return will copy it and the copy will continue to function. Objective-C のブロックの場合は return する前に explicitly にコピーしなければならず、 さもなければ即座に invalid なものになってしまいます。 Performance 性能 Objective-C blocks are objects which contain an embedded function pointer. A block call translates to a call to that function pointer, passing the block as an implicit parameter: Objective-C のブロックは埋め込まれた関数ポインターを持っているオブジェクトです。 あるブロックの呼び出しは、暗黙の引数としてそのブロックを渡す (ブロックに)埋め込まれた関数ポインターを使った呼び出しへと変換されます。 block(); // equivalent to: block->impl(block); The cost of calling a block is therefore about the same as the cost of calling a C function. It's slightly higher due to the need to look up the implementation pointer first, but just slightly. ブロック呼び出しのコストはしたがって、 C の関数呼び出しのコストと概ね同じものです。 最初に implementation pointer の look up が必要である分、 ブロック呼び出しの方がわずかに高価なのは確かですが、本当にわずかなものです。 Opportunities for optimization are rare in most use cases. For example, this code calls a method to iterate over an array with a block: ほとんどの場合、最適化の機会はほぼありません。 例として、次のようなブロック中にある配列を iterate over するメソッドを呼び出すコードを挙げます: [array do: ^(id obj) { NSLog(@"Obj is %@", obj); }]; The implementation of -do: can't know anything about the block which is passed to it here, so it must perform the full dereference and call for each iteration of the loop. この例の -do: の実装は渡されたブロックについて何も知ることができないので、 ループの iteration ごとに full dereference と呼び出しを行わなければなりません。 The cases where blocks can be optimized are mostly cases where they're not needed in the first place, for example where they are defined and then called in the same scope. One place where useful optimizations could be made are inline functions which take block parameters, since the optimizer is able to improve the inlined code based on the calling code. However, as far as I know, no current blocks-capable compilers perform any of these optimizations, although I haven't investigated it thoroughly. ブロックが最適化可能であるようなケースは、たいていはそのブロックが in the first place で必要とされていないケース、例えば同じスコープで定義と呼び出しがされているといったもの です。useful な最適化が可能であるかもしれない場所の一つがブロックパラメーターを引数に とるインライン関数です。それは、オプティマイザーが calling code に基づいてinline され たコードを改良できるからです。しかしながらわたしの知る限りでは、 although I haven't investigated it thoroughly. このような最適化の何かを行う block-capable なコンパイラーは現状でありません。 C++0x lambdas are objects with a operator(). There is no dynamic dispatch involved, so calling the lambda works out to be a simple function call, with no dereferencing ahead of time. C++0x のlambda は operator() を持ったオブジェクトです。 これは動的ディスパッチが involve されないので、lambda の呼び出しは単純な関数呼び出しとして dereferene の ahead of time もなく works out します Because passing a lambda to another function involves templates, there are further opportunities for optimization. Consider this code to iterate over a vector: 別の関数に lambda を渡すことによって template を invlove するので、 最適化のための更なる機会があります。 あるベクターを iterate する次のコードで考えてみましょう: for_each(v.begin(), v.end(), [](int x) { printf("x is %d\n", x); }); for_each is a template function, which means that it gets specialized for this particular type. This makes it an excellent candidate for inlining, and it's likely that an optimizing compiler will end up generating code for the above which would be just as good as the equivalent for loop. この for_each は特定の型に対して特殊化されたテンプレート関数です。 This makes it an excellent candidate for inlining, インライン展開の excellent candidate にする and it's likely that an optimizing compiler will end up generating code for the above which would be just as good as the equivalent for loop. 最適化コンパイラーが最終的に for ループと同程度に優れているであろうコードを生成する This is a typical tradeoff between C++ and Objective-C. C++ often favors the fastest possible generated code at the level of individual functions, sacrificing ease and speed of compilation and sometimes ease of programming to get it. Objective-C more often favors implementations which are simpler to create, compile, and use, at the cost of additional runtime overhead. これは C++ と Objecive-C との間にある典型的なトレードオフです。 C++ はしばしば ease and speed of compilation だとか、 ときには ease of programming to get it まで犠牲にしても 可能な限り高速な生成コードを favor します。 Objective-C は additional runtime overhead のコストの点で、 作成やコンパイル、あるいは使うのがシンプルである実装をより一層 favor します Conclusion 結論 Objective-C blocks and C++0x lambdas are similar language features with similar goals but considerably different approaches. Objective-C blocks are somewhat simpler to write and to use, especially in the case of using them for asynchronous or background tasks where the block has to be copied and kept alive beyond the lifetime of the scope where it was created. C++0x lambdas ultimately provide more flexibility and potential speed, but at the cost of considerable added complexity. In comparing the two, I believe that Apple ultimately made the better set of tradeoffs, at least for the cases where I am likely to use blocks in my own programming. Objectice-C のブロックと C++0x の lambda は、似通った目標を持っているけれども異なるア プローチを採用している類似の言語機能です。Objective-C のブロックは書いたり使ったりする のが簡単な、somewhat で、特にブロックがコピーされなければならなかったり、また、作られ たスコープの lifetime を越えて keep alive されなければならない非同期なタスクやバックグ ラウンドタスクに使うようなケースで使われるものです。C++0x の lambda は more flexibility と potential speed を ultimately に provide しますが、 cost of considerable な complexity を付加します。 これら二つを比較したとき、 少なくともわたし自身がプログラミングするときにブロックを使いたくなるような状況で Apple は、最終的に better set of tradeoff を made するとわたしは確信していします。 That wraps things up for this week. Come back in another 14 days for the next baffling edition. As I say every time, Friday Q&A is driven by reader ideas. If you have a topic that you would like to see covered here, please send it in. Did you enjoy this article? I'm selling a whole book full of them. It's available for iBooks and Kindle, plus a direct download in PDF and ePub format. It's also available in paper for the old-fashioned. Click here for more information. When not writing these blog posts, I put this stuff into action over at Rogue Amoeba, where we create great audio software for the Mac.
大規模ゲームがトレンドだからといって調子にのって社員を増やすとロクなことがないと。 耐えられなくなって減らす時が来たとして、 そこで減るのはその時に取った不要な新人ではなく、 それまで一線で働いてきた歴戦の戦士なわけだ。 "
金が出ればやる気が出るとは限らないが、金が出なければやる気も出ない。 てなもんで。
例によって本文訳しているような余裕はなっしんぐ。
An open letter to those who want to start programming - Solace In Random Lines An open letter to those who want to start programming プログラミングを始めたいと思っている人への公開書簡 First off, welcome to the fraternity. There aren't too many people who want to create stuff and solve problems. You are a hacker. You are one of those who wants to do something interesting. “When you don't create things, you become defined by your tastes rather than ability." – WhyTheLuckyStiff Take the words below with a pinch of salt. All these come from me – a bag-and-tag programmer. I love to get things working, rather than sit at something and over-optimize it. Start creating something just for fun. That's a great start! There's no way you will start if you say you “need to learn before doing”. Everybody's got to start somewhere. Fire up your editor and start writing code.Choose a good language. One that you think you can produce something useful in short time. 短時間で有用ななにかを作り出せるだろうと思うような良い言語を選ぼう。 So let C not be your first language. That might give you the satisfaction of doing things the really old-n-geeky way. C was the solution to the problem Assembly Language was. It offers better syntactic sugar than it's prominent predecessor – Assemble Language. But today, C (or C++) is not a language that you can produce something very quickly. I would suggest that you use a dynamic language – I won't sideline any options. Choose a language whose syntax (and documentation) you think you might be comfortable with. For this, you might want to spend some time trying out different languages for a few hours. The purpose of choosing such a language is not to make you feel better and that programming is easy. Completing stuff faster and being able to see the output keeps you motivated. Don't choose a language that requires a special heavy-weight IDE (tool that helps you write code and run it) to program better in the language. All you should need is a text editor. ですから、最初の言語として C を選んではいけません。 C を選ぶことで、古き良きギーク流のことをしているという満足が得られるかもしれません。 C はアセンブリ言語が解決しようとしてた問題を解決したものでした。 C はそれ以前のもの、つまりアセンブリ言語よりもまともな構文糖 (syntactic sugar) を もたらしました。しかし今日にあっては、C (や C++) はあなたがすばやく何かを作れる 言語ではありません。わたしは動的言語を使うことをオススメします。 あなたが comfortable であると思うような構文(とドキュメント)を備えた言語を選びましょう。 Choose a good editor. 良いエディターを選ぼう Use an operating system that'll teach you something. あなたに何かを教えてくれるであろうオペレーティングシステムを使おう Don't copy-paste files to backup stuff. バックアップするのにコピペをしてはいけない Know where to get help. 助けを得られる場所を知ろう Develop your netiquette. ネチケットを身につけよう Write opensource code. オープンソースなコードを書こう
Scala: The Static Language that Feels Dynamic への反応?
Whiley | Language Complexity? Language Complexity? By Dave, on June 13th, 2011 Some languages are complex, others are simple … right? C++ versus just about anything else is a good example here. But, it begs the question: what makes a language complex? 複雑な言語が一部にはあって、そのほかのものはシンプル。本当に? C++ とそのほかの言語というのはその良い例です。しかし、ひとつの質問が浮かび上がります。 言語を複雑にしているものとはなんなのでしょうか? So, I've just been reading Bruce Eckel's Artima article on Scala. It's actually a nice article, and I enjoyed it. But, one thing bugged me — and, it's nicely summarised in this quote: そこでわたしは Bruce Eckel の Scala についての Artima article を読みました。 それはとてもすばらしい atricle で、楽しめるものでした。 けれどもひとつのことがわたしを bugged させました。 それは次の引用に端的に表されています: But you can see from the code above that learning Scala should be a lot easier than learning Java! There's none of the horrible Java ceremony necessary just to write “Hello, world!” — in Scala you can actually create a one-line script … しかし上記のコードから、Scalaを学ぶことはJavaを学ぶよりも数段容易なものであることを 認識できるでしょう! Scala ではただ単に "Hello, world!"を書くためだけに Java では必須の 面倒この上ないおまじないは一切必要ありません。実質一行のスクリプトを書けば良いのです。 本文略
対応OSはWindows 7/Vista/XP/Server 2008/Server 2003の各日本語版で、価格は税込14,700円から。
げしょ。
Amazon.co.jp: Scala実践プログラミング―オープンソース徹底活用: 小笠原 啓: 本 がないかと秋葉原のあそことあそこに行ってみたけどまだ(?)なかった。 Amazon.co.jp: Scheme修行: Daniel P. Friedman and Matthias Felleisen, 元吉 文男, 横山 晶一: 本 はたくさんあった。
Scala 本では Amazon.co.jp: Scalaではじめるプログラミング―「Java」「.NET」のソフト資産を生かして開発を効率化! (I/O BOOKS): 赤間 世紀: 本 があった。が(以下略)
パラダイムシフト(英: paradigm shift)とは、その時代や分野において当然のことと考えられていた認識や思想、社会全体の価値観などが革命的にもしくは劇的に変化することを言う。パラダイムチェンジとも言う。
その3つの中でただの一度も使われていない(はずの)言葉がある。それは
だめ。限界w
ぐでーん
bug-gawk Archives にアナウンスがなかったのに、3.1.85 が出てるとかいう話を聞いたので なんじゃそりゃあと思い調べてみたら、分離前のMLにあった○| ̄|_
2nd gawk 4.0 beta tarball available From: Aharon Robbins Subject: 2nd gawk 4.0 beta tarball available Date: Tue, 07 Jun 2011 10:33:42 +0300 Hello Everyone. The next beta tarball for gawk 4.0 is at http://www.skeeve.com/gawk/gawk-3.1.85.tar.gz There are a number of bug fixes, including a better job of making [a-z] ranges work how G-d intended. Thanks, Arnold
まあそれほど大きな変更ではなさげ。 文字クラスの扱いについては、ほかの人から質問が出てるみたいだけど。
なんか海の向こうでも騒動? Scala: The Static Language that Feels Dynamic (Bruce Eckel) : programming 伸びてます。
Scala: The Static Language that Feels Dynamic Summary The highest complement you can deliver in the Python world is to say that something is "Pythonic" -- that it feels and fits into the Python way of thinking. I never imagined that a static language could feel this way, but Scala does -- and possibly even better.
全部読むのはちと面倒だが。
以前に見たことがあるけど、さらに(ry
pattern - vimdoc-ja ============================================================================== 4. パターンの概要 *pattern-overview* 量指定子の概要。 */multi* *E61* *E62* 詳しい説明や使用例は、リンク先を参照してください。 *E64* 量指定子 'magic' 'nomagic' アトムがいくつマッチするか |/star| * \* 0 以上 最長一致 |/\+| \+ \+ 1 以上 最長一致 (*) |/\=| \= \= 0 か 1 最長一致 (*) |/\?| \? \? 0 か 1 最長一致 (*) |/\{| \{n,m} \{n,m} n 以上 m 以下 最長一致 (*) \{n} \{n} n 正確に指定した数だけ (*) \{n,} \{n,} n 以上 最長一致 (*) \{,m} \{,m} 0 以上 m 以下 最長一致 (*) \{} \{} 0 以上 最長一致 (*と同じ) (*) |/\{-| \{-n,m} \{-n,m} n 以上 m 以下 最短一致 (*) \{-n} \{-n} n 正確に指定した数だけ (*) \{-n,} \{-n,} n 以上 最短一致 (*) \{-,m} \{-,m} 0 以上 m 以下 最短一致 (*) \{-} \{-} 0 以上 最短一致 (*) *E59* |/\@>| \@> \@> 1 強欲な量指定子 (*) |/\@=| \@= \@= なし 幅ゼロの肯定先読み |/zero-width| (*) |/\@!| \@! \@! なし 幅ゼロの否定先読み |/zero-width| (*) |/\@<=| \@<= \@<= なし 幅ゼロの肯定後読み |/zero-width| (*) |/\@<!| \@<! \@<! なし 幅ゼロの否定後読み |/zero-width| (*) (*) {Vi にはない機能です} 普通のアトムの概要 */ordinary-atom* 詳しい説明や使用例は、リンク先を参照してください。 アトム magic nomagic マッチするもの |/^| ^ ^ 行頭 (パターンの先頭にある場合だけ) |/zero-width| |/\^| \^ \^ リテラル文字 '^' |/\_^| \_^ \_^ 行頭 (どこでも使える) |/zero-width| |/$| $ $ 行末 (パターンの末尾にある場合だけ) |/zero-width| |/\$| \$ \$ リテラル文字 '$' |/\_$| \_$ \_$ 行末 (どこでも使える) |/zero-width| |/.| . \. 何か 1 文字 (改行以外) |/\_.| \_. \_. 何か 1 文字 (改行含む) |/\<| \< \< 単語の先頭 |/zero-width| |/\>| \> \> 単語の末尾 |/zero-width| |/\zs| \zs \zs なし。マッチの開始地点を設定します |/\ze| \ze \ze なし。マッチの終了地点を設定します |/\%^| \%^ \%^ ファイルの先頭 |/zero-width| *E71* |/\%$| \%$ \%$ ファイルの末尾 |/zero-width| |/\%V| \%V \%V 選択範囲内 |/zero-width| |/\%#| \%# \%# カーソル位置 |/zero-width| |/\%'m| \%'m \%'m マーク m の位置 |/zero-width| |/\%l| \%23l \%23l 23行目 |/zero-width| |/\%c| \%23c \%23c 23列目 |/zero-width| |/\%v| \%23v \%23v 23列目 (表示単位) |/zero-width| 文字クラス {Vi にはない機能です}: */character-classes* |/\i| \i \i 識別子文字 (オプション 'isident' を参照) |/\I| \I \I "\i" と同じですが、数字は除外します |/\k| \k \k キーワード文字 (オプション 'iskeyword' を参照) |/\K| \K \K "\k" と同じですが、数字は除外します |/\f| \f \f ファイル名の文字 (オプション 'isfname' を参照) |/\F| \F \F "\f" と同じですが、数字は除外します |/\p| \p \p 印字可能文字 (オプション 'isprint' を参照) |/\P| \P \P "\p" と同じですが、数字は除外します |/\s| \s \s 空白文字: <Space> と <Tab> |/\S| \S \S 空白文字以外。\s の反対です |/\d| \d \d 数字 [0-9] |/\D| \D \D 数字以外 [^0-9] |/\x| \x \x 16 進数字 [0-9A-Fa-f] |/\X| \X \X 16 進数字以外 [^0-9A-Fa-f] |/\o| \o \o 8 進数字 [0-7] |/\O| \O \O 8 進数字以外 [^0-7] |/\w| \w \w 単語を構成する文字 [0-9A-Za-z_] |/\W| \W \W 単語を構成する文字以外 [^0-9A-Za-z_] |/\h| \h \h 単語の先頭の文字 [A-Za-z_] |/\H| \H \H 単語の先頭の文字以外 [^A-Za-z_] |/\a| \a \a 英字 [A-Za-z] |/\A| \A \A 英字以外 [^A-Za-z] |/\l| \l \l 小文字英字 [a-z] |/\L| \L \L 小文字英字以外 [^a-z] |/\u| \u \u 大文字英字 [A-Z] |/\U| \U \U 大文字英字以外 [^A-Z] |/\_| \_x \_x x は上記の文字クラスのどれかです。文字クラスと改行が マッチします。 (文字クラスここまで) 略 */\@<=* \@<= 幅ゼロの肯定後読み。|/zero-width| {Vi にはない機能です} Perl の "(?<=pattern)" と同じですが、Vimでは可変長パターンも使えます。 Example マッチするもの \(an\_s\+\)\@<=file "an" と空白文字 (改行含む) の後の "file" 処理速度を気にするなら、この量指定子は避けたほうが無難です。代わりに "\zs" を使ってください |/\zs|。次のものは上記の例と同じものにマッチし ます: an\_s\+\zsfile "\@<=" と "\@<!" は直前の文字がマッチしているかどうかをチェックしま す。理論上は、マッチの現在位置よりも前ならどこでもマッチできます。しか し、処理時間を制限するために、マッチの現在行と、(もしあれば) 1 つ前の 行だけが検索されます。ほとんどの場合はこれで十分ですし、遅くなり過ぎる こともありません。 "\@<=" や "\@<!" の後にくるパターンは最初にチェックされます。そのため、 "\1" のような、\(\) の前方参照は機能しません。そのときは次のようにしま す: Example マッチするもの \1\@<=,\([a-z]\+\) "abc,abc" の ",abc" */\@<!*
ほー。
17項目あるので、いつもよりは多め?
plope - Open Source Project Maintainer Sarcastic Response Cheat Sheet Open Source Project Maintainer Sarcastic Response Cheat Sheet オープンソースプロジェクトのメンテナー向けの皮肉を込めた対応のカンペ Need a sarcastic response to a support interaction as an open source project maintainer? Look no further! 1. I'll just retype the docs into this email for you. わたしはあなたのためにドキュメントからタイプしなおしてメールしています。 2. Please send me an email personally, because the mailing list is full of other people who can help. メールは個人的に送ってください。メーリングリストは余計な人たちがたくさんいます。 3. I don't need to see any code to answer that. 回答するのにコードは一切必要ありません。 4. Just paste the very last line of the traceback please, I've memorized all the potential codepaths of your application. トレースバックの最後の行だけ貼り付けてください。お願いします。 5. Of course I believe you've found a fundamental bug in the system. You've been using it for almost 10 minutes. 6. Why would you learn to use an interactive debugger? 7. Don't sweat it, I am a master at Engrish. 8. That docs typo is important enough for me to fix right now; don't bother creating an issue for it. ドキュメントにある誤字はわたしにとっては今すぐ修正しなければならない重要なものです。 そのためのバグ票を起こすのを面倒くさがらないでください。 9. Please don't submit a pull request, just type the diff manually into IRC, I'll take care of it right now. 10. Let's talk about variable names, I really wasn't doing anything else. 変数の名前について話し合いましょう。それ以外のことをするつもりはありません。 11. When I said 'dont do it that way', I was just making idle conversation. 12. I love answering the same question from you every two weeks. 二週間毎にあなたの同じ質問に答えるのが大好きです。 13. It totally makes sense for you to do it the hard way over and over. 14. Please, please let me convince you to use my free software because I know you're going to contribute back later. 15. The dogma you've gained from your six months of experience is indeed how everyone should do it. 16. You're right, it is too complex. Why didn't I think of that? あなたが正しいです。これは複雑すぎます。なぜそう考えなかったのでしょうね? 17. Ignoring conventions is completely reasonable at your experience level. あなたの経験からすれば、規約を無視することはまったく合理的です。 Created by chrism
どうもニュアンスがよくわからんところがあるな ○| ̄|_
今こそ君のノウハウがまた必要だし、君は君の持ってるノウハウを若い連中に教える義務がある、と僕は思ってるよ。
まさかブラザ作ってる人って、ユーザーの気持ちがわからない仕事ができない人が配属されてるんですか?
「Enumerable をもっと Enumerable らしく」。enumerable_lz は、その 1 つの提案です。
一時期、embedded をそのまま日本語にした感のある「埋め込み」ってのも よく見かけたような気が。
組み込みプログラマー雑談スレッド その19 774 仕様書無しさん [sage] 2011/06/08(水) 19:56:26.00 ID: Be: マイコンを使う技術を 誰が「組込み」「エンベデッド」なんて名前付けたの? 2000年前後ぐらいから言われるようになった。 おそらくアメリカでエンベデッドシステムなんて呼ばれてたのを誰かが日本語に翻訳したんだろうけど 昔は日本では組込みのことを「マイコン応用」と呼んでいた。 775 仕様書無しさん [sage] 2011/06/08(水) 20:01:23.42 ID: Be: 試験を受けてもらいたいから、名前変えたんじゃないの? 776 仕様書無しさん [] 2011/06/08(水) 21:36:36.28 ID: Be: 団体作って試験受けさせて金巻き上げる 対策本売って金巻き上げる いい商売だ 777 仕様書無しさん [sage] 2011/06/08(水) 21:57:47.71 ID: Be: >>774 少なくとも80年代の終わりには聞いた記憶があるけど。 778 仕様書無しさん [sage] 2011/06/08(水) 23:26:24.34 ID: Be: 「組込み」って80年代ぐらいからほんの一部の者たちの間で言われてたけど 2001年に情報処理技術者試験で「テクニカルエンジニア(エンベデッドシステム)」っていう名前がつくまで全くの無名だったな 所詮名前だけで、技術としては大昔からある 779 仕様書無しさん [sage] 2011/06/09(木) 07:24:35.24 ID: Be: 概念的な、てなことを言ったら1950年頃にMITのリアルタイムフライトシミュレータに コンピュータが使われたのがたぶん元祖だからな。 780 仕様書無しさん [sage] 2011/06/09(木) 07:39:59.11 ID: Be: >>777 俺は70年代ぐらいには聞いたきがする 793 仕様書無しさん [sage] 2011/06/11(土) 16:18:07.40 ID: Be: ここ数年建機のコードに携わっているんだが 最近設計が微妙に複雑になってきているのに再利用性とか可読性とか求められるから CからC++に移行したいんだよなあ… でも、C++に移行するとハード系の人間含めて脱落者が多くなって無理そう (個人的にはライバルが減って(゚д゚)ウマーなんだがw) 794 仕様書無しさん [sage] 2011/06/11(土) 19:01:17.79 ID: Be: >>793 社内での取り組み方であれば、いきなりガチガチにやった方がよいよ。 betterCとしてすこしずつ浸透させるやり方だと、間違いなく破綻する。
そいやガウディ本あともう少しのところまで読んだけど完走してないや ○| ̄|_
プログラミング言語 Scala 6冊目 92 デフォルトの名無しさん [sage] 2011/06/12(日) 12:12:35.32 ID: Be: 結局Javaを知らないと書けないから複雑、マルチパラダイムだから複雑 これはいいんだよ、完全に事実だから だからJavaと関数型を勉強してから来いよ LLしか知らないようなやつがいきなり理解できるわけねーんだよ 93 デフォルトの名無しさん [sage] 2011/06/12(日) 12:44:38.86 ID: Be: Rubyは勉強しないといけないなぁ、とは思っている。 プログラマとして上を目指すなら、色々な言語を知っておいて損はない。 それと、初心者に門戸を広げるというのはまた話が別だけどね。 94 デフォルトの名無しさん [] 2011/06/12(日) 12:50:02.02 ID: Be: 勉強したくないからRubyやってるんだろ 95 デフォルトの名無しさん [sage] 2011/06/12(日) 12:52:46.73 ID: Be: いやまてまてRubyはRubyで色々勉強しなきゃいかんし というか抗争を煽ろうとしてる人間がスレに混じってるようで嫌だな 96 デフォルトの名無しさん [sage] 2011/06/12(日) 12:55:32.07 ID: Be: >>93 僕と契約して、Ozを勉強してよ http://www.mozart-oz.org/home/doc/tutorial/index.html 日本語翻訳は任せた ていうか誰か完訳して… CTMCPで使われてるのにまだチュートリアル日本語版が無いとか 日本の情報工学マジ… 99 デフォルトの名無しさん [sage] 2011/06/12(日) 13:08:12.37 ID: Be: >>96 CTMCPは衝撃だった マルチパラダイムであっても核言語を整理すれば あそこまで簡潔になるんだなあと じゃあScalaはっていう話になるが、どうしても複雑だという印象を拭えない Ozとの違いでいくと、静的型付けって所が影響してるのかなあ? 110 デフォルトの名無しさん [sage] 2011/06/12(日) 13:54:27.52 ID: Be: >>96 つーかOzってCTMCPを読むための言語ってイメージだが それならCTMCPを読めばええやんって話だから誰も翻訳しないんじゃね 114 デフォルトの名無しさん [sage] 2011/06/12(日) 15:00:04.28 ID: Be: >>110 Scheme(SICP)は沢山入門文書があるのにね…。 原文読めよって話になるんだろうけど、それを嫌がる人にもCTMCPに触れてもらいたいのよ。 800P超える本に手を出す人が英語読むの億劫、ってのもレアケースかもだけど、 日本語文書で概要掴んで好きな所だけつまみ食いをもっと気軽に出来るようにしてほしいなって思って。 技術英単語にもっと明るくて時間があるなら、俺がやってもいいけどさ
Oz のチュートリアルってのはこれか。
Tutorial of Oz This tutorial introduces the Oz programming language and the Mozart programming system. (略) The tutorial covers most of the concepts of Oz in an informal way. It is suitable as first reading for programmers who want to be able to quickly start writing programs without any particular theoretical background. The document is deliberately informal and thus complements other Oz documentation. 以下略
あとで書く(可能性はどれくらい?
昨日のつづき。
NetRexx is now open source...does it matter? : programming Yes, APL, Lisp, Forth, and S/360 assembler are each minor inspirations to Rexx. But, compare the string formatting functions to those in Python. Rexx is also the origin of the popular long-precision Decimal datatype in Java and C#. Rexx has a cool "parse" statement and has associative arrays. Rexx essentially has a universal datatype. Rexx resembles the current wave of dynamic languages. All that said, this is 20 years too late. Rexx is now historical. Python has superseded it. (Disclaimer: I wrote a lot of Rexx code in the 80s and 90s.)
20年遅すぎた。ってのはまあそうだろうなあ。
にわかARM支持派(にわか組み込み専門家、にわかCPU専門家)
It's hard to summarize Chad's book into just a few sentences, but what I got from his book is that if, for whatever reason, you lose your passion for your job, you should move on to another place where you can be passionate and excel.
If you know the latex code of a character which you want in unicode, just enter the its code and then press enter.
仕様に詳しい方がいたら、どの辺からそういうことがいえるのか、教えていただきたいですね!
しかし、よく考えれば、C++でも実装クラスが限定されるなら、Javaと同様なことをハードコードすることでC++の仮想関数を高速ができるのではと思って試してみました。
昔、聞いた笑い話を思い出した。あるハードの開発でノイズでトラブルが起きた。でも現場の技術者の誰も対応できない。技術部長がかんかんになって、誰でもいいからわかる人間を連れてこい、と厳命した。そこで出てきたのは、
unicode 文字列とかPythonのような。 つーても実体は違うのだろうけど
New Features of Perl 5.14: unicode_strings - Perl.com New Features of Perl 5.14: unicode_strings By chromatic on June 8, 2011 11:12 AM Perl 5.14 is now available. While this latest major release of Perl 5 brings with it many bugfixes, updates to the core libraries, and the usual performance improvements, it also includes a few nice new features. Perl 5.14 が利用可能になっています。これはPerl 5の最新のメジャーリリースであり、 たくさんのバグフィックス、コアライブラリの更新、そして usual な性能の向上がなされ ていますが、いくつかの niceな新機能もあります。 One such feature is the new unicode_strings feature, enabled with use feature 'unicode_strings'; or use feature ':5.14';. (Perl 5.12 first introduced this feature, though it remained incomplete until the development of 5.14. Fortunately, you can write use feature ':5.12'; while running with 5.14 and still get all of the benefits of the improved form in Perl 5.14.) そういった機能の一つが新しい unicode_strings 機能です。これは use feature 'unicode_strings'; もしくは use feature ':5.14'; とすることで 有効になります。 unicode_strings tells the Perl 5 compiler to assume Unicode semantics for all string operations within the enclosing lexical scope. In other words, Perl will treat all strings as if they contain Unicode characters and not merely bytes. This fixes an issue when your code handles text outside of the strict ASCII range. unicode_strings は Perl 5コンパイラーに対し、現在の位置を取り囲むレキシカルスコープ (うまくねー)における文字列操作すべてにおいてUnicode semantics を仮定するように 指示します。言い換えれば、Perl はすべての文字列が Unicode 文字を保持していて 単なるバイトではないものとして扱うようになります。これはあなたのコードが strict な ASCII の範囲の外側にあるテキストを扱うときの問題を解決します。 For example, what should Perl assume if you read a character with a code point between 128 and 255? It's obviously not ASCII text. Is it Latin-1? Is it a raw byte? What should happen? たとえば、もしあなたがコードポイントで128から255の間にあるようなキャラクターをひとつ 読んだとしたら、Perlはすべきことはなんでしょうか? ASCIIでないことは明らかです。 Latin-1でしょうか? raw byte でしょうか? 何がおきるべきでしょうか? If you intend it as a Latin-1 character (Ö, for example), then the regular expression metacharacter \w should match it, because an O even with a diaresis is still a letter. The Perl 5 documentation refers to this as "character semantics". あなたがそのようなキャラクター (たとえば Ö) を Latin-1 のものとして扱いたいのなら、 正規表現のメタキャラクターの \w はそれにマッチすべきです。 なぜなら、diaresis がついていても O は文字には違いないからです。 Perl 5のドキュメントはこれを "character semantics" としています。 If you intend it as the byte value 214, then \w should not match it (though why are you using a regular expression against it?). The Perl 5 documentation refers to this as "byte semantics". これを byte value の 214 としたいのであれば、\w はそれにマッチすべきではありません (なぜそんなものに対して正規表現を使おうというのでしょう?)。Perl 5のドキュメントは これを "byte semantics" としています。 Now assume you have several strings from several places and you don't know the exact encodings of all of those sources and you want to concatenate two strings or interpolate them into a third string. What happens? ここで、あなたの手元に数箇所から得られたいくつかの文字列があって、それらすべての 正確なエンコーディングがわからないけれども、二つの文字列の連結だとか 第三の文字列へ interpolate したいとします。何が起きるでしょうか? With unicode_strings in effect, Perl 5 prefers to use character semantics for all string operations. You can override this lexically with no feature 'unicode_strings'; or use locale;. unicode_string が有効であるとき、Perl 5はすべての文字列操作に対して character semantics の使用を prefer します。これは no feature 'unicode_strings'; もしくは use locale; によってオーバーライド可能です。 For more information, see perldoc feature and especially The Unicode Bug" in perldoc perlunicode.
now open source ってあるけど、ダウンロードページ見るとパッケージの日付が2005年なんですけど。 そこからぜんぜん更新されていないってことなんだろうか。
NetRexx is now open source...does it matter? : programming NetRexx is now open source...does it matter? (netrexx.org)What the hell is NetRexx? (Their website also seems to be down or perpetually loading.)A compiler/interpreter of object-oriented version of REXX to Java bytecode. And REXX is one of oldest scripting languages (created in 1979).So assuming that it (at one point) cost money, it would be a safe assumption that it's a language in high demand.Didn't cost money, just wasn't open-source. Just like the Java JDK it runs on, until a few years ago. There are quite a few free interpreters for other versions of Rexx out there (Regina, Rexx/imc etc.). And on some platforms it was the scripting language (Amiga, OS/2, IBM systems). It never got quite popular on the current crop of systems (Windows, free Unices). Compared to languages like Python or Ruby, it's syntax has a few historical oddities.At this point, probably not. I've never heard of a single piece of software written in it.I click on "examples" and see no code. I possibly will never take a look at your language again. You failed to get a new user.Wow, that's awesome. Finally I can make my OS/2 scripts webscale.
Regina はちょっとだけいじったな。
lviv is a functional stack-based programming language. Or maybe it's just a fancy programmable calculator.
仕事で効率をあげろと休憩時間を削られれば余裕は無くなるし、効率効率言ってると人間が疎外されてゆくように思えるかもしれない。
In this directory I place slides of presentations I have given.
2. May the fork be with you
がよいな。
…ってスターウォーズネタは大丈夫だよね?
解説部分は略。
From CVS to Git, 9 Things I've Learned « EclipseSource Blog From CVS to Git, 9 Things I've Learned I decided to record some of things I learned while moving from CVS (a centralized version control system) to git (a distributed version control system). 1. Commit early, commit often 2. May the fork be with you 3. Check your head 4. RTFL: Read The Frickin (ref)Log 5. To pull or to fetch, that is the question 6. Shut-up and just branch 7. Stash it, don't trash it 8. Play the blame game 9. Those who don't learn from history, are destined to repeat it
一つ前へ
2011年6月(上旬)
一つ後へ
2011年6月(下旬)
リンクはご自由にどうぞ
メールの宛先はこちら