ときどきの雑記帖 3mm方眼紙編

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

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

ホームへ

2011年01月20日

■_

ジャイアントロボ次回が最終回というのがショックでかすぎた昨日。

栄光なき天才たち2010 「遂に復活!!天才たちの知られざる物語読みつくせ!!」 - アキバBlog
お、知らなかった。

渋谷シネセゾン、2月5日から閉館に伴うクロージング特別上映を実施 - GIGAZINE
あー、あそこも閉館しちゃうのね。 ここでは何を観たんだっけか。あ、父親たちの星条旗とか硫黄島の手紙、 立喰師列伝あたりか。

・コールオプション
すなおにカタカナ書きにすればよかったのか > Call Option
コールオプション(Call Option) とは - コトバンク コールオプション とは - コトバンク コールオプション - 野村證券

面白そうな話だ。 2011-01-20 - はてなるせだいあり

■_ 最適化

rubyでそれっぽいdecorator - 初学者の箸置 TAILCALL optimization - 初学者の箸置 Rubyの末尾再帰最適化を理解する - hp12c

そいや、C++ とか D では書けたのだろうか>某氏

■_ Why Java Developers Hate JavaScript | Javalobby

Why Java Developers Hate JavaScript | Javalobby

Why Java Developers Hate JavaScript 

Submitted by Gordon Dickens on Mon, 2011/01/17 - 7:00am 
 
 
As a Java developer, I used to hate JavaScript. At one time I used to say “friends 
don't let friends use JavaScript”. 

一 Java develper として、わたしは JavaScript を嫌ってきました。あるときなどは
“friends don't let friends use JavaScript”.
と言っていたくらいです。

In recent years, JavaScript has become required for a flexible & feature rich user 
experience. WIth the advent of tools such as JQuery and GWT many of these issues have 
been minimized. Also, I took the time to read more about JavaScript. The book that 
really opened my eyes is JavaScript: The Good Parts. 

近年、JavaScript は flexible で機能豊富なユーザー体験のために要求されるように
なってきました。JQuery や GWT のようなツールの advent を使うことで
このような問題の多くが最小限なものにされます。
また、より JavaScript について知るために時間をかけました。
JavaScript: The Good Parts という本は、わたしの目を開いた一冊です。

So… What do Java developers hate? 
 
 * JavaScript may look like Java, smell like Java and even taste a little like Java, 
   but it does not behave like Java

   JavaScript は Java のように見え、Java のようなにおいがし、多少は Java のような味さえも
   するが、Java のようには振舞わない。

 * Variables are global in scope
   変数がグローバルスコープにある

 * “this” has different meaning based on the invocation type (learn this for your own sake)
   “this”が、元となった invocation type と異なる意味を持っている

 * Braces do NOT guarantee scope
   ブレースがスコープを生成「しない」

 * Functions are first class citizens, not classes (avoid classes, you will set 
   yourself up for disappointment)

   関数が first class citizens であるのに、class はそうでない

 * Functions are objects, not simply methods to a class
   関数はオブジェクトであるが、クラスに対するメソッドはそうではない。

 * Variables are dynamically typed objects
   変数が動的に型付けされるオブジェクトである

 * JavaScript often fails silently (this is for user experience)
   JavaScript はしばしば静かに失敗する

 * Difficult to debug (use FireFox & Firebug addon)
   デバッグするのが難しい (Firefox とアドオンの Firebug を使いましょう)

 * Semicolons are optional (bad idea, put them where you want them)
   セミコロンが省略可能

 * Functions always return values, a value or “undefined”
   関数は常に値("undefined"を含め)を返す。

 * “new” has some specific assumptions, not simply creating an Object
   "new" はいくつかの固有の仮定を行っていて、ただ単純にオブジェクトを
   生成するわけではない

 * Cross browser compatibility (use jQuery or GWT to address most issues) 
 
What should you understand about JavaScript?
JavaScript についてあなたが理解しておくべきこととは?
 
 * Functions – First class citizens, the primary object in JavaScript
   関数 -
 * prototype system – Object.prototoype, object linkage, delegation, hasOwnProperty() 
   method, etc.
   プロトタイプシステム -
 * closures
   クロージャ
 * currying
   カリー化
 * the 4 invocation types: method, function, constructor & apply
   四つの invocation types: メソッド、関数、コンストラクター、apply
 * dynamic languages such as groovy, ruby, etc. they share many similarities
   groovy、ruby のような動的言語。それらの言語とは多くの共通点があります

What should you forget when using JavaScript?
JavaScript を使うときに忘れるべきことは?
 
 * Classes
   クラス
 * Scope using braces
   ブレースを使ったスコープ
 * Strong typing
   強い型付け
 
In summary, it is an entirely different language with many syntactical similarities. 
JavaScript is very power and flexible once you understand how it behaves. I highly 
recommend the O’Reilly book (mentioned above), its a short read and packed with 
awesome facts.

まとめると、JavaScript はJava と構文的に似ている点を多く持った完全に異なる言語です。
JavaScript はひとたびその振る舞いを理解できれば非常に強力でフレキシブルなものです。
わたしはオライリーの本を強くお薦めします。

■_ C は

C is fucking crazy : programming というのが盛り上がっていたので、どんなコードかいなと たどってみればこんなのだった。

gist: 787047 - C is fucking crazy.- GitHub

#include <stdio.h> 
void(*swap)() = (void(*)()) "\x8b\x44\x24\x04\x8b\x5c\x24\x08\x8b\x00\x8b\x1b\x31\xc3\x31\xd8\x31\xc3\x8b\x4c\x24\x04\x89\x01\x8b\x4c\x24\x08\x89\x19\xc3" 
"Oh, there you are Mr. Insanity..."; 
 
int main(){ // works on GCC 3+4 
    int a = 37, b = 13; 
    swap(&a, &b); 
 
    printf("%d%d",a,b); 
} 
 
// TIL: If you do this at work, you'll probably be fired

… DEP に引っかからないか?

C is fucking crazy : programming
 
C is fucking crazy (gist.github.com) 
 
 
C isn't crazy, it just doesn't stand in the way of crazy programmers. 
 
 
That's crazy! 
 
 
C is a low-level systems language. It'd be crazy if it couldn't do this. 
 
 
It only does it if you ignore the invalid cast from data pointer to function pointer. 
Modern C has seen fit to say that's a no no. 

 
What do you mean? It's a totally valid cast. Neither gcc nor the MS C Compiler 
complain about it. I bet OS kernels have quite a few casts like that, otherwise they 
wouldn't be able to read and execute executables from the disk, for example. 
 
(EDIT: Ok, now that I think about it it's a shitty example for various reasons, but 
you get my point none the less.) 

 
As Anderkent have already said, this basically takes a block of raw instructions, 
stick it into the memory, and gets casted into a function (void(*)()). In intel asm, 
the mnemonics would be as follows: 
 
mov eax, [esp+4] ;\x8b\x44\x24\x04 
mov ebx, [esp+8] ;\x8b\x5c\x24\x08 
mov eax, ds:[eax] ;\x8b\x00 
mov ebx, ds:[ebx] ;\x8b\x1b 
 
xor eax, ebx ;\x31\xc3 
xor ebx, eax ;\x31\xd8 Actual swapping done here 
xor eax, ebx ;\x31\xc3 
 
mov ecx, [esp+4] ;\x8b\x4c\x24\x04 
mov ds[ecx], eax ;\x89\x01 
mov ecx, [esp+8] ;\x8b\x4c\x24\x08 
mov ds[ecx], ebx ;\x89\x19 
 
ret ;\xc3 
 
 
> xor eax, ebx ;\x31\xc3 
> xor ebx, eax ;\x31\xd8 Actual swapping done here 
> xor eax, ebx ;\x31\xc3 
 
Why not just use xchg eax, ebx? 
 

■_

2011年01月19日

■_

チャンピオンREDで連載中のジャイアントロボが来月最終回と聞いて

■_ parrot

いつの間にか 3.0とか。

Parrot 3.0.0 "Beef Stew" Released - nntp.perl.org

On behalf of the Parrot team and an enthusiastic but undiscriminating 
dachshund that followed me home last week, I'm proud to announce Parrot 3.0.0, 
also known as "Beef Stew", or at the insistence of a shadowy government 
organization, "Snowflake". Parrot (http://parrot.org) is a virtual machine 
that dreams about running all dynamic languages everywhere, even the one 
you're think about right now. Parrot has big plans, even if needs a haircut 
and sometimes goes outside with its shoes untied. 

(略)
 
Here are some highlights from this release:
今回のリリースでの highlights をいくつか挙げます:

- Core 
 + A new embedding API is available in "parrot/api.h" and documented in 
   docs/pdd/pdd10_embedding.pod . 
 + Packfile PMCs were refactored and can now be used to produce runnable bytecode. 
 + Packfile manipulation code now throws embedder-friendly exceptions rather 
   than printing error details directly to stderr. 
 + Unicode support for file IO, environment variables, program names, and 
   command-line parameters was improved. 
 + An experimental gdb pretty-printers in tools/dev for Parrot STRINGs and 
   PMCs is now available. (gdb 7.2 or later and Python are required) 
 + c2str.pl and pmc2c.pl improvements result in a noticeably faster build. 
 + Bugs in our Digest::sha256 library and bit-related dynamic ops were fixed 
   by GCI student Nolan Lum. Both now work correctly on 32 and 64 bit  systems. 

- Languages 
 + Ωη;)XD - OMeta for Winxed https://github.com/plobsing/ohm-eta-wink-kzd 

- Community 
 + tree-optimization by GSoC student Tyler L. Curtis joined the nest and now 
   lives at http://github.com/parrot/tree-optimization . 
 + Plumage now lives at http://github.com/parrot/plumage and is installable. 
 + Christmas went as scheduled. The Parrot team does not take credit for this event. 

- Documentation 
 + HTML documentation generation has been rewritten and greatly simplified. 
 + We have improved documentation in docs/project/git_workflow.pod about 
   keeping a fork of parrot.git in sync. 
 + Translations of our README in various languages are now in the 
   docs/translation directory, thanks to Google Code-In students. 

- Tests 
 + A better way to write "todo" tests with Parrot's Test::More was implemented 
   by GCI student Fernando Brito. 
 + Major increases in test coverage of many core PMCs, dynamic PMCs and 
   dynamic opcodes resulted from GCI and the intrepid students it attracted. 
 + Jonathan "Duke" Leto set up Debian Linux x86_64 and sparc32 smokers 
   in the GCC Compile Farm, which continually submit smoke reports with 
   a variety of configuration options and compilers. Thanks, GCC! 
 + Makefile dependency checking is now automatically tested, resulting in a 
   more reliable parallel build. 
 + Coverage tests were improved for platforms with and without Devel::Cover. 
 
(略) 
 

しばらく Parrot のコードも読んでないや。

■_ 今日の十

10 Things You Can Do to Become a Better PHP Developer
10 Things You Can Do to Become a Better PHP Developer 
あなたがより良い PHP dveloper になるためにできる十のこと


PHP is probably the most popular web development language right now. At least 20 
million domains use PHP and it's the language used on major sites such as Wikipedia 
and Facebook as well as in some of the world's biggest open source projects like 
WordPress and Drupal. 

PHP はおそらく現時点においてもっともポピュラーなweb開発用言語です。
少なくとも2000万のドメインが PHP を使っていて、
Wikipedia や Facebook のようなメジャーなサイトだけでなく WordPress や Drupal の
ような世界でも最大級のオープンソースプロジェクトのいくつかがこの言語を使っています。

In this article, I'll share with you ten things I wish I was told when I was just 
getting started with PHP development, and I'm hoping you'll be able to learn a thing 
or two if you're just taking your first steps into this awesome web development 
language. 

本 article でわたしはあなたと、わたしが PHP 開発を始めるまさにそのときに
教えられていたら良かったであろうと思ったこと十個を共有します。
そして、この awesome な web 開発言語への第一歩をあなた踏み出すならば
これらの一つでも二つでも可能であることを願います。

1. Use PHP Core Functions and Classes 
   PHP のコア関数やコアクラスを使おう

If you're trying to do something that seems fairly common, chances are, there's 
already a PHP function or class that you can take advantage of. Always check out the 
PHP manual before creating your own functions. There's no need to create a function 
to remove the white space at the beginning and at the end of a string when you can 
just use the trim() function. Why build an XML parser for RSS feeds when you can take 
advantage of PHP's XML Parser functions (such as xml_parse_into_struct)? 

fairly common のような何かを行おうとした場合、
アドバンテージを得られるであろうPHPの関数やクラスがすでにあるかもしれません。
独自の関数を作ってしまう前に、いつでも PHP のマニュアルを確認してください。
trim() が使えるのに文字列の先頭や末尾にある空白を取り除く関数を作る必要はありません。
なぜ (xml_parse_into_structのような) PHP の XML パーザー関数の利点を得られるときに
RSS フィードのための XML パーザーを組み立てるのでしょうか?


2. Create a Configuration File
   設定ファイルを作ろう


Instead of having your database connection settings scattered everywhere, why not just 
create one master file that contains its settings, and then include it in your PHP 
scripts? If you need to change details later on, you can do it in one file instead of 
several files. This is also very useful when you need to use other constants and 
functions throughout multiple scripts. 
 
なぜ、設定を取得するところすべてでデータベースコネクションを張るのではなく、設定情報を
保持するマスターファイルを作ってそれをPHPスクリプトからincludeするようにしないのでしょ
うか? あとから詳細を変更する必要があっても、複数個のファイルではなく一つのファイルの変
更でそれが可能です。これは複数のスクリプトで他の定数や関数を使う必要があるときに
とても便利です。


Using a config file is a popular web application pattern that makes your code more 
modular and easier to maintain. 

config ファイルを使うことは、あなたのコードをより modular にして保守を容易にする
poplar な web アプリケーションパターンです。


3. Always Sanitize Data That Will Go into Your Database 
   あなたのデータベースに格納されるデータは常にサニタイズしよう

SQL injections are more common that you may think, and unless you want a big headache 
later on, sanitizing your database inputs is the only way to get rid of the problem. 
The first thing you should do is learn about popular ways your app can be compromised 
and get a good understanding of what SQL injections are; read about examples of SQL 
injection attacks and check out this SQL injection cheat sheet. 

SQL インジェクションはあなたが考えているよりもずっと一般的なもので、後になってから痛い思いを
したいのでなければデータベースの入力をサニタイズすることがこの問題を取り除く唯一の方法です。
あなたがまずすべきことは  popular ways your app can be compromised について学び、
そして SQL インジェクションがどういったものなのかをきちんと理解することです。
SQLインジェクション攻撃の例を読み、
SQLインジェクションのカンニングペーパーをチェックしましょう。

Luckily, there's a PHP function that can help make a big heap of the problem go away: 
mysql_real_escape_string. mysql_real_escape_string will take a regular string (learn 
about data types through this PHP variables guide) and sanitize it for you. If you use 
the function together with htmlspecialchars, which converts reserved HTML characters 
(like <script> becomes &lt;script&gt;), not only will your database be 
protected, but you'll also safeguard your app against cross-site scripting (XSS) 
attacks when rendering user-submitted HTML (such as those posted in comments or forum 
threads). 

幸運なことに、a big heap of the problem を取り除くのを手助けしてくれる PHP 関数
mysql_real_escape_string があります。この mysql_real_escape_string は普通の文字列を受け取り
(learn about data types through this PHP variables guide)、
それをあなたのためにサニタイズしてくれるのです。
この関数を、予約された HTML キャラクターを(<script> becomes &lt;script&gt; のように)
変換する htmlspecialchars と一緒に使えば、あなたのデータベースを守るだけでなく
(posted in comments or forum threads のような) 
ユーザーが submit したHTML をレンダリングするときの
クロスサイトスクリプティング(XSS)攻撃からも安全にすることになります


4. Leave Error Reporting Turned On in Development Stage 
   開発段階ではエラーレポート機能を有効にしておこう

Looking at the PHP White Screen of Death is never helpful except for knowing something 
is definitely wrong. When building your application, leave error_reporting and 
display_errors turned on to see run-time errors that will help you quickly identify 
where errors are coming from. 
 
PHP の White Screen of Death (師の白画面) を見ることは、
何かが決定的に間違ったということがわかること以外にはなんの助けにもなりません。
アプリケーションを構築するときに leave error_reporting と display_errors を
実行時エラーを見るように設定することで、エラーがどこで起こったのかを素早く特定
するのが楽になるでしょう。


You can set up these run-time configurations in your server's php.ini file or, if you 
don't have access to override the directives in this file, set them on top of your 
PHP scripts (using the ini_set() function to set display_errors to 1, but it has its 
limitations when done this way). 

サーバーにある php.iniファイルを使ってこういった実行時コンフィグレーションをセットアップできます。
このファイルに書かれているディレクティブを上書きする権利を持っていないのであれば、
それらの設定値を PHP スクリプトの先頭に置いても良いです
ini_set() 関数を使って display_errors を 1にセットしようとしても
この関数はそういった使い方をするときに制限があります)。


The reason behind turning on error reporting is quite simple — the sooner you know 
about your errors, the faster you can fix them. You might not care about the warning 
messages that PHP might give you, but even those usually signal towards a 
memory-related issue that you can take care of. When you're done building out your 
application, turn error_reporting and display_errors off or set their values to a 
production-ready level. 

エラーレポートを有効にする理由は極めて単純で、エラーについて早く知れば知るほどそれに
対処するのも早くなるからです。
PHP が出す警告のメッセージをあなたは気にも留めないかもしれませんが、
そういったよくあるシグナル (usually signal) でさえ、
注意を払えるようなメモリーに関する issue に toward しているのです。
自分のアプリケーションを組み上げ終えたときには、
error_reporting と display_errors をオフにするか
それらの変数の値を production-ready なレベルにセットしましょう。



5. Don't Over-Comment Your Code 
   コードにコメントをつけすぎないようにしよう

Proper documentation of your code through comments in your scripts is definitely a 
good practice, but is it really necessary to comment every single line? Probably not. 
Comment the complicated parts of your source code so that when you revisit it later 
you'll quickly remember what's going, but don't comment simple things such as your 
MySQL connection code. Good code is self-explanatory most of the time. 

コードに対する適切なドキュメンテーションは definitely な good practice ですが、
一行一行すべての行にコメントをつける必要があるでしょうか? おそらくそうではありません。
ソースコードの複雑な部分にコメントすることは、
あとで見返したときに何をしようとしているのかを即座に思い出せるようにしますが、
MySQL connection code のような単純なことについてコメントをつけてはいけません。
良いコードとは self-explanatory most of the time です。


Good Example of Commenting 
良いコメントの例

<?php 
 
 /* CONNECT TO THE DATABASE */ 
 
 $hostname = "localhost"; 
 $username = ""; 
 $password = ""; 
 $dbname = ""; 
 
 $connectionStatus = mysql_connect($hostname, $username, $password) or die(mysql_error()); 
 $selectionStatus = mysql_select_db($dbname) or die(mysql_error()); 
 
 /* END DATABASE CONNECTION */ 
 
?> 
 
Bad Example of Commenting 
悪いコメントの例

<?php 
 
 /* DEFINE THE CONNECTION VARIABLES */ 
 $hostname = "localhost"; // Hostname 
 $username = ""; // Username 
 $password = ""; // Password 
 $dbname = ""; // Database name 
 // Connect to the database or display an error 
 $connectionStatus = mysql_connect($hostname, $username, $password) or die(mysql_error()); 
 // Select our database here 
 $selectionStatus = mysql_select_db($dbname) or die(mysql_error()); 
 
?> 


6. Keep Favorite Code Snippets Handy
   好みのコード片をキープしておこう
 
You'll be coding a lot of the same things throughout your PHP development career, and 
keeping code snippets always available will help you save a lot of time. There are 
several apps that can keep and sync your code snippet collection for you, so no matter 
where you are, you can always have your snippets available. Some apps you can use to 
corral your code snippets are Snippet, snippely, Code Collector, and Snipplr 
(web-based). 

あなたは自分の PHP development のキャリアを通じて同じこと (same things) を何度となくコ
ーディングすることになるでしょう。そして、いつでも利用できるようにコード片をキープして
おくことは大いにあなたの時間を節約してくれるでしょう。コード片のコレクションの keep 
and sync ができるいくつかのアプリケーションがあります。ですからあなたがどこにいるのか
は重要ではなくて、いつでも自分のコード片を利用できます。コード片を corral するのに使える
ソフトウェアとしては Snippet、snippely、Code Collector、Snipplr (web ベース) などがありま
す。


Most integrated development environments (IDEs) such as Eclipse (which can store code 
templates) and Dreamweaver (via the Snippets Panel) may have built-in features for 
storing code snippets. 

(コードテンプレートに格納可能な) Eclisse や (Snippets Panelを通じた) Dreamweaver 
のように最も integrate された開発環境は
コード片を格納する組み込み機能を持っているかもしれません。


Even a simple and well-organized directory called snippets that contain text files (or 
PHP scripts) — and possibly synced in the cloud using an app like Dropbox if you use 
multiple computers — can do the trick. 

テキストファイル (もしくは PHPスクリプト) を格納した snippets  と呼ばれる
単純かつ well-organized ディレクトリでさえ
- and possibly synced in the cloud using an app like Dropbox if you use multiple computers -
こういった trick を行えます。


7. Use a Good Source Editor to Save You Time 
   時間を節約するために良いソースエディターを使おう

Your editor is where you'll spend the majority of your time, so you want to use 
something that helps you save time. Syntax highlighting is a must and definitely 
something you should be looking for as a software feature. Other bonuses include code 
hinting, code navigation and built-in debugging tools. All of these features can end 
up saving you massive amounts of time. An example of a source code editor/IDE for PHP 
is phpDesigner. 
 
エディターはあなたが多くの時間を費やすものです。ですから、時間を節約できるようなものを
使いましょう。構文ハイライト機能はエディターの機能として必須とも言うべきものです。その
ほかあると良い機能にはコードヒント機能やコードナビゲーション機能、組み込みのデバッグツ
ールなどがあります。こういった機能はすべてあなたが時間を大幅に節約するのを手助けするも
のです。ソースコードエディターや IDE の例としては phpDesigner があります。

Use a Good Source Editor to Save You Time 

時間を節約するために良いソースエディターを使おう

Take the time to get familiar with your source code editor's features by reading the 
documentation and reading tutorials online. A bit of time investment in this arena can 
really streamline your coding workflow. 

ドキュメントやオンラインチュートリアルを読むことで
使っているソースコードエディターの機能になじむための時間を取りましょう
この arena での investment にちょっとだけ時間を掛けることは
コーディングのワークフローを目に見えて能率良くします。

Check out this list of source code editors for developers as well as this list of free 
text editors for coders to discover popular code-editing applications. 

Check out this list of source code editors for developers
as well as this list of free text editors for coders to discover popular code-editing applications. 


8. Use a MySQL Administration Tool (Like phpMyAdmin) 
   MySQL の Administration ツールを使おう

I know some crazy hard-core developers who like working with MySQL (the popular 
Database Management System pairing for PHP) via command line, which, to me, is 
inefficient and just, well, crazy. It's a good thing to know how to administer your 
MySQL database using mysqladmin, but afterwards, you should use a graphical user 
interface like phpMyAdmin to speed up database development and administration. 

コマンドラインから (よくPHPと一緒に使われるデータベースマネージメントシステムである)
MySQL を使うのを好むような crazy hard-core developers がいることを知っています。
わたしにとってそんなやり方は非効率的で、まさしくなんというか crazy なものです。
mysqladmin を使って MySQLデータベースをどのように管理するかを知ることはよいことです。
but afterwards,
you should use a graphical user interface like phpMyAdmin to speed up database development and administration. 
データベース開発や管理のスピードを上げるために
phpMyAdmin のようなグラフィカルユーザーインターフェースを使うべきです。


Use a Good Source Editor to Save You Time 
時間を節約するために良いソースエディターを使おう

phpMyAdmin, in particular, is an excellent open source database viewer/manager that 
allows you to view your MySQL databases graphically so that you don't have to waste 
time doing things via the command line. You can quickly build databases and their 
tables, export your databases into SQL files, run SQL queries, optimize tables, check 
for issues, create MySQL database users and set up their privileges quickly, and much 
more. There is a good chance your web host already has phpMyAdmin installed, and if 
not, it only takes minutes to install. 

特に phpMyAdmin は素晴らしいオープンソースデータベース viewer/manager です
MySQL データベースをグラフィカルに見せることで
コマンドラインから操作して時間を浪費させることのない
即座にデータベースとそのテーブルを構築でき
データベースを SQL ファイルへと export できます
SQLクエリを実行し
テーブルを最適化し

使っているwebホストにすでにphpMyAdmin がインストールされていれば
良い機会ですし、もしインストールされていなくても
インストールにはほんの数分しか要しません。

Check out this list of the best MySQL database management tools and this list of MySQL 
apps for alternatives to phpMyAdmin. 



9. Use a PHP Framework 
   PHP フレームワークを使おう

It took me a really long time to accept the fact that using a web application 
development/rapid application development framework would help me out. You have a 
small learning curve in the beginning, and there will be a lot of reading to do to 
learn how the API of the framework works, but you get amazing productivity and 
efficiency benefits later. Using a framework forces you to use better web development 
patterns that you might not be using right now. 

わたしにとって、web アプリケーション開発フレームワークや
rapid アプリケーション開発フレームワークを使うことが自分を助けるであろう
という事実は、受け入れるには本当に長い時間が掛かりました。
You have a small learning curve in the beginning,
and there will be a lot of reading to do to learn how the API of the framework works,
but you get amazing productivity and efficiency benefits later.

フレームワークを使うことはこれまで使ってこなかったかもしれないより良い web 開発パターンを使うのを強制します。


Using a PHP framework pays off big time when you have to share your code with others 
later on or when you have to work together with someone; it gives you a standardized 
platform for building web applications. I learned the importance of this the hard way 
when I had to start hiring other developers. 

PHP のフレームワークを使うことは、あなたが自分のコードを後になって他人と共有しなければなら
なくなったときや誰かと一緒に作業しなければならなくなったときに大きく時間を pays offします。
フレームワークを使うことは、 web アプリケーションの構築に対して標準化されたプラットフォーム
を与えるのです。わたしは他の開発者を雇うようになったときにこの hard way の重要性を学びました

CakePHP 

Some popular PHP frameworks are CakePHP, CodeIgniter, symfony, and Zend.

ポピュラーなPHPフレームワークには CakePHP、CodeIgniter、symfony、Zend といったものがあります。


10. Connect with Other PHP Developers 
    ほかの PHP developer たちと結びつこう

You don't know it all. And even if you think you do, there are thousands of others 
out there that know how to do something better than you do. Join a PHP community like 
PHPDeveloper and interact with others. By connecting with other developers, you'll 
learn better ways of doing the things you're currently doing. 

あなたはすべてを知っているわけではありません。自分はすべてを知っているのだと考えていた
としても、なにかをあなたよりもずっと良くできる方法を知っている人が何千人といます。
PHPDeveloper のようなコミュニティに参加して他の人たちと対話しましょう。他の開発者たち
とつながることで、あなたが今行っていることをもっと良くやる方法を学ぶことができるでしょ
う。


■_

昨日の Python 版に対抗? して

Rubyで末尾再帰最適化をする。 - athosの日記

(略)
その後、Scheme版をだいたいそのままRubyに書き直したのが以下のRuby版です。 
 
class Module 
  def tco(name) 
    continue = [] 
    first = true 
    arguments = nil 
 
    private_name = "private_" + name.to_s 
    alias_method private_name, name 
    private private_name 
 
    proc = lambda do |*args| 
      if first 
        first = false 
        while true 
          result = send(private_name, *args) 
          if result.equal? continue 
            args = arguments 
          else 
            first = true 
            return result 
          end 
        end 
      else 
        arguments = args 
        continue 
      end 
    end 
    define_method name, proc 
  end 
end 
 
ここで定義した tco というクラスマクロを以下のように使います。 
 
class Sum 
  def sum1(n, acc=0) 
    if n == 0 
      acc 
    else 
      sum1(n-1, acc+n) 
    end 
  end 
 
  def sum2(n, acc=0) 
    if n == 0 
      acc 
    else 
      sum2(n-1, acc+n) 
    end 
  end 
  tco :sum2 # ←コレ 
end 

(略)

実装としては、メソッドの呼び出しを置き換えるのに、Pythonのデコレータの代わりにアラウン
ドエイリアスを使ってます。アラウンドエイリアスの他にもメタプログラミングRubyで紹介され
ているテクニックをいくつか使わせてもらいました。メタプログラミングRuby素晴らしい! 
 

なるほどん。 基本的な制御フローは同じですね。

Twitter / @podhmo: 昨日のpythonの末尾最適化の話、トランポリンなの ...

昨日のpythonの末尾最適化の話、トランポリンなのでjsでもできますね。 
https://gist.github.com/786160
function tco(g){
    //arguments
    g.__first = true;
    g.__cont = {};
    g.__original = g
    g.__tco = function (){
        var r;
        if(g.__first){
            g.__first = false;
            for(;;){
                var r = g.apply(this,arguments)
                if (g.__cont === r){
                    arguments = g.__args //update arguments
                } else {
                    g.__first = true;
                    return r;
                }
            }
        } else {
            g.__args = arguments;
            return g.__cont;
        }

gist: 784338 - GitHub ;; 「Pythonで末尾再帰最適化をする。」のScheme版

■_

2011年01月18日

■_

97きのこ本のイベントで、日本人プログラマーに同様のものを書いてもらったのを 読みたいとかいう意見が割りとあったようです。 会場で意見を述べたのは一人でしたがまあ雰囲気的に。

きのこ本も元は web に投稿されたものの集まりだし、 そういうサイトを作ってみてもいいんじゃないですかね。 って実際書いて投稿する人がどれだけ(一人で複数本がありとしても)いるか。かなあ。

自分が書くとしたら「封筒裏の計算」ネタかなあ。 二ページ分できちんと書けるのかまったく自信もないけど(笑)

■_

97きのこ本のイベントでも技術的負債 (Technical Debt) の話題がでましたが、 「負債」というのは正しくないだろうというご意見。


Bad code isn't Technical Debt, it's an unhedged Call Option | Steve Freeman

Steve Freeman

Working software daily

Bad code isn't Technical Debt, it's an unhedged Call Option
出来の悪いコードは技術的負債ではなく、ヘッジされていない Call Option だ

Written on 23 Jul 2010

I'd been meaning to write this up for a while, and now Nat Pryce has written up the 
140 character version.

I'd been meaning to write this up for a while,
and now Nat Pryce has written up the 140 character version.


Payoff from writing a call.

This is all Chris Matts' idea. He realised that the problem with the “Technical Debt” 
metaphor is that for managers debt can be a good thing. Executives can be required to 
take on more debt because it makes the finances work better, it might even be 
encouraged by tax breaks. This is not the same debt as your personal credit card. 
Chris came up with a better metaphor, the Call Option.

これはすべて Chris Matts のアイデアです。
彼は、マネージャーたちが “Technical Debt” metaphor を
debt が good things にできてしまう問題を詳らかにしました。
finances を work better させるので、
executive たちは一層の debt を take するように要求できるのです。
そしてそれは tqax breaks (脱税?) によってさえ促進されるかもしれません。
Techinical debt はあなたの個人的なクレジットカードと同じ debt ではありません。
Chris はより良い metaphor である the Call Option を見出しました。

I “write” a Call Option when I sell someone the right, but not the obligation, to 
buy in the future an agreed quantity of something at an price that is fixed now. So, 
for a payment now, I agree to sell you 10,000 chocolate santas1 at 56 pence each, at 
any time up to 10th December. You're prepared to pay the premium because you want to 
know that you'll have santas in your stores at a price you can sell.

From my side, if the price of the santas stays low, I get to keep your payment and I'm 
ahead. But, I also run the risk of having to provide these santas when the price has 
rocketed to 72 pence. I can protect myself by making arrangements with another party 
to acquire them at 56 pence or less, or by actually having them in stock. Or, I can 
take a chance and just collect the premium. This is called an unhedged, or “Naked”, 
Call. In the financial world this is risky because it has unlimited downside, I have 
to supply the santas whatever they cost me to provide.

わたしの側からすると、もしsantasの価格が低いままであれば

Call options are a better model than debt for cruddy code (without tests) because they 
capture the unpredictability of what we do. If I slap in an a feature without cleaning 
up then I get the benefit immediately, I collect the premium. If I never see that code 
again, then I'm ahead and, in retrospect, it would have been foolish to have spent 
time cleaning it up.

テストのない cruddy code (汚いコード) に対して、Call options は「負債」よりも良いモデルです。
それは (Call option が) unpredictability of what we do を capture するからです。


On the other hand, if a radical new feature comes in that I have to do, all those 
quick fixes suddenly become very expensive to work with. Examples I've seen are a big 
new client that requires a port to a different platform, or a new regulatory 
requirement that needs a new report. I get equivalent problems if there's a failure I 
have to interpret and fix just before a deadline, or the team members turn over 
completely and no-one remembers the tacit knowledge that helps the code make sense. 
The market has moved away from where I thought it was going to be and my option has 
been called.

Even if it is more expensive to do things cleanly (and I'm not convinced of that 
beyond a two-week horizon), it's also less risky. A messy system is full of unhedged 
calls, each of which can cost an unpredictable amount should they ever be exercised. 
We've all seen what this can do in the financial markets, and the scary thing is that 
failure, if it comes, can be sudden—everything is fine until it isn't. I've seen a few 
systems which are just too hard to change to keep up with the competition and the 
owners are in real trouble.

So that makes refactoring like buying an option too. I pay a premium now so that I 
have more choices about where I might take the code later. This is a mundane and 
obvious activity in many aspects of business—although not, it seems, software 
development. I don't need to spend this money if I know exactly what will happen, if I 
have perfect knowledge of the relevant parts of the future, but I don't recall when I 
last saw this happen.

So, the next time you have to deal with implausible delivery dates, don't talk about 
Technical Debt. Debt is predictable and can be managed, it's just another tool. Try 
talking about an Unhedged Call. Now all we need is a way to price Code Smells.


1) There is an apocryphal story about a trader buying chocolate santa futures and 
forgetting to sell them on. Eventually a truckload turned up at the Wall Street 
headquarters.

Filed in: Agile Programming, Software culture. 

この option ってカタカナ書きの「オプション」でいいのかな。 金融関係は良くわからん。

とにかく、「負債」とは違って、「値が上がる」ことも「値を下げる」こともあるのだから オプションみたいなものでしょう。ということなのかしらん。

■_ でこれーたー

色々使い道?があるのねえ。

Pythonで末尾再帰最適化をする。 - IT系で覚醒めたい

ちょっとスクリプトをいじって、フローを把握できるように(見づらいけど)してみた。

class tail_recursive(object):

    def __init__(self, func):
        self.func = func
        self.firstcall = True
        self.CONTINUE = object()

    def __call__(self, *args, **kwd):
        print "__call__"
        if self.firstcall:
            print "firstcall"
            func = self.func
            CONTINUE = self.CONTINUE
            self.firstcall = False
            try:
                while True:
                    print "func(%d)" % args[0]
                    result = func(*args, **kwd)
                    if result is CONTINUE: # update arguments
                        print "CONTINUE"
                        args, kwd = self.argskwd
                    else: # last call
                        print "return"
                        return result
            finally:
                self.firstcall = True
        else: # return the arguments of the tail call
            print "else: %d %d" % args[0:2]
            self.argskwd = args, kwd
            return self.CONTINUE


@tail_recursive
def sum(n, acc=0):
    if n == 0:
        print "sum(0)"
        return acc
    else:
        print "sum(%d, %d)" % (n, acc)
        return sum(n-1, acc+n)
sum(5)

>python moge.py
__call__
firstcall
func(5)
sum(5, 0)
__call__
else: 4 5
CONTINUE
func(4)
sum(4, 5)
__call__
else: 3 9
CONTINUE
func(3)
sum(3, 9)
__call__
else: 2 12
CONTINUE
func(2)
sum(2, 12)
__call__
else: 1 14
CONTINUE
func(1)
sum(1, 14)
__call__
else: 0 15
CONTINUE
func(0)
sum(0)
return

再帰呼び出しがデコレーターの呼び出しにすりかわって、 呼び出しのネストが深くならないようになってるのね。ふむ。

ところで

Pythonで末尾再帰最適化をする。 - IT系で覚醒めたい

はっきりいってなんでこれがそんなすごいことやってくれるのか初めは訳が分かんなかったんで
すが、これPythonのダイナミックスコープによって実現されてるんですよね。オソロシヤ。

…ダイナミックスコープ?

Pythonで相互再帰の末尾再帰最適化もできた - IT系で覚醒めたい

■_ 来月の新刊

O'Reilly Japan News 第156号                       2011-1-18
(略)
■Coming Soon

来月発売予定の書籍情報です。2月は以下の7点。鋭意制作中につき、
楽しみにお待ちください。
-----------------------------------
●ビューティフルデータ

* Toby Segaran、Jeff Hammerbacher 編
* 堀内 孝彦、真鍋 加奈子、苅谷 潤、小俣 仁美、篠崎 誠 訳
* ISBN978-4-87311-489-7
* 定価3,570円(税込)
-----------------------------------
●Androidアプリケーション開発ガイド
HTML+CSS+JavaScriptによる開発手法

* Jonathan Stark 著
* 増井 俊之 監訳
* 牧野 聡 訳
* ISBN978-4-87311-486-6
* 定価1,995円(税込)
-----------------------------------
●入門 HTML5

* Mark Pilgrim 著
* 矢倉 眞隆 監訳
* 水原 文 訳
* ISBN978-4-87311-482-8
* 定価2,415円(税込)
-----------------------------------
●Java: The Good Parts

* Jim Waldo 著
* 矢野 勉 監訳
* 笹井 崇司 訳
* ISBN978-4-87311-487-3
* 定価2,310円(税込)

-----------------------------------
●JavaScriptパターン
優れたアプリケーションのための作法

* Stoyan Stefanov 著
* 豊福 剛 訳
* ISBN978-4-87311-488-0
* 定価2,940円(税込)

-----------------------------------
●Mathematicaクックブック

* Sal Mangano 著
* 松田 裕幸 訳
* ISBN978-4-87311-483-5
* 定価4,410円(税込)
-----------------------------------
●プログラミング Windows Azure

* Sriram Krishnan 著
* マイクロソフト株式会社 監訳
* 玉川 竜司 訳
* ISBN978-4-87311-480-4
* 定価3,780円(税込)


Mathematicaクックブック 出るのかあ。 本体買うあてもないのにこれは買ってしまうかもしれない(笑) ビューティフルデータも要チェックだな。

■_

■_

このネタを考えながら寝るとしよう。

2011-01-18 - Ruby親方

さくっと配列をランダムに半分に割りたいんだけど、いい方法はないものか。
 
ary1にデータを入れといて、 
 
ary2=[] 
(0..(ary1.size/2-1)).each{|n|d=ary1[rand(ary1.size-1)];ary1.delete(d);ary2<<d} 
 
なんだかものすごくカッコ悪いんだけど。 
 
(一応、ユニークなデータであるという前提です。)

2011年01月17日

■_

む。ボールペンの話やら書こうと思ってたが時間がががが。

■_

記憶を辿ると、「エンディアンネス」という言葉に遭遇したのは Cマガジンにあった、フィンローダさんかきだあきらさんの書いた記事だったような気がします。 とすると、90年代前半から中頃という可能性が大きいですね、

英語圏でも使われてる(ようになった)という話を聞いてもあまり使う気にはなれなかったりして(笑)

英語、で思い出したのですが、以前北米某所に数ヶ月行っていたときに EPROM にプログラムを焼き付ける作業があったのですけど 「ROMを焼く」とまったく同じに「Burn the ROM」とか言うのですね。 初めて聞いたときにはちょっとびっくりしました。 ってまあ CD-R などのライタープログラムのメニューを見れば 「burn」ってありましたっけか。

■_ 優れた Perl プログラマーの見分け方

How to Identify a Good Perl Programmer - Modern Perl Books, a Modern Perl Blog
Modern Perl Books, a Modern Perl Blog 

How to Identify a Good Perl Programmer 

By chromatic on January 16, 2011 1:10 PM 
 
The article Why You Can't Hire Great Perl Programmers addressed the core Perl community.
We need to encourage Perl dabblers to improve their skills and to join the community. 
 
Several commenters noted that the article did not address the employer side of hiring. 
Certainly an employer offering $15 an hour for Perl programmers in Silicon Valley or 
New York City or Chicago or Seattle will have to work much harder to entice great 
programmers than someone paying competitive wages. 

(さくっと略)


 * What do variable sigils indicate in Perl 5?
   Perl 5 で変数の sigils が示しているものは何?

 * What's the difference between accessing an array element with $items[$index]
   and @items[$index]?
   $item[$index] と @item[$index] とのアクセス時の違いはなに?

 * What's the difference between == and eq?
   == と eq の違いはなに?

 * What do you get if you evaluate a hash in list context?
   リストコンテキストでハッシュを評価したときの結果はどうなる?

 * How do you look up keywords in the Perl documentation?
   Perl のドキュメントからどうやってキーワードを見つけ出す?

 * What is the difference between a function and a method in Perl 5?
   Perl 5における関数とメソッドの違いとは?

 * When does Perl 5 reclaim the memory used by a variable?
   
 * How do you ensure that the default scope of a variable is lexical?
   変数のデフォルトのスコープを lexical にするには?

 * How do you load and import symbols from a Perl 5 module?
   Perl 5 モジュールからどのようにしてシンボルをロードしたりインポートする?

 * What governs how Perl 5 loads modules How can you influence the list of directories
   from which perl attempts to load modules?

 * How do you look up error messages in the Perl 5 documentation? (Award bonus points
   for knowing how to enable explanations of all error messages encountered.)

 * What happens when you pass an array into a function?
   関数に配列を渡したときに何がおきる?

 * How do you pass one or more distinct arrays into a function?
   関数にひとつ以上の別個の配列を渡すには?

 * What is the difference, on the caller side, between return; and return undef;?
   呼び出し側から見たときの、return; と return undef; の違いとは?

 * Where do tests go in a standard CPAN distribution?

 * How do you run tests in a standard CPAN distribution?

 * What command do you use to install new distributions from the CPAN?

 * Why would you use the three-argument form of the open builtin?
   なぜ三引数形式の oepn を使うのが好ましいのか?

 * How do you detect (and report) errors from system calls such as open? (Award bonus
   points for knowing how to enable automatic detection and reporting of errors.)

 * How do you throw an exception in Perl 5?
   Perl 5 で例外を送出するには「

 * How do you catch an exception in Perl 5?
   Perl 5 で例外を捕捉するには?

 * What is the difference between reading a file with for and with while?
   ファイルからの読み込みを for で行うのと while で行うのとでの違いとは?

 * How do you handle parameters within a method or function in Perl 5?
   Perl 5において、メソッドや関数のパラメータをどのように扱うのか?

 * What do parentheses around the variable name in my ($value) = @_; mean, and what
   would happen if you removed them?
   my ($value) = @_; のように変数名を囲むカッコは何をしているのか? また、
   それを取り除いた場合はどうなのか?

 * Is new a builtin function/keyword?

 * How do you read the documentation of a core library? A CPAN module?

 * How do you access only the values of a Perl 5 hash? 
 
None of these are trick questions. All of them have simple, unambiguous answers that 
demonstrate a solid understanding of Perl 5, its philosophy, and its practical use. A 
good Perl 5 programmer should be able to answer at least 80% of these questions with 
no trouble. These are not the only questions a good Perl programmer should be able to 
answer, but anyone who can't answer these questions with ease needs to study more Perl. 

略

Powered by Movable Type 
This blog is licensed under a Creative Commons License. 

How to Identify a Good Perl Programmer : perl

別言語版考えた人はよろしく :)

■_ Scala levels

Scala levels: beginner to expert, application programmer to library designer | The Scala Programming Language

Scala levels: beginner to expert, application programmer to library designer 

Created by odersky on 2011-01-16. Updated: 2011-01-16, 17:35 
 
Scala is a bit of a chameleon. It makes many programming tasks refreshingly easy and 
at the same time contains some pretty intricate constructs that allow experts to 
design truly advanced typesafe libraries. This means that, depending at what piece of 
code you look at, Scala might look very simple or very complex. But which pieces 
exactly are easy for beginners and which are more advanced? In the end, everybody will 
have their own yardstick. Nevertheless, I am trying here to give a rough 
categorization. 
 
I hope this will help newcomers to the language decide in what order to pick subjects 
to learn, and that it will give some advice to teachers and book authors in what order 
to present the material. 
 
I assume that programmers have already a good knowledge of Java, so we can take at 
least pre-generics Java 1.4 for granted. If that's not the case, some of the 
entry-level concepts such as classes and exceptions would need to be moved to more 
advanced levels. 
 
Also, I distinguish between Scala application programmers and Scala library designers, 
because the required skill sets are really quite different. A first shot at a 
categorization has been discussed last month on the scala-debate mailing list. The 
current categorization incorporates some of the suggestions that were made then. So, 
here we go: 
 
Level A1: Beginning application programmer 
 
 * Java-like statements and expressions: standard operators, method calls, conditionals,
   loops, try/catch 
 * class, object, def, val, var, import, package 
 * Infix notation for method calls 
 * Simple closures 
 * Collections with map, filter, etc 
 * for-expressions 
 
Level A2: Intermediate application programmer 

 * Pattern matching 
 * Trait composition 
 * Recursion, in particular tail recursion 
 * XML literals 
 
以下略

Copyright © 2011 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland 

■_

2011年01月16日

■_

・浅井長政
わしが中学生の頃は「あさいながまさ」だったような気がするけど 今は「あざいながまさ」なのね(いやまあ当時から「あざい」が正しいのは聞いてたけど)。

「ナンバーカード」ってしっくりこないんです! とか。

・ムダヅモなき改革
…最終回? (予告ではそうだったけどさあ) しかし「野生の証明」か。

97きのこ webkit

・日本橋丸善
久しぶりに行ってきた。今はもう理工学書の洋書は扱ってないそうな。 (ぴー)年前はここまで出かけてきて、いつの円ドルレートなんだって値段のついた プログラミングの本を何時間も悩んでから買ってたりしたんだよなあ(遠い目) まあ、安く買えるって点ではAmazonさんにはいくら感謝しても足りない。

んで、ザ・クオンツの原書を洋書売り場で見かけたのだけど、 翻訳版と表紙を見比べると原著のほうが作品の内容を端的に表現できていると思うなあ。
ザ・クオンツ  世界経済を破壊した天才たち The Quants: How a Small Band of Maths Wizards Took Over Wall Street and Nearly Destroyed it

「The Quants」で検索したらこんなんが引っかかったけどなんだろこれ。
The Quants: How a New Breed of Math Whizzes Conquered Wall Street and Nearly Destroyed It The Quants: How a New Breed of Math Whizzes Conquered Wall Street and Nearly Destroyed It

・買った
銀座まで出かけてこれを購入。
LAMY【ラミー】 ボールペン pico(ピコ) L284 プラチナコート
LAMY【ラミー】 ボールペン pico(ピコ) L284 プラチナコート
軸の短いボールペンはいろいろ試しているのだけどこれというのが見つからなくて (そこそこ満足いくのはあった)、値段にちょっと引いたけどえいやで買ってしまった(笑) 本当は実物を見て、Amazonさんでぽちっとなしようかと思ったんだけど(安いから) あまりそういうのもよろしくなかろうということで伊東屋で購入。 第一印象はとても良かったけど(だからこそ買った)、しばらく使ってみてさてどうか。

で、LAMYのボールペンと同じフロアにあったものをいろいろ眺めてて、 電卓がちと気になった。 が、このネタは明日以降に引っ張ろう(笑)

・十進BASIC
数としてはそれほど多くはないのだけど、どうみても課題の類と思われる 十進BASICでのプログラミングについての質問を知恵袋やらOKWaveで 見かけることがあるのは、どこかで教材に使っていたりするんだろうか (そもそもの出自がそんな感じでしたよね)。

■_

リツイートもかなりされているようですが、あえて twitter ではなくこちらで紹介。 Twitter / @Jeffrey Angles: 【お願い!】古書を寄付して下さい!私の教えている西ミ ... で、このツイートにあるリンクの先から

西ミシガン大学図書館に古書を寄付してください。

アメリカの中西部にある大学、西ミシガン大学で日本文学と翻訳論を教えているジェフリー・ア
ングルスと申します。西ミシガン大学では、この数年間、日本語を勉強している学生も日本から
来ている留学生も急増しておりますが、日本語の本が図書館にほとんどありません。そのため、
日本語を勉強しているアメリカの学生は解読能力が充分身についていない状況が続いております。 

自動車産業が経済的なベースだったミシガン州は、アメリカの中でとても経済的に困難な州なの
で、残念ながら、新本を大量に購入する予算はございません。日本では活字ばれの時代になって
いるとよく言われていますが、活字の面白さと日本文化の素晴らしさをどうしても学生に紹介し
たいと思い、是非に皆様のご協力をお願いしております。 

日本の理解と日本語の能力を上げるために、只今大学のために日本語の本を集めております。私
は2011年3月の冒頭まで東京大学の客員准教授として日本におりますので、その間になるべくい
ろいろな本を集めております。 

使っていらっしゃらない本、寄付できる本がありましたが、2011年3月1日までに私の東京の住所
に送って下されば、私はアメリカに転送致しまして、西ミシガン大学図書館にお入れします。お
名前を本の中に寄付者としてお書きしまして、大学図書館からも礼状が送られます。 

特にこのような本が役に立ちます。文庫本でも、ペーパーバックでも、ハードカバーでも歓迎致
します。 

· 大衆文学:推理小説、恋愛小説、ホラー小説などのいわゆる人気小説など。 
 
· 純文学:近現代の日本文学、日本古典文学など。 
 
· 文学全集:一遍にたくさん揃えるから、特に助かります。 
 
· 子供の絵本:初級レベルの日本語の学生が読めるもの。 
 
· 学生の国語教科書:初級レベルの日本語の学生が読めるもの。 
 
· 漫画:アメリカでは爆発的に人気があるから、学生がきっと面白がります。 
 
· 詩集:詩は短いから、授業では使いやすいです。 
 
· 歴史の本:日本文化を知るためにとても役に立ちます。 
 
· 芸術の本:展覧会のカタログとその他の日本の美術を紹介するもの。 
 
· 翻訳文学:日本からの留学生が読みます。 
 
2011年3月1日までに下記の住所にお送りください。 

(略)
 

ほぼ全文丸写しですが、送り先の住所などはあえて削りました。 ご自分で元記事を読んだ上で判断してください。

さてなんか出せそうなものあったかな。

■_

こういうのの管理に使うフォーマットってどういうのがいいんですかねえ。

Perl 6 module ecosystem – news and ideas 
by ttjjss on 08/01/2011 

I've looked a bit into S22 recently, and I thought it would be fun to try to implement 
some subset of it in neutro and see how it will turn out. Well done is better than 
well said, so I did. More thinking on the subject and I decided to mangle the module 
ecosystem itself a bit to suit the new capabilities nicely. I gave life to a fork of 
perl6/ecosystem. How is it different? Let's see. It no longer contains a list of the 
git repo urls, rather it keeps the urls of the META.info files known to it, and a 
script which downloads all of them and puts in a nice projects.json file containing 
all the metadata of the modules: descriptions, proper names (goodbye perl6-Acme-Meow, 
welcome Acme::Meow), dependencies, probably more eventually. But wait, what is this 
META.info magic? Let's see how it looks for neutro: 

  { 
  "name" : "neutro", 
  "version" : "*", 
  "description" : "A simple module installer for Perl 6 modules", 
  "depends" : [ "File::Tools", "Module::Tools", "JSON::Tiny" ], 
  "repo-type" : "git", 
  "repo-url" : "git://github.com/tadzik/neutro.git" 
  } 

 (略)

■_ 気にはなっていた

自分は(意識して)「バイトオーダー」のような語を使ってたんですが、 あるとき「エンディアンネス」というのを見たときひっくり返りそうに。 もっともこれ、英語圏でも使っているようなんですが (endianness) → What is Endianness?

お、こんなんあった endian(3) - Linux manual page

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

469 デフォルトの名無しさん [] 2011/01/14(金) 22:46:10 ID: Be: 
 
 
 
 エンディアン嘘つかなーい 
 
 って言いますが 
 
 ホンマでっか。 
 
 
 
474 デフォルトの名無しさん [sage] 2011/01/15(土) 11:57:45 ID: Be: 
 >>469 
 "エンディアン" という単語は存在しなーい! 
 
475 デフォルトの名無しさん [sage] 2011/01/15(土) 14:16:57 ID: Be: 
 コロンブスがアメリカ大陸見つけた時、インドに着いたと思って原住民をインディアンって呼んだだろ 
 もちろん相手側からしてみればアイデンティティ粉砕されたようなもん 
 それの引喩として、強調のために違う文字を当てて言ったんじゃないだろうか 
 
477 デフォルトの名無しさん [sage] 2011/01/15(土) 14:20:12 ID: Be: 
 何を言ってるんだ 
 
 エンディアンはエンドから来てるんだろ? 
 
478 デフォルトの名無しさん [sage] 2011/01/15(土) 14:26:27 ID: Be: 
 リリパットのとんがり帽子の向きじゃなかったっけ >エンディアン 
 

「ビッグエンディアン」「リトルエンディアン」と big/little ついているから 意味があるのであって、endian だけ切り出しても意味ないじゃんと思ってたら なんかそういう用法が生まれてしまった模様(笑)

■_ こんなところに○○さんが

いやまあ本人だという絶対的な証拠はありませんが

Bjarne Stroustrup on C++0x - CodeGuru : programming
 
Bjarne Stroustrup on C++0x - CodeGuru (codeguru.com) 
 
 
  There isn't a space between > and > in vector<pair<string,int>>. I rate this
  the smallest improvement in C++0x; it saves the programmer from having to add that "spurious"
  space (learn more about this issue here). 
 
This makes me way more excited than it should... 
 

WalterBright
 
The irony of that is that a long time ago, I modified the Digital Mars C++ compiler so 
the space wasn't necessary. I had to remove that to make it Standard compliant, now I 
can put it back in again <g>. 
 
 
Walter, can you make the following compiler hack in order to eliminate headers? 
headers are major pain-in-the-butt. 
 
 * when the compiler finds an include directive, then it checks if the header exists 
   somewhere in the include path.

 * if the header does not exist, then the compiler searches for an implementation file 
   with the same filename with the header. if the implementation file exists, then the 
   compiler extracts the header from the implementation file.

 * if the header exists, then the compiler checks its date against the implementation 
   file's date. If the implementation file is newer than the header, then a new header is 
   extracted from the implementation file and replaces the old header.
 
 * when the compiler finds a declaration in an implementation file that also exists in 
   a header file, and the declaration in the implementation file is equal to the 
   declaration in the header file, then the declaration in the implementation file is 
   silently ignored. 
 
EXAMPLE 
 
file main.cpp: 
 
 #include "foo.hpp" 
 
 main() { 
 Foo *foo = new Foo; 
 foo->bar(); 
 data = 0; 
 } 
 
File foo.cpp: 
 
 class Foo { 
 public: 
 void bar() { 
 } 
 }; 
 
 int data = 0; 
 
 static int private_data = 0; 
 
When main.cpp is compiled, the compiler does the following: 
 
 * checks if foo.hpp exists; foo.hpp does not exist. 
 * checks if foo.cpp exists; foo.cpp exists. 
 * 
 
 it opens the file foo.cpp and creates the following header file: 
 
 #ifndef FOO_HPP 
 #define FOO_HPP 
 
 class Foo { 
 public: 
 void bar(); 
 }; 
 
 extern int data; 
 
 #endif //FOO_HPP 
 
 * compiles foo.cpp, including foo.hpp silently into foo.cpp. 
 
When the declaration 'class Foo' is reached, the compiler does the following: 
 
 * compares the declaration Foo in the header and implementation. 
 * since the declarations in the header and implementation are equal, the declaration in the implementation is declared valid. 
 * The compiler creates the symbol Foo::bar from the implementation file foo.cpp. 
 
The above-described mechanism could eliminate a major c++ headache, that of headers. 
 
Template declarations would be moved to the headers automatically. 
 
The mechanism is easy to implement. 
 
 
 The mechanism is easy to implement. 
 
...and will break every C++ program that currently uses headers with the same names as 
implementation files. 
 
EDIT: The basic idea is reasonable though, but changing the semantics of #include is 
not. It could be done with "#pragma autoinclude(foo.hpp)" or similar and 
since it's then a #prama, it doesn't even violate the C++ standard. 
Agreed. "#pragma autoinclude(foo.hpp)" is a reasonable solution. 
 
Other solutions may be: 
 
 * import instead of #include 
 * include options: #include "foo.hpp" auto 
 * special include file names:#include "foo.hpp.auto" 
 
 * 固定リンク 
 * 親コメント 
WalterBright
 
Such a scheme cannot be Standard compliant, 
 
 1. macros gum up everything 
 2. dependency on order of declarations across multiple headers 
 3. name injection into namespaces 
 
and my experience is that above all else, C++ programmers want compliance. C++ is so 
complicated that any deviation from it will break their code. 

 
I don't see any of the problems you mention. What I propose is a simple copy-and-paste 
job: copy all the public declarations from the implementation file to the header file. 
 
 macros gum up everything 
 
I don't see how it is a problem. Suppose you have the following code in a .cpp file: 
 
 #include "a" 
 #include "b" 
 #define FOO(S) A(S) + B(S) 
 
The solution would simply move the macro to the header. Any dependencies the macro FOO 
may have on the other include files remain as is in the header file. 
 
 dependency on order of declarations across multiple headers 
 
Again, I see no problem about this. 
 
The copy-and-paste job, i.e. the creation of the header file would be a preprocessor 
task, not affecting the actual language compiler. 
 
 name injection into namespaces 
 
Again, I don't see how is that a problem. Any namespace defined in the implementation 
file would be transferred in the header file. 
 
 Such a scheme cannot be Standard compliant 
 
I do not see any violation of the standard. I do not propose a language change, I 
propose a way to avoid maintaining macros. 
 
Perhaps you could give us specific examples of the problems. 
 
 and my experience is that above all else, C++ programmers want compliance. C++ is so 
complicated that any deviation from it will break their code. 
 
I am not proposing any deviation from the language. 
 
I like to point out that I understand your hesitation: it is not in your best interest 
to do this, after all. You want to promote D, not enhance C++. Headers in C++ is one 
good reason to move to D, after all. 
 
WalterBright
 
Yes, I could spend some time coming up with specific examples. But that's pretty time 
consuming. I'll just say that C++ has a lot of very subtle dependencies on the order 
of declarations (carefully read what the Standard has to say about this in the 
template section, for example) and your scheme will change the order. 
 
Or you could just use the precompiled header implementation available in most quality 
C++ compilers, including Digital Mars'. In using them, however, you need to craft the 
header files carefully so they are not order dependent. 
 

■_

2011年01月15日

■_

・読んだ
旅に出よう、滅びゆく世界の果てまで。 (電撃文庫)
あるラジオで紹介されたからなんですが。 発想は面白いと思いました。展開そのものは「陳腐」といって悪ければよくあるパターンの。 と言えるかもしれませんがそれも含めて悪くはなかったと思います。 自分は二番目のエピソードが一番良かったですね。 どんなお話かはナイショ :)

■_ ruby-core

Windows と Unix ではソケットハンドルの扱いが違うという話で。

[ruby-core:34483] Windows sockets and CRT fds

Subject: [ruby-core:34483] Windows sockets and CRT fds 
From: ghazel
Date: Fri, 14 Jan 2011 12:27:48 +0900 
 
Hi, 
 
I was recently debugging a hang on the mysql2 gem. The cause turned 
out to be that the socket file descriptor from libmysql was being 
passed in to rb_thread_select(): 
https://github.com/brianmario/mysql2/blob/8c0c350c06c979c53b5eb67b95b9b313c8f297d8/ext/mysql2/client.c#L340 
 
This worked fine on linux, but on Windows rb_thread_select would never 
return. The rb_thread_select function expects CRT fds (made with 
_open_osfhandle()). Ruby win32 code goes to great lengths to redefine 
socket(), FD_SET, FD_ISSET, and a pile of other functions, so that 
extensions like EventMachine create and work with the CRT fds instead 
of the SOCKET handles transparently. However in cases like like mysql2 
and curb (which uses libcurl), the socket is created by an external 
library, and the handle is the SOCKET, not the CRT fd. Here's the curb 
case: https://github.com/taf2/curb/blob/5f223a8f2e0de3e6c0b783296ce403613ef6b795/ext/curb_multi.c#L472 
 
My question is; why does Ruby go through all this trouble on Windows? 
Why not pass around and work with SOCKET handles instead? 
 
-Greg
[ruby-core:34484] Re: Windows sockets and CRT fds

Subject: [ruby-core:34484] Re: Windows sockets and CRT fds 
From: "U.Nakamura"
Date: Fri, 14 Jan 2011 13:03:47 +0900 
 
Hello, 
 
In message "[ruby-core:34483] Windows sockets and CRT fds" 
 on Jan.14,2011 12:27:48, <ghazel / gmail.com> wrote: 
> My question is; why does Ruby go through all this trouble on Windows? 
> Why not pass around and work with SOCKET handles instead? 
 
Because, if do so, we must rewrite all ruby core functions and 
extensions which expect that socket is a kind of file descriptor. 
 
About mysql2 gem, it should know how MySQL treats Windows SOCKETs 
and how Ruby treats them. 
And it should fill in the gap. It's the work of wrapper library. 
 
 
Regards, 

[ruby-core:34485] Re: Windows sockets and CRT fds

Subject: [ruby-core:34485] Re: Windows sockets and CRT fds 
From: ghazel
Date: Fri, 14 Jan 2011 13:35:42 +0900 
 
On Thu, Jan 13, 2011 at 8:03 PM, U.Nakamura <usa / garbagecollect.jp> wrote: 
> In message "[ruby-core:34483] Windows sockets and CRT fds" 
> on Jan.14,2011 12:27:48, <ghazel / gmail.com> wrote: 
>> My question is; why does Ruby go through all this trouble on Windows? 
>> Why not pass around and work with SOCKET handles instead? 
> 
> Because, if do so, we must rewrite all ruby core functions and 
> extensions which expect that socket is a kind of file descriptor. 
 
I understand it would have to be rewritten to change it, but why was 
it written that way to begin with? Aside from the effort to change it, 
is there anything lost or gained by switching? 
 
> About mysql2 gem, it should know how MySQL treats Windows SOCKETs 
> and how Ruby treats them. 
> And it should fill in the gap. It's the work of wrapper library. 
 
Unfortunately this is quite difficult. Libraries like libmysql create 
and destroy their own sockets, so it is rarely possible to create and 
destroy a CRT fd at the same time. Creating a CRT fd when you need it 
(to pass to rb_thread_select) is fine, but closing it afterwards 
closes the underlying socket at well. Tracking the associated CRT fds 
and trying to close them when it's safe is a lot of effort, and maybe 
not possible if you don't get a destroy event. 
 
More importantly: no one has done it correctly. Every author of a ruby 
extension I can find has completely missed this subtlety of Ruby's 
Win32 code - since just treating linux fds as fds with 
rb_select_thread works fine. 
 
So, I think by switching to SOCKET handles right now, more extensions 
would start working on Windows than do today. I have yet to find one 
which would be broken by the switch. 
 
-Greg
[ruby-core:34490] Re: Windows sockets and CRT fds

Subject: [ruby-core:34490] Re: Windows sockets and CRT fds 
From: "U.Nakamura"
Date: Fri, 14 Jan 2011 15:03:23 +0900 

 
Hello, 
 
In message "[ruby-core:34485] Re: Windows sockets and CRT fds" 
 on Jan.14,2011 13:35:42, <ghazel / gmail.com> wrote: 
> I understand it would have to be rewritten to change it, but why was 
> it written that way to begin with? Aside from the effort to change it, 
> is there anything lost or gained by switching? 
 
Q: why was it written that way to begin with? 
A: Sorry, I don't know. I guess that the author might not want 
 to put many #ifdef-s into ruby core source. 
 
Q: Aside from the effort to change it, is there anything lost or 
 gained by switching? 
A: Currently the programmer of an extension library doesn't need 
 to know about Windows if the extension library is not linked 
 to outer libraries. After the switching, he must write two 
 code for Unix and Windows. Of course, if the extension library 
 depends on outer libraries which treat Unix and Windows by 
 different way, his time will decrease because of omitting 
 the code for ruby's faked FD. 
 
 
> So, I think by switching to SOCKET handles right now, more extensions 
> would start working on Windows than do today. I have yet to find one 
> which would be broken by the switch. 
 
Anyway, the patch is welcomed. 
If the patch is better enough than current, it will be applied 
naturally. (However, the timing is not certain because we must 
take care of ABI compatiblity.) 
 
 
Regards, 
-- 
[ruby-core:34509] Re: Windows sockets and CRT fds

Subject: [ruby-core:34509] Re: Windows sockets and CRT fds 
From: ghazel
Date: Sat, 15 Jan 2011 06:49:55 +0900 
 
On Thu, Jan 13, 2011 at 10:03 PM, U.Nakamura <usa / garbagecollect.jp> wrote: 
> Hello, 
> 
> In message "[ruby-core:34485] Re: Windows sockets and CRT fds" 
> on Jan.14,2011 13:35:42, <ghazel / gmail.com> wrote: 
>> I understand it would have to be rewritten to change it, but why was 
>> it written that way to begin with? Aside from the effort to change it, 
>> is there anything lost or gained by switching? 
> 
> Q: why was it written that way to begin with? 
> A: Sorry, I don't know. I guess that the author might not want 
> to put many #ifdef-s into ruby core source. 
 
win32.c and win32.h have a ton of ifdefs in them. What I'm proposing 
would remove many of them, and not add any to the rest of Ruby code. 
Who is the author of the _open_osfhandle code? 
 
> Q: Aside from the effort to change it, is there anything lost or 
> gained by switching? 
> A: Currently the programmer of an extension library doesn't need 
> to know about Windows if the extension library is not linked 
> to outer libraries. After the switching, he must write two 
> code for Unix and Windows. Of course, if the extension library 
> depends on outer libraries which treat Unix and Windows by 
> different way, his time will decrease because of omitting 
> the code for ruby's faked FD. 
 
I'm not sure which parts you're saying need to be rewritten for Unix 
and Windows. Currently there needs to be different code for Unix and 
Windows, because a socket handle you might come across on Windows has 
to be adapted to the sort of fd that ruby uses. After the hypothetical 
switch to using regular Windows sockets in Ruby, you could take a 
socket handle from anywhere and select on it in Ruby and have no 
Windows specific code (except inside of Ruby). So, I only see it 
reducing the amount of platform specific code (and bugs) in 
extensions. 
 
-Greg

この辺のコードって、元々は(当時の)Perlのコードを参考にしたんじゃなかったけか。→ Who is the author of the _open_osfhandle code? いや。CRT にあるやつかな。

Aside from the effort to change it, is there anything lost or gained by switching? これはその effort を誰が負うのよといういつもの問題になる気が。

■_ The Art of Computer Programming

なんか新刊が出たらしく。 research!rsc: Knuth, Volume 4A

4巻以降の構成よくわかんねーだよな。AだのBだの

The Art of Computer Programming

Volume 4A 
 
Combinatorial Algorithms, Part 1 (Upper Saddle River, New Jersey: Addison-Wesley, 2011), xvi+883pp. 
ISBN 0-201-03804-8 
 
(Preliminary drafts were previously published as paperback fascicles; see below.) 
The Remainder of Volume 4 
 
Present plans are for Volume 4A to be the first in a series of several subvolumes 4A, 
4B, 4C, ... entitled Combinatorial Algorithms, Part 1, 2, 3, .... The remaining 
subvolumes, currently in preparation, will have the following general outline: 
 
 * 7.2.2. Basic backtrack 
 * 7.2.3. Efficient backtracking 
 * 7.3. Shortest paths 
 * 7.4. Graph algorithms 
 * 7.4.1. Components and traversal 
 * 7.4.2. Special classes of graphs 
 * 7.4.3. Expander graphs 
 * 7.4.4. Random graphs 
 * 7.5. Network algorithms 
 * 7.5.1. Distinct representatives 
 * 7.5.2. The assignment problem 
 * 7.5.3. Network flows 
 * 7.5.4. Optimum subtrees 
 * 7.5.5. Optimum matching 
 * 7.5.6. Optimum orderings 
 * 7.6. Independence theory 
 * 7.6.1. Independence structures 
 * 7.6.2. Efficient matroid algorithms 
 * 7.7. Discrete dynamic programming 
 * 7.8. Branch-and-bound techniques 
 * 7.9. Herculean tasks (aka NP-hard problems) 
 * 7.10. Near-optimization 
 * 8. Recursion 
 

まあゆっくり構えてても良いかな?

■_

丸投げにも(厳しくそれでいて)優しいFORTRANスレ。

くだすれFORTRAN(超初心者用)その5 

457 デフォルトの名無しさん [] 2011/01/13(木) 13:52:47 ID: Be: 
 FORTRANの課題が出て〆切が月末なんだ。 
 三問ほど有償で解いてやんよって人いないか。 
 
458 デフォルトの名無しさん [sage] 2011/01/13(木) 15:36:12 ID: Be: 
 とりあえず問題晒してみそ 
 誰か解いてくれるかも 
 
460 デフォルトの名無しさん [] 2011/01/14(金) 00:02:02 ID: Be: 
 お言葉に甘えて失礼します。 
 とりあえず一問目。 
 
 「ある動物園の一日の総入園者数(1行目)と入園者の年齢(2行目以降)が 
 収納されているファイルからデータを配列に貯えて、平均年齢、及び最高年齢と最低年齢を 
 求めて出力するとともに、各年代(10歳未満、10代、20代、・・・70代、80歳以上)ごとの 
 入園者数を出力するプログラムを作れ。 
 また、平均年齢は小数点以下第1位まで示すこと。」 
 
 データはここ。 
 http://www5.plala.or.jp/selene-kw/ 
 
 宿題代行スレでないのは百も承知だが、ここ以外にFORTRAN師探せなかったんだ。 
 なにかしら反応もらえると助かる。 
 よろしくおねがいします。 
 
461 デフォルトの名無しさん [sage] 2011/01/14(金) 01:15:44 ID: Be: 
 >>459-460 
 やはり FORTRAN77 か? 90でもいいのか? 
 
462 デフォルトの名無しさん [sage] 2011/01/14(金) 02:36:05 ID: Be: 
 90でも77でもいいです 
 といってもあまり違いが分かってるわけじゃないのですが 
 
463 デフォルトの名無しさん [sage] 2011/01/14(金) 09:31:01 ID: Be: 
 >>460 
 ここは宿題スレだからスレの趣旨には合ってる 
 
464 デフォルトの名無しさん [sage] 2011/01/14(金) 10:24:33 ID: Be: 
 >>460 
 予想してたより簡単で拍子抜けしたw 
 暇ができた時にまだ誰も解いてなかったら答えるよ 
 
465 デフォルトの名無しさん [sage] 2011/01/14(金) 11:56:20 ID: Be: 
 でけた 
 年代別のところは途中で端折ったから自分で補え 
 
 program main 
 
 implicit none 
 
 integer :: i, n, decade(9) 
 integer,allocatable :: age(:) 
 
 open (99,file="ex5-3.d", status='old', action='read', position='rewind' ) 
 read (99,*) n 
 allocate ( age(n) ) 
 read (99,*) ( age(i) , i=1, n ) 
 close (99) 
 
 decade = 0 
 do i=1,n 
 if (age(i)<10) decade(1) = decade(1) + 1 
 if (age(i)>11 .AND. age(i)<20) decade(2) = decade(2) + 1 
 end do 
 
 write (*,'(a8, f5.1)') " ave = ", REAL(sum(age)) / REAL(n) 
 write (*,'(a8, i5)') " min = ", minval(age) 
 write (*,'(a8, i5)') " max = ", maxval(age) 
 
 write (*,'(a8,i5)') " 0-10 : ", decade(1) 
 write (*,'(a8,i5)') "11-20 : ", decade(2) 
 
 end program main 
 
466 デフォルトの名無しさん [sage] 2011/01/14(金) 11:57:08 ID: Be: 
 ありゃ、タブは2chじゃ無視されるんだな 
 適宜字下げしてくれ 
 
467 デフォルトの名無しさん [sage] 2011/01/14(金) 12:05:15 ID: Be: 
 あと、連続したスペースも無視されるようだから a8 の中身も適宜修正してくれ 
 intelコンパイラ、f90形式でうまくいくのは確認した 
 
468 デフォルトの名無しさん [sage] 2011/01/14(金) 21:04:28 ID: Be: 
 スペースを&#160;←これを半角で入れるとちゃんと字下げされるんだけど 
 コピペした時に削らないとコンパイルできないので置換する必要がある 
 
469 デフォルトの名無しさん [] 2011/01/14(金) 23:17:59 ID: Be: 
 早っΣ(;゜д゜) 親切な回答ありがとうございます!! 
 C言語の代行が企業だと50万かかると検索して出たから 
 有償とかそれなり覚悟してたんだ。 
 
 3問中の1問は自力で解くことにします。 
 もう1問も類似したプログラム見つけるなりしてみる。 
 どうしても無理げだったら聞きにこさせてもらうかも。 
 
 本当にありがとうございます!

小文字だと fortran ぽく見えねえ(笑)

■_ JavaScript で~

Quick BASIC みたいな環境を作ったとか作るとか。

qb.js: An implementation of QBASIC in Javascript : javascript
 
qb.js: An implementation of QBASIC in Javascript (stevehanov.ca) 
 
 
loading... 

 
Oh, WOW. Searching to see if I still have my old .qb files somewhere ... 
 
 
wow... 
 
Really, wow... But ehm.. why would we use this? It's great stuff for educational 
purposes, and to show what the canvas element can do, but what would be a real-world 
application for this? 

 
Having fun and learning about parsing, compiling, bytecode, &c. Did i mention it's fun? 
 

Quick BASIC ってファイルの拡張子 .qb だったっけ? BAS だったような覚えががががが。

■_ ネタ

【ナポレオン】長谷川哲也31【アイゼンファウスト】 
71 名無しんぼ@お腹いっぱい [sage] 2010/12/31(金) 21:04:14 ID:yiW0qJuR0 Be:
    某○ミケの会場で開催直前にでスタッフが円陣を組んで

    「○○は!」
    (聞き取れなかったが、おそらく外周担当スタッフという意味の何かだろうと推察)「

    「「地上最強ォォ!!」」

    とかやって気合入れていた。

    とりあえず自分は心の中で「ブルボーン」とつぶやいた。 

72 名無しんぼ@お腹いっぱい [sage] 2010/12/31(金) 21:08:08 ID:RwID67830 Be:
    口に出してたらサンちゃんに斬られていたかもしれないな 

73 名無しんぼ@お腹いっぱい [] 2010/12/31(金) 22:32:29 ID:ZKHF8/JN0 Be:
    >>71
    「デュゴミエオヤジのパクリ」ってつぶやけばよかったのに 

■_

先週の分

で、今日の分


ちゃっかりサインをいただく。


メモから起こすのめんどくせー。 ついったーのまとめがあるからやる気起こらないんだよね。はっきり書いちゃうとw (自分はセッション中にはツイートしてませんけど)

■_

2011年01月14日

■_

センター試験と言えば

■_ お題拝借

okwave から。

マルチプルインスタンスのメリット | OKWave
 
マルチプルインスタンスのメリット 
 
100%の自信をもって回答できる方のみ回答をお願いします。 
 
Java等のオブジェクト指向プログラミング技術において、クラスからインスタンスを 
たくさん作れるというのが特徴の一つとなっていますが、クラスからインスタンスを 
たくさんつくれるメリットはなんでしょうか。 
クラスからインスタンスをたくさん作れなくても、1つ作れば動くプログラムはたくさんありますし、 
そういうプログラムであれば、staticなアクセスにすればよいですよね。 
 
クラスからインスタンスがつくれることを説明した本やサイトは山ほどありますが、 
インスタンスがたくさん作れることのメリットを説明した本をみたことがなく、 
「なぜオブジェクト指向でつくるのか」という本を買って読みましたが、 
納得がいくメリットを感じられませんでした。 
 
また世の中のソースをみると、みんな、すぐにクラスを作ってオブジェクトを作っていますが、 
みなさんがどうして、オブジェクトを作らなくてもコーディングできるケースのプログラムを 
オブジェクトを作るのか不思議でしかたありません。 
 
どうしてオブジェクトを作らなくてもいいケースでもオブジェクトを作るのか、 
またたくさんオブジェクトを作れるメリットはなんなのか、教えてください。 
 

言い回しがちょっと変とか、挑戦的なのはまあ置いといて。

いちいち (たとえば new して) インスタンスを作らなければならないのは 面倒だというのはそう思う人もいるのですかねえ。 でもまあ思いっきり雑な言い方をすれば、インスタンスをただひとつしか作らない ということはある型の変数をただひとつだけ用意してどうこうするってのと 同じようなものだから、ごく限定的な状況を除けばそれは現実的ではないような。

■_ pass by

恒例のこの話題。 Pass by Reference isn't one of Java's Values : programming

2011/value.markdown at master from raganwald's homoiconic - GitHub
 
Pass by Reference isn't one of Java's Values 
 
On the interwebs, I noticed some discussions (e.g. proggit and hacker news) about 
another discussion (serverside) about whether Java the language uses Pass by Reference 
or Pass by Value. It's an old, old argument, and the tl;dr is that Java and most other 
modern languages pass references to objects by value, which means it uses Pass by 
Value. It is absolutely wrong to assert that Java uses Pass by Reference. 

インターネットのそこかしこで Java という言語は pass by reference を使っているのか
それとも pass by value を使っているのかということについての議論がなされているのが
見受けられる。それは古い古い論争であって、その tl;dr は
Java やその他の modern な言語の大部分は オブジェクトへの reference を by value で
渡していて、これはつまり pass by valeu (値呼び) を使っているということである。
Java が pass by reference (参照渡し、参照による呼び出し) を使っているという
主張はまったくもって間違ったものである。


While it's tempting to bash Java programmers for the misconceptions, I think that's 
just confirmation bias. I have absolutely no faith that a statistically significant 
sample of Ruby or Javascript programmers would contain a larger proportion of people 
who get the terms right. 


Which, for the most part, probably demonstrates that the issue just isn't that important.
If it were, nobody would be able to write code without figuring the names out. The fact
is, if you understand what your language does, knowing the correct names is only
important when talking to another programmer. 


I doubt this comes up much, since two programmers talking about Ruby or Java or 
javascript would both have the same understanding of what happens with parameters 
passed to functions/methods. 


In my opinion, trouble over terms is more important when moving from a language with 
one set of semantics to another. For example, when moving from Java to Javascript, not 
understanding closures would make for some error-laden conversations with experienced 
Javascript programmers. 


But for those of you who haven't seen any of the Aleph-0 explanations, here is the 
Aleph-One-th explanation of why Java (and Ruby and Javascript and most other modern 
programming languages) is Pass by Value. 
 
explanation 
 
Java passes a reference to a mutable object by value. This means: 

Java は mutable オブジェクトへの reference を by value で渡す。
これはどういうことかというと:

 1. There is only one instance of the original object, it is not copied, and;
    オリジナルのオブジェクトはただひとつしかなく、コピーされていない。そして

 2. There are two reference to it. One in the original method's environment and
    one in the called method's environment. Since Java passed the reference by
    value, there is a copy of the reference in the called method.
    そのただひとつのオブジェクトに対する参照が二つ存在している。ひとつは
    元のメソッドの環境のものであり、もうひとつは呼び出されたメソッドの環境に
    置かれているものである。Java は reference を by value で渡すので、
    呼び出されたメソッドにその reference のコピーが存在する。
 
Illustration: 
 
public void some_method () { 
 String first_ref = "original string"; 
 // ... 
} 
 
So first_ref is a reference to the string "original string" in some_method. 

first_ref は some_method 中で "original string" という文字列を参照している。

Somewhere else we write: 

public void called_method (String second_ref) { 
 second_ref = "brand new string"; 
} 


In called_method, second_ref will be a copy of a reference to a String. When 
called_method is called, second_ref will point to some original String (which is an 
object, obviously). But it's a brand new reference. 


What happens when second_ref = "brand new string"; is executed? Well, first 
we evaluate the RHS of the assignment. This creates a brand new string with the value 
"brand new string". Then we change the reference second_ref to point to the 
brand new string and throw away its original value, which was a reference to the 
original string. 


Let's flesh out some_method: 


public void some_method () { 
 String first_ref = "original string"; 
 called_method(first_ref); 
 System.out.println(first_ref); 
} 


What is output? 


As above, second_ref inside of called_method now contains a reference to "brand 
new string". But first_ref hasn't changed, it still points to "original 
string," and that's what gets printed. 


Thus, Java passes references to objects, but it does so by making a brand new 
reference to the original object. If Java used pass by reference, this program would 
output "brand new string." 


post scriptum 


Pass by Reference is rare in modern languages, but consider this line of ancient FORTRAN: 

2 = 3 

FORTRAN was originally Pass by Reference for everything. To make matters more interesting,
integer constants in a program were references to the integers, not some kind of special
primitive. Therefore, the above line of code changes the reference 2 to become the reference
3, and everywhere in the program that uses 2, you actually get 3. 

Legend has it that this code was used to fix a bug without search and replace, a very 
expensive operation in the days of paper tape and/or punch cards. 

And this just in: 
 
  pass by value (of refs) is just so plain better that "by name" and "by 
  reference" are mostly of historic/scientific interest—@axeolotl 
 
True, but every now and then some idiot ventures into the tomb and awakens a long dead 
monster. 

とある(たぶん)有名な Java の入門本を読んでたら、 Java は int や double なんかは call by value だけど、 オブジェクト型は call by refernce です。的な記述があってぐんにょりしたことが。 で、 プログラミング言語Java (The Java Series) これの何ページだかに Java には call by value しかなくて、 オブジェクト型は call by reference というのは良く見られる間違いであるといった 記述があって大笑い。

情報処理技術者試験で使われてはいても、このへんの仕様のお話は出てこないのだろうねえ。

■_ いんたびゅーうぃずすぽすっぽセンセイ

まあ全文は誰かやるだろうと予測 :)

An Interview with C++ Creator Bjarne Stroustrup - CodeGuru

With the new C++0x standardization process about to have the final technical vote we 
sit down with C++ creator Bjarne Stroustrup to talk about C++0x, new features and 
future plans. 
 
Danny Kalev: Where is the C++0x standardization process standing these days? How close 
are we to a new International Standard? 

C++0x の標準化プロセスの近況はどういったものでしょうか?
新しい国際標準にはどのくらい近づいていますか?

Bjarne Stroustrup: The final technical vote is scheduled for March 26, 2011. I see no 
reason for that to fail. After that, there are formal national ballots and ISO 
bureaucratic delays, but I'm pretty confident that the official standard will be 
available in 2011. 

最後の techinical vote が2011年3月26日に予定されています。
この投票が失敗するとは考えていません。
投票のあと、形式的な national ballots と ISO bureaucratic delays がありますが、
2011年中に offical standard が世に出るであろうと期待しています。

(略)
 
Danny Kalev: Finally, what are your New Years' resolutions? 
では最後に、新年にあたっての決意を。

Bjarne Stroustrup: 
 
 * To get C++0x formally approved as an ISO standard.
   C++0x を ISO 標準として形式的に approve させる

 * To produce a good first draft of The C++ Programming Language (4th Edition).
   The C++ Programming Language (第四版) の first draft を仕上げる。

 * To spend more time with my grandchildren.
   孫との時間をもっと持つようにしたい

 * To have at least one interesting new technical insight. 
   少なくともひとつ、interesting new technical insight を持つ。

first draft of The C++ Programming Language (4th Edition) ほう。ページ数もとんでもなくなりそうな予感。

■_

2011年01月13日

■_

今週のモーニングにはカレチが載ってた。

■_ Why Teach Programming with BASIC

これもまあ定期的に出る話題ではありますが。


ClubCompy - kids [heart] computers! by David Woldrich » Why Teach Programming with BASIC — Kickstarter

Why Teach Programming with BASIC
(なぜプログラミングをBASICで教えるのか)

Update #8 

In less than a century of programming, programmers have created thousands of languages, 
with dozens of popular languages in widespread use. Programmers and teachers have 
their choice of languages intended for industry or teaching, with specific languages 
designed for specific roles.

一世紀にも満たないプログラミングの時代において、プログラマー達は千を越える言語を産み出し、
そのうちの数ダースの言語は広く使われるようになりました。
プログラマーたちと教師たちは、特別な役割のために設計された特別な言語でもって
industry や teaching を意図した言語の選択を行いました


We've chosen as inspiration a language designed by Thomas Kurtz and John Kemeny: BASIC. 
BASIC exploded in popularity as computers became more accessible in the late '70s and 
early '80s. Everyone who's worked on ClubCompy started to program with BASIC, and it 
was an amazing introduction into the power of programming.

わたしたちは Thomas Kurtz と John Kemeny によって設計された言語である BASIC を選択しました。
BASIC は 70年代後半から80年代の初めにかけてコンピューターがより accessible になるのと歩調を
合わせて爆発的に広がりました。ClubCompy で働くすべての人は BASIC でプログラミングを始めてい
ましたが、それは power of programming への amazing introduction でした。


Since the introduction of BASIC in 1963, several generations of languages have appeared.
Productive professional programmers have moved on beyond the simple BASIC of the '60s and
'70s and early '80s, but we've chosen BASIC as our inspiration for its simplicity in two
ways: it's easy to teach and it's easy to implement.

1963年に BASIC が導入されて以来、プログラミング言語は数世代を数えました。
Productive professional programmers は 60年代から 80年代初めの単純な BASIC を飛び越えていますが
わたしたちはその二つの意味での simplicity への our inspiration として BASIC を選択しました。
つまり、教えやすく実装が簡単であるということです。


The Simplicity of Explanation
説明が容易

Kurtz and Kemeny designed BASIC for novice programmers. In doing so, they explicitly 
followed several design goals to enforce a simplicity of explanation:

Kurtz と Kemeny は新米プログラマーたち (novice programmer) に向けて BASIC を設計しました。
その際に、explanation の simplicity を enforce するためのいくつかの設計上の目標に
彼らは明確に従いました。


    * A line is a simple statement
      一行が単純な文である

    * Numbers are numbers
      数値は数値である

    * Line numbers make control flow obvious
      行番号は制御フローを明確にする

    * The default behaviors are obvious and reasonable
      デフォルトの振る舞いが明確でresonable である


While it's possible to emulate some of these features by implementing a subset of a 
language such as Scheme or Smalltalk, the designs of those languages rely on the 
gestalt of the languages: a subset of Smalltalk is less useful than it could be unless 
you choose the very heart of Smalltalk.

これらの機能のいくつかは Scheme や Smalltalk のサブセット言語を実装することで
エミュレート可能ですが、そういった言語の設計は元の言語の gestalt に依存しているのです。
Smalltalk のサブセットは、あなたが Smalltalk の very heart を選択しない限りは
本来あるものよりも不便なものになってしまいます。

Similarly, BASIC's relative lack of abstractions is an advantage to people who've 
never programmed before. A sequential list of instructions with no control flow more 
complex than a loop or "go to step 10" is much easier to understand than 
even simple function application (let alone method dispatch or recursion).

同様に、BASIC の相対的な抽象化の欠如はそれまでプログラミングをしたことのない人に対する
advantage です。ループや "go to step 10" よりも複雑な制御フローを持たない
命令列は単純な関数アプリケーションと比べてさえ理解するのが格段に容易です。


Function application, method dispatch, and recursion are important concepts to 
understand to be sure, but we prefer to delay their explanation until later in the 
ClubCompy learning experience.

関数適用、メソッドディスパッチ、再帰はきちんと理解することが重要なコンセプトですが、
しかしわたしたちはそれらを説明するのを ClubCompy での学習の後にした方が良いと考えました。


Like BASIC in the microcomputers of our childhoods, ClubCompy's language offers a 
tight integration with the shell. Any expression usable in the shell is usable in a 
program, and vice versa. The only difference between a program and immediate commands 
is the presence or absence of line numbers. Again, this is easy to explain in metaphor 
terms that students already understand.

わたしたちが子供だった頃のマイクロコンピューター上の BASIC のように、ClubCompy の言語は
シェルと強く結びついています。シェルで使えるすべての式はプログラムにおいても使用可能で、
その反対も然りです。プログラムと immediate command の間の唯一の違いとは行番号の有無だけ
なのです。繰り返しますが、これは学生たちがすでに理解している metaphor terms で
容易に説明できるのです。


Finally, the limitations of BASIC help us write good tutorial materials because they 
limit the complexity of the programs we write. Where languages with better possibilities
for abstractions allow us to write very concise, very powerful code, we must be more
explicit and less clever here. Our goal is not to write the most elegant programs
possible in any language. Our goal is to write programs to help our students understand
computing.

結局のところ、BASIC の制限というのはわたしたちがよいチュートリアルを書くのを手助けしたの
です。それはそういった制限がわたしたちの書くプログラムの複雑さを限定したからです。
言語がより一貫的で非常に強力なコードの記述を可能にするようなもっと優れた抽象化に対する
possibilities を持っていたのなら、わたしたちは more explicit かつ less clever でなければ
なりません。
わたしたちの目標はどんな言語でも可能な最もエレガントなプログラムを書くことではありません。
わたしたちの目標は学生たちがコンピューティングを理解するのを手助けするプログラムを書くことです。


The Simplicity of Implementation
実装の Simplicity

Didactic concerns drive the design, but implementation concerns are also important. A 
beautiful, elegant language that students find impenetrable and unusable is as useless 
as the best teaching language possible that we cannot implement effectively. We've 
spent a lot of time designing a language that is both simple to teach and sufficiently 
simple to implement.

didactic concerns は設計を drive しますが、implementation concerns もまた重要です。
学生達がimpentrable と unusable を見いだす美しくエレガントな言語は、わたしたちが
効率的に実装できない可能性のある best teaching language と同じくらい useless なのです。
わたしたちは教えるのに単純で実装するのに充分単純な言語の設計に時間を掛けました。
わたしたちの technical constraints は their own limitations を offer しています:

didatic 教訓的な 教えたがる

    * We wanted a system hosted solely in a modern web browser. We can make few assumptions
      about the computers our students will use, especially those found in homes and
      libraries. Requiring the installation of extra software, even plugins, is a barrier
      we prefer to avoid. This meant creating a new language implementation.

      わたしたちはモダンな web ブラウザーで solely にホストされるシステムを欲していました。
      わたしたちの学生が使うであろうコンピューターについて、特に家庭と図書館でのものについて
      二、三の仮定を置くことができます。
      extra software のインストールを要求することは、それがたとえプラグインであったとしても
      わたしたちが取り除きたい障壁 (barrier) なのです。
      これは新しい言語の実装を作り出すことを意味します。

    * We wanted a system easy to secure, such that there are no mechanisms to escape the
      security of the system to manipulate either the underlying machine or the experience
      of other users. In this case, a language with fewer features and fewer possibilities
      for abstraction and cleverness is easier to audit. This meant evaluating our
      implementation for potential mischief.

      わたしたちは underlying machine もしくは experience of other users な
      操作をするためにセキュリティを迂回するような機構のない easy to secure なシステムを
      欲していました。
      この場合、少ない機能しか持たず、
      abstraction や cleverness に対する possibilities も少ない言語が
      audit するのにより簡単です。
      これはわたしたちの実装の潜在的な mischief を評価することを意味します。

    * We wanted a system which runs on multiple platforms. Again, we make no assumption about
      the underlying machine besides the presence of a relatively modern web browser. You can
      access ClubCompy on a machine running Microsoft Windows, Mac OS X, a free software
      system running the Linux kernel such as a GNU/Linux distribution or an Android
      smartphone, and even certain set top boxes and game consoles.

      わたしたちは複数のプラットフォームで実行できるシステムを欲していました。
      繰り返しますが、わたしたちは
      比較的新しいwebブラウザーの存在を除けばマシンに依存する仮定をしていません。
      あなたは Microsoft の Windows や Mac OS X を実行しているマシン上や
      GNU/Linux ディストリビューションや Android スマートフォンのような
      Linux カーネルを実行している自由ソフトウェアシステム上、
      さらには一部のセットトップボックスやゲームコンソール上にある
      ClubCompy にさえアクセスできます。


    * We wanted a system with intrinsic graphics primitives. This justification follows one
      of our goals for teaching: students should be able to produce visual feedback within
      the first three minutes of exploring ClubCompy. Intrinsic primitives for drawing and
      sprite operations are easier to explain than the extension ecosystem necessary to
      import graphic primitives from a library.

      わたしたちは intrinsic な graphics の primitives を持ったシステムを欲していました。
      この justification は our goals for teaching の一つに従っています:
      学生たちは、ClubCompy を exploring して最初の三分間で visual feedback を produce 可能で
      あるべきです。
      drawing のための instrinsic な primitives とスプライト操作は、ライブラリから graphic
      プリミティブを import する必要のある拡張エコシステムよりも説明するのが容易です

    * We wanted a system we could tweak and change for further didactic purposes. When we
      added the turtle graphics operations, we gleefully borrowed them from other languages
      we've used. The Logo programming language, created in 1967, eventually introduced the
      turtle first as a physical robot and then a cursor, and influenced multiple
      generations of didactic languages. We implemented our own version of BASIC, and in an
      already-fragmented world of many, many implementations and reinventions of BASIC
      question that. If we'd borrowed and reimplemented and then expanded Smalltalk, for
      example, we'd have had to do more work to understand and adhere to the core principles
      of the language. BASIC frees us for further expansion.

      わたしたちは、わたしたちが tweak したり further didatic purposes のために変更できるような
      システムを求めていました。わたしたちがタートルグラフィクスの操作を追加したときには
      それをわたしたちが既に使っていた別の言語から gleefully に拝借しました。
      1967年に作られたプログラミング言語 Logo は物理的なロボットや後にはカーソルとして初めてタートルを
      導入し、そして複数世代の didactic languages に影響を及ぼしました。
      わたしたちは独自の BASIC を実装し、
      and in an already-fragmented world of many, many implementations
      and reinventions of BASIC question that.

      もし、たとえば Smalltalk を基に再実装と拡張を行っていたならば、わたしたちは理解と
      adhere to the core principles of the language のために
      もっと多くの作業をしなければならなかったでしょう。
      BASIC はそういった further expansion からわたしたちを解放してくれたのです。

Even though the Tasty language of ClubCompy is an amalgamation of BASIC and Logo, there are
no strict technical reasons why it must remain so. Nor do any technical reasons exist why
the Tasty language must be the sole language of ClubCompy. We've designed our technology
such that many languages are possible, such that we can create new languages and
implementations with all of the capabilities of the Tasty platform with different syntaxes.

ClubCompy の Tasty 言語が BASIC と Logo の amalgamation であったとしても、
そこには strict な技術的理由 (technical reasons) はありません。
また、Tasty 言語が sole language of ClubCompy でなければならない
なんらかの技術的理由もありません。わたしたちは、多くの言語で可能で
新しい言語と異なる構文を持った Tasty platform の capabilities すべての実装を作れるような
自分たちの technology を設計しました


Why would we do this?

Just as BASIC makes introductory programming more obvious, Scheme makes function 
application and recursion more obvious, and Smalltalk makes message passing more 
obvious, the philosophy and syntax of a language influences the mindset of its 
programmers and the design of programs written in that language. Perhaps future 
ClubCompy lessons will require the design of new languages to expose didactic concepts 
in concrete and effective ways.

ちょうど BASIC が introductory programming を より明確にしたように
Scheme は関数の適用と再帰 (function application and recursion) をより一層明確にし、
そして Smtalltalk はメッセージパッシング (message passing) をより一層明確にして、
ある言語の哲学や構文はその言語を使うプログラマーの mindset と
その言語で書くプログラムの設計に影響を及ぼします。
おそらく将来の ClubCompy のレッスンでは、didatic なコンセプトを具体的かつ効果的な
やり方で expose する新しい言語の設計を必要とするでしょう。


After all, our goal is to promote the understanding of computing and logical thinking 
and problem solving far more than the syntax or implementation of any one system.

わたしたちの目標は何か一つのシステムの構文や実装ではなく、コンピューティングの理解と
ロジカルシンキング、そして問題の解決を promote することです。


© 2010 Kickstarter, Inc.
Quantcast

■_ Scala とは

Effective な Java か?

200以上コメントがついていたので。

Scala == Effective Java? : programming
 
Scala == Effective Java? (grahamhackingscala.blogspot.com) 
 
 
If people are doing a new project on the JVM (greenfield) with no existing Java code, 
there is no reason to not use Scala instead of Java. 

 
Another reason: scalac slow compilation times - Hello world in 8 s. 
 
 
That might be true for scalac, but not for scala, fsc or sbt. 
 
 
Well, even warmed up, scalac is significantly slower than Java compilers. Admittedly, 
it's offset somewhat by the fact that you'd be compiling far fewer lines of Scala for 
the same equivalent functionality in Java. 

 
Yes, scalac is and will be a a magnitude slower than javac, because it does a lot more 
work than javac. (Says Martin Odersky which has written both javac and scalac.) 
 
That's why people use scala, sbt or fsc as already mentioned. 
 
 
 That's why people use scala, sbt or fsc as already mentioned. 
 
Yes, I know why people use each of these tools, but they do not by any means entirely 
solve the problem. (And I'm baffled as to why you think the REPL would help with slow 
compilation). 
 
Sankozi's numbers are wrong, but his core complaint is valid -- compilation speed does 
matter in the real world, and Scala is on the slow side. 
 
If Clojure wants to compete against Java or Scala, it has to be as fast as Java or 
Scala. Reality: It is magnitudes slower. And in times were computing power doesn't 
grow exponentially anymore, this matters. 
 
Sure, there are hacks like type annotations to make it a bit more typed (and therefore 
faster), but if you do that Clojure isn't a "simpler language" anymore (and 
in my humble opinion even more ugly than Java). 
 
Ruby and Python successfully compete with java in its own stronghold (server side web 
applications), yet they are up to a 100 times slower than java. So if such a huge 
difference in speed is ok for millions of Pyton + Ruby + PHP programmers, then clojure 
being MUCH faster than those languages is doing fine. Besides it's piggybacking on top 
of java. So if any part of a program ever becomes a performance bottleneck, clojure 
programmers have an easy way to fix it (step down to java). 
 
 but if you do that Clojure isn't a "simpler language" 
 
Type annotation is just that, a small piece of additional information in function 
parameters. It does not change semantics AT ALL. How can you seriously compare it to 
such complex constructs as traits, mixins, awkward OO pattern matches, and many edge 
cases Scala has ? 

■_ ねた

例によってざっくり組んだだけ。 しかも Ruby でやる意味があったのかという…

#!/usr/local/bin/ruby
# -*- coding: utf-8 -*-

def num2DPD(num)
# BCD (a b c d) (e f g h) (i j k m)
#  ↓
# aei | pqr stu v wxy
# 000 | bcd fgh 0 jkm
# 001 | bcd fgh 1 00m
# 010 | bcd jkh 1 01m
# 100 | jkd fgh 1 10m
# 110 | jkd 00h 1 11m
# 101 | fgd 01h 1 11m
# 011 | bcd 10h 1 11m
# 111 | 00d 11h 1 11m
# いずれかの桁が8以上 v=1
# v=1のとき wx で桁を表す
# wx 00 1桁目
#    01 2桁目
#    10 3桁目
#    11 → 複数の桁が8以上→ stをみる
# st 00 3桁目と2桁目が8以上
#    01 3桁目と1桁目が8以上
#    10 2桁目と1桁目が8以上
#    11 3桁とも8以上

 sd3 = (num / 100).to_i
 sd2 = (num / 10).to_i % 10
 sd1 = num % 10

 #puts "sd3:#{sd3} sd2:#{sd2} sd1:#{sd1}"
 v = (sd3<=7 && sd2<=7 && sd1<=7) ? 0 : (1<<3)
 a = (sd3>7) ? 1 : 0
 e = (sd2>7) ? 1 : 0
 i = (sd1>7) ? 1 : 0

 sd3 &= 7
 sd2 &= 7
 sd1 &= 7

 aei = a*4+e*2+i
 d = (sd3 & 1)
 h = (sd2 & 1)
 m = (sd1 & 1)
 jk = (sd1>>1)
 fg = (sd2>>1)
 wx = st = dpd = 0

 #puts "v=#{v}, a=#{a}, e=#{e}, i=#{i}, aei=#{aei}"
 case aei
# aei | pqr stu v wxy
# 000 | bcd fgh 0 jkm
 when 0
   #puts "sd3=#{sd3}, st=#{sd2}, sd1=#{sd1}"
   dpd = (sd3<<7) | (sd2<<4) | sd1
# 001 | bcd fgh 1 00m
 when 1
   #puts "sd3=#{sd3}, st=#{sd2}, v=#{v}, m=#{m}"
   dpd = (sd3<<7) | (sd2<<4) | v | m
# 010 | bcd jkh 1 01m
 when 2
   wx = 1
   #puts "sd3=#{sd3}, jk=#{jk}, h=#{h}, v=#{v}, wx=#{wx}, m=#{m}"
   dpd = (sd3<<7) | (jk<<5) | (h<<4) | v | (wx<<1) | m
# 100 | jkd fgh 1 10m
 when 4
   wx = 2
   #puts "jk=#{jk}, d=#{d}, sd2=#{sd2}, v=#{v}, wx=#{wx}, m=#{m}"
   dpd = (jk<<8) | (d<<7) | (sd2<<4) | v | (wx<<1) | m
# 110 | jkd 00h 1 11m
 when 6
   wx = 3
   st = 0
   #puts "jk=#{jk}, st=#{d}, h=#{h}, v=#{v}, wx=#{wx}, m=#{m}"
   dpd = (jk<<8) | (d<<7) | (h<<4) | v | (wx<<1) | m
# 101 | fgd 01h 1 11m
 when 5
   wx = 3
   st = 1
   #puts "fg=#{fg}, d=#{d}, st=#{st}, h=#{h}, v=#{v}, wx=#{wx}, m=#{m}"
   dpd = (fg<<8) | (d<<7) | (st<<5) | (h<<4) | v | (wx<<1) | m
# 011 | bcd 10h 1 11m
 when 3
   wx = 3
   st = 2
   #puts "sd3=#{sd3}, st=#{st}, h=#{h}, v=#{v}, wx=#{wx}, m=#{m}"
   dpd = (sd3<<7)| (st<<5) | (h<<4) | v | (wx<<1) | m
# 111 | 00d 11h 1 11m
 when 7
   wx = 3
   st = 3
   #puts "d=#{d}, st=#{st}, h=#{h}, v=#{v}, wx=#{wx}, m=#{m}"
   dpd = (d<<7) | (st<<5) | (h<<4) | v | (wx<<1) | m
 end

 printf "%3d → %010b\n", num, dpd

end

[*0..999].each do |num|
  num2DPD(num)
end

もうちょっとすっきりさせたいけどいいや。

しかしうまいこと考えるもんだなあ>dpd 【コラム】コンピュータアーキテクチャの話 (104) 10進浮動小数点演算 | エンタープライズ | マイコミジャーナル

■_

2011年01月12日

■_

4月5日に公開録音とな。

■_

C 本。

The Definitive C Book Guide and List - Stack Overflow
 
To follow the example of The Definitive C++ Book Guide and List for C Books here is a 
wiki post for organization. 
 
A tag search for "C" and "Books" returns no complete book list 
results as of writing this question. That search is here. 
 
This post is to providing QUALITY books and an approximate skill level. Maybe we can 
add a short blurb/description about each book that you have personally read / 
benefited from. Feel free to debate quality, headings, etc. 
 
Reference Style - All Levels 
 
 1. The C Programming Language (also known as: K & R) - Brian W. Kernighan and Dennis M. Ritchie 
 2. C: A Reference Manual - Samuel P. Harbison and Guy R. Steele 
 3. C Pocket Reference (O'Reilly) - Peter Prinz, Ulla Kirch-Prinz 
 
Beginner 
 
 1. C Primer Plus - Stephen Prata 
 2. C Programming: A Modern Approach - K. N. King 
 3. A Book on C - Al Kelly/Ira Pohl 
 
Intermediate 
 
 1. Object-oriented Programming with ANSI-C - Axel-Tobias Schreiner 
 2. C Interfaces and Implementations - David R. Hanson 
 3. The C Puzzle Book - Alan R. Feuer 
 4. The Standard C Library - P.J. Plauger 
 
Above Intermediate 
 
 1. Expert C Programming: Deep C Secrets - Peter van der Linden 
 
 
I added Deep C Secrets which I loved. 

日本でよく見かける「入門書」と、↑のBeginnerに挙げられてるのを比較すると…

■_

Ruby 1.8 - Feature #4239: Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? - Ruby Issue Tracking System

2011年01月12日 13:55 PM - Charles Nutter 
 
JRuby's 1.9 support is perhaps not complete, but it's good enough that we can run a 
very high percentage of RubySpecs, most Rails tests, and Rails itself is able to 
generate, scaffold, boot, and serve dynamic pages. It's looking very good. 
 
If we get a lot of help from users (and maybe help from ruby-core), it may be possible 
to set 1.9 mode as the default mode for JRuby in the next release. I believe that 
would help 1.9 adoption and help age out 1.8.

age outの意味 - 英和辞書 - goo辞書

age outの意味 - 英和辞書 - goo辞書

age out[age out] 
 
 ((米俗))(ある年齢になって)麻薬などをやめる.
Age-Out - What Does Age-Out Mean?

Definition: To age-out means to lose eligibility for special education and related 
services under the Individuals with Disabilities Education Act because of reaching the 
age of 22. IDEA services are only provided through age 21. 

Examples: 

Some students age-out of special education programs because they remain in the 
programs until they reach age 22.

■_ Perl 6

こうしてみると記号の組み合わせもやたらとあるような。

Perl 6 Index Tablet / Perl 6

 * ! (logical op) - logical negation, forces binary context, high precedence version of not 
 * ! (twigil) - twigil of private class and object variables 
 * ! - suffix for required named parameter in signatures 
 * !<op> (meta op) - negates (mostly comparsion operators) 
 * !! - second Part of the ternary (conditional) operator after ?? 
 * !!! (yadda op) - yadda Operator that calles die 
 * " " (quoting op) - double quoting, interpolate with :s, :a, :h, :f, :c, :b (all vars, functions, blocks, control chars), alias to qq/.../ or Q :qq/.../ 
 * # - starts a comment that continues to the end of the line; works even inside regexes as (regex Metachar) 
 * #`( ) - starts a multi line comment that continues to the end of the line or bracket, works with any combination of bracket pairs 
 * $ (sigil) - prefix of scalar vars 
 * $() (conext op) - forces scalar context, alias to item() 
 * $ (regex Metachar) - end of the string 
 * $$ (regex Metachar) - end of a line 
 * % (sigil) - prefix of hash variables 
 * % (numeric op) - gives remainder of a modulo division, forces numeric context 
 * %() (conext op) - forces hash context, alias to the hash() function 
 * %% (numeric op) - Bool::True if the left is evenly divisible by right value 
 * & (sigil) - sigil of the callable namespace 
 * & (junctive op) - junctive AND, requires that all conditions are met 
 * & (regex Metachar) - match multiple patterns (AND - connection of patterns) 
 * && (logical op) - short circuit AND, evals right side if left side returned true, high precedence version of and 
 * ' ' (quoting op) - simple quoting, just / and ' needs o be quoted, alias to q// 
 * () - grouping of values (parameters) 
 * () (regex Metachar) - encompass a subregex/submatch 
 * * (numeric op) - multiplies numbers and forces numeric context on parameters; 
 * * (term) - synonym for Inf (Whatever) in connection with a Range operator (".."); marks the end of an array in a slice operator so that negative indices access array elements relative to one beyond the final element 
 * * - marks as prefix slurpy arrays in signatures 
 * * (twigil) - secondary sigil of global variables 
 * ** (numeric op) - raises a number to a power and forces numeric context 
 * ** (regex Metachar) - multiplies char or group like x (strig op) outside of regex, (ha)**3 equals (hahaha) 
 * + (conext op), (numeric op) - forces numeric context of values and adds results 
 * +& (numeric op) - bitwise and, numeric context 
 * ++ (sequence traversion) - generic autoincrement, calls internal iterator of that object, before (prefix) or after (suffix) the evaluation of the surrounding term, alias to succ 
 * +< (numeric op) - shift left in numeric kontext 
 * +> (numeric op) - shift right in numeric kontext 
 * +^ (numeric op) - bitwise xor in numeric context 
 * +| (numeric op) - bitwise or in numeric context 
 * , - list generating operator 
 * - (numeric op) - forces numeric context and subtract 
 * -- (sequence traversion) - generic autodecrement, calls internal iterator of that object, before (prefix) or after (suffix) the evaluation of the surrounding term, alias to pred 
 * --> - define the type of the return value of a routine by writing the types name after this arrow at the end in a signature 
 * -> - assigns a named parameter for a block (pointy block) 
 * . - secondary sigil for public accessors (getter/setter) 
 * . (regex Metachar) - really any character (unlike Perl 5) 
 * .. (ranges), (infix list op) - range generating operator, range object in item context 
 * ... (infix list op) - infix operator for list generation, sequence operator 
 * ... (yadda op) - term that calls fail (exception), marks unimplemented empty routine bodies 
 * / (numeric op) - division, numeric context 
 * / (rat composer) - inside round braces (3/7) gives you a rational number that keeps track of its numerator and denominator 
 * // (numeric op) - short circuit defined or, returns the first defined value (from left to right), similar to orelse, high precedence version of err 
 * \0[<n>] escape sequence - character given in octal (brackets optional) 
 * : - pair generation operator, also known as adverbial syntax 
 * : (filetest op) - start of all file text ops, syntax: ":" ~ one (<r w x o R W X O e z s f d l p S b c t u g k T B M A C>) 
 * : (twigil) - for autogenerated named parameters of a block 
 * :b<n> - general radix form for literals, makes a number n in base b (up to 36), for example :2<1000001> is 65 
 * : - (flow control) - endchar of all labels, jou can jump to 
 * : - prefix of named parameter in a signature 
 * :: (sigil) - abstraction sigil, name space separator (like in Perl 5) 
 * ::= - binding a value or variable to a variable at compile time 
 * := - creates an alias to a variable at runtime (binding) 
 * ; - seperates commands ( statements ) or array indices eg @[2;3] instead of @a[2][3] 
 * < (num comparison) - infix op, lesser than, Bool::True if numerically ordered the left comes before the right operand 
 * <-> double pointy syntax to assign a rw parameter to a block 
 * << (meta op) - applies the operator on the left as hyper operator to the array on the right 
 * <<== - leftward pointing feed operator that adds values to an existing list (append-mode) 
 * << >> (quoting op) - circumfix quoting operator for grouping with autoquoting and evaluation (alias to Q :qq :ww /.../) 
 * <= (num comparison) - less than or equal, numeric comparison operator 
 * <== - leftward pointing feed operator 
 * <=> (num comparison) - numeric less-equal-greater comparison for sortable classes, does cmp in numeric context as leg does in string context 
 * < > (quoting op) - circumfix quoting operator for grouping with autoquoting (alias to Q :q :ww /.../ or qw/.../) 
 * < > (regex metachar) - embraces an subrule (assertion) 
 * = (Op) - assignment, right side is evaluated and assigned to the left 
 * <op>= (meta op) - self assignment, left side is one oper and the result is assigned to ($a += 3; equals $a = $a + 3) 
 * =:= (comparison op) - compares binding, if both vars are bound to same memory location 
 * == (num comparison) - equality of value, does a cmp in numerical context as leg does in string context 
 * === (comparison op) - identity, equality of value and type 
 * ==> (op) - rightward pointing feed operator 
 * ==>> (op) - rightward pointing feed operator that adds values to an existing list (append-mode) 
 * => (op) - pair (and hash) constructor, fatarrow 
 * > (num comparison)- infix op, greater than 
 * >= (num comparison) - infix op, greater than or equal 
 * >> (meta op) - binds operator (right) as hyper operator to an array (left) 
 * ? (conext op) - forces binary context in an expression, returns Bool::False when value is 0 or empty, otherwise Bool::True 
 * ? - suffix for optional named parameters in signatures 
 * ? - quantifier for 0 or 1 occurrence in Regexes 
 * ? (twigil) - secondary sigil for constant compiler hint variables 
 * ?& (bool op) - logical AND op, and combinator, forces binary context 
 * ?? !! (logical op) - ternary or conditional operator 
 * ??? (yadda op) - yadda operator that calles warn 
 * ?^ (bool op) - logical XOR, forces operands into boolean context 
 * ?| (bool op) - logical OR, forces operands into boolean context 
 * @ (sigil) - sigil of an array 
 * @() (conext op) - forces (flattened) array context, alias to list() function 
 * <var>[ ] - postcircumfix operator, appended on an array var, returns an array slice with values which indexes was inside the brackets 
 * [ ] - circumfix operator that creates a reference to an array that holds all values that encompas these brackets 
 * [<op>] (meta op) - circumfix reduction metaop, close to functional "reduce", applies the operator between all elements of an array 
 * [\<op>] (meta op) - circumfix reduction metaop, applies above reduction to a series of lists made of array slices ranging in length from 1 to the complete length of the original list 
 * \ - capture generator, creates a reference to the following structure 
 * \ - escape char, all escape sequences inside quotes and regexes start with it 
 * ^ (junctive op) - junctive xor, requires that one value in a list is true 
 * ^ - upto operator, ^$limit expands to 0 ..^ +$limit range 
 * ^ (ranges) - in range definitions, it excludes a limit value, in scalar context see smartmatch 
 * ^ (twigil) - for autogenerated positional parameters of a block, position results from alphabetical order of all $^-Variables 
 * ^ (regex Metachar) - start of the string 
 * ^^ (logical op) - logical xor, combines expressions, returns true when only one expression is true, otherwise false, high precedence version of xor 
 * ^^ (regex Metachar) - start of a line 
 * {} - circumfix operator: encloses blocks and creates a coderef, or a hashref when it is identified as a hash or contains a '=>' 
 * | (junctive op) - junctive OR, requires that a condition is fulfilled 
 * | (regex Metachar) - match alternate patterns (OR - connection of patterns) 
 * |() (conext op) - flatten capture object into arglist, (named parameter) 
 * || (logical op) - short circuit OR, evaluates sequentially, ends evaluation at the first expression that returns true, high precedence version of or 
 * ||() (conext op) - flatten capture object into semicolon list, (positional parameter) 
 * ~ (conext op), (string op) - forces string context (stringify) and/or concatenate strings, synonym for cat 
 * ~& (string op) - characterwise and, forces string context 
 * ~< (string op) - characterwise left shift, forces string context 
 * ~> (string op) - characterwise right shift, forces string context 
 * ~^ (string op) - characterwise xor, forces string context 
 * ~| (string op) - characterwise or, forces string context 
 * ~~ - smartmatch operator, compares (almost) all variable and data types 
 

<-> と <=> とか <<== <= <== ==> ==>> => もうなにがなんだか。

■_

■_

2011年01月11日

■_

・読んだ
Amazon.co.jp: 先読み「情報脳」の鍛え方 〜情報中毒社会サバイバルガイド〜: 小関 悠: 本 ちょっと期待はずれ。だったかな。 情報のキュレーターなんてのは面白いとは思ったけど この本以前にも見たような覚えあったし。

■_ gawk 4.0(の候補)

ドキュメントを読んでたらこんなの発見。

4.7 Defining Fields By Content
==============================

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

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

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

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

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

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

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

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

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

   When run, we get the following:

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

   Note the embedded comma in the value of `$3'.

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

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

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

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

まあ、csv をごにょごにょしたいって要望はそれなりにあるようだし、 それに対処するとなるとこういう方向になるよねえ。 でも改行を含んだレコードの扱いはどうなるんだろう。

■_

そしてもうひとつ

Foreword
********

Arnold Robbins and I are good friends. We were introduced in 1990 by
circumstances--and our favorite programming language, AWK.  The
circumstances started a couple of years earlier. I was working at a new
job and noticed an unplugged Unix computer sitting in the corner.  No
one knew how to use it, and neither did I.  However, a couple of days
later it was running, and I was `root' and the one-and-only user.  That
day, I began the transition from statistician to Unix programmer.

   On one of many trips to the library or bookstore in search of books
on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and
Weinberger, `The AWK Programming Language', Addison-Wesley, 1988.
AWK's simple programming paradigm--find a pattern in the input and then
perform an action--often reduced complex or tedious data manipulations
to few lines of code.  I was excited to try my hand at programming in
AWK.

   Alas,  the `awk' on my computer was a limited version of the
language described in the AWK book.  I discovered that my computer had
"old `awk'" and the AWK book described "new `awk'."  I learned that
this was typical; the old version refused to step aside or relinquish
its name.  If a system had a new `awk', it was invariably called
`nawk', and few systems had it.  The best way to get a new `awk' was to
`ftp' the source code for `gawk' from `prep.ai.mit.edu'.  `gawk' was a
version of new `awk' written by David Trueman and Arnold, and available
under the GNU General Public License.

   (Incidentally, it's no longer difficult to find a new `awk'. `gawk'
ships with GNU/Linux, and you can download binaries or source code for
almost any system; my wife uses `gawk' on her VMS box.)

   My Unix system started out unplugged from the wall; it certainly was
not plugged into a network.  So, oblivious to the existence of `gawk'
and the Unix community in general, and desiring a new `awk', I wrote my
own, called `mawk'.  Before I was finished I knew about `gawk', but it
was too late to stop, so I eventually posted to a `comp.sources'
newsgroup.

   A few days after my posting, I got a friendly email from Arnold
introducing himself.   He suggested we share design and algorithms and
attached a draft of the POSIX standard so that I could update `mawk' to
support language extensions added after publication of the AWK book.

   Frankly, if our roles had been reversed, I would not have been so
open and we probably would have never met.  I'm glad we did meet.  He
is an AWK expert's AWK expert and a genuinely nice person.  Arnold
contributes significant amounts of his expertise and time to the Free
Software Foundation.

   This book is the `gawk' reference manual, but at its core it is a
book about AWK programming that will appeal to a wide audience.  It is
a definitive reference to the AWK language as defined by the 1987 Bell
Labs release and codified in the 1992 POSIX Utilities standard.

   On the other hand, the novice AWK programmer can study a wealth of
practical programs that emphasize the power of AWK's basic idioms: data
driven control-flow, pattern matching with regular expressions, and
associative arrays.  Those looking for something new can try out
`gawk''s interface to network protocols via special `/inet' files.

   The programs in this book make clear that an AWK program is
typically much smaller and faster to develop than a counterpart written
in C.  Consequently, there is often a payoff to prototype an algorithm
or design in AWK to get it running quickly and expose problems early.
Often, the interpreted performance is adequate and the AWK prototype
becomes the product.

   The new `pgawk' (profiling `gawk'), produces program execution
counts.  I recently experimented with an algorithm that for n lines of
input, exhibited ~ C n^2 performance, while theory predicted ~ C n log n
behavior. A few minutes poring over the `awkprof.out' profile
pinpointed the problem to a single line of code.  `pgawk' is a welcome
addition to my programmer's toolbox.

   Arnold has distilled over a decade of experience writing and using
AWK programs, and developing `gawk', into this book.  If you use AWK or
want to learn how, then read this book.

     Michael Brennan
     Author of `mawk'
  

まいける… mawk ほっぽりだしてなにやってんすか。

■_

■_ まだ続いてた

Ruby 初心者スレッド Part 40 

552 デフォルトの名無しさん [sage] 2011/01/11(火) 06:12:37 ID: Be: 
 オブジェクトの内容を参照するための情報を引数として渡しているのは間違いがない 
 ただ、それは「参照渡し」とは違う 
 
553 デフォルトの名無しさん [sage] 2011/01/11(火) 06:36:01 ID: Be: 
 参照渡しはC言語にしか存在しないのでC言語以外でこの言葉を使用するのを禁止するって法律に書いとけ 
 
554 デフォルトの名無しさん [sage] 2011/01/11(火) 07:15:52 ID: Be: 
 >>553 
 C 言語には「存在しない」が。全部値渡しだぞ、あれ。渡してる値が整数だったりポインタだったりするだけだ。 
 C++ や Pascal には参照渡しがある。 
 
555 デフォルトの名無しさん [sage] 2011/01/11(火) 07:29:37 ID: Be: 
 というか参照渡しとはなんぞやという面倒な話に 
 
 ある言語の概念を他の言語に無理矢理適用しようとするのやめようぜ 
 
556 デフォルトの名無しさん [sage] 2011/01/11(火) 07:39:52 ID: Be: 
 やっぱり紐だよ紐。 
 変数は荷札。引数は荷札と紐を渡す。 
 
559 デフォルトの名無しさん [sage] 2011/01/11(火) 10:12:05 ID: Be: 
 Cのポインタ渡しは参照渡しだろうという説はある 
 Cには参照渡しが「ないからこそ」、Cでのポインタ渡しは 
 ポインタ以外を渡す行為と対称して参照渡しと呼ばれるのだな 
 
 Cだけの世界では、>552的な意味で間違ってはいない 
 
 まあ、汎用な計算機科学っぽい事象かと思ったら 
 特定の言語実装べったりのローカル概念でしたというのは 
 稀によくある 
 
560 デフォルトの名無しさん [sage] 2011/01/11(火) 10:31:15 ID: Be: 
 単に誤用してるだけだな。 
 たまに俺の用法で辞書書き換えろとか言い出す困ったちゃんもいるが。 
 
561 デフォルトの名無しさん [sage] 2011/01/11(火) 11:13:22 ID: Be: 
 > Cには参照渡しが「ないからこそ」、Cでのポインタ渡しは 
 > ポインタ以外を渡す行為と対称して参照渡しと呼ばれるのだな 
 
 呼ぶな。 
 
 C++ には本物の参照渡しがあるし、早速混乱するぞ。 
 
562 デフォルトの名無しさん [sage] 2011/01/11(火) 11:18:39 ID: Be: 
 Cしかやらないのなら問題はないし、Cで終わる人も多かろう 
 
 というか値渡しだって「値を渡してるから略して値渡しなんだよね」と認識してる人が大多数だろう 
 「ポインタという名前の参照用情報を渡してるから略して参照渡しと呼ぶね」と認識することを責めることはできん 
 
563 デフォルトの名無しさん [sage] 2011/01/11(火) 11:26:34 ID: Be: 
 C++もやる人と同じプロジェクトに放り込まれて混乱するわけですな。 
 
564 デフォルトの名無しさん [sage] 2011/01/11(火) 11:26:43 ID: Be: 
 めんどくせえ… 
 
  ・ 不用意に略語にするな 
  ・ あなたのプログラミング上の造語はほぼ確実にどっかの専門用語だ 
  ・ 正しい語を使って話せ 
 
 でいすか 
 
565 デフォルトの名無しさん [sage] 2011/01/11(火) 11:28:42 ID: Be: 
 お前ら一体何十回同じ話ししてんのかと 
 技術解説+理解を促進させるサンプルがあれば 
 不正確な比喩表現なんて必要ない 
 
566 デフォルトの名無しさん [sage] 2011/01/11(火) 11:34:37 ID: Be: 
 >>565 
 説明表現を考えているわけではない 
 
 「それは~~が~~で~~~なわけだ」 
 「なるほど○○なんですね」 ← これ 
 「いや違う」 
 
 をなんとかしようなんとかできんなという話だ 
 
567 デフォルトの名無しさん [sage] 2011/01/11(火) 11:37:37 ID: Be: 
 >>566 
 いや違う~は~って意味だから覚えてね、でOKじゃん。 
 
568 デフォルトの名無しさん [sage] 2011/01/11(火) 11:38:11 ID: Be: 
 読むだけ時間の無駄。 
 
569 デフォルトの名無しさん [sage] 2011/01/11(火) 11:43:20 ID: Be: 
 基本、Cしか知らない人はRubyしか知らない人並みに害悪を撒き散らす 
 適当な壷の中にでも封印しておくのがよい

570 デフォルトの名無しさん [sage] 2011/01/11(火) 21:43:01 ID: Be:
    >>556
    紐ってどういう例え? 

571 デフォルトの名無しさん [sage] 2011/01/11(火) 21:45:22 ID: Be:
    その話もう終わってるから 

次はどこのスレでこの話題が出ててくるのでしょうか…ww


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

ホームへ


リンクはご自由にどうぞ

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