ときどきの雑記帖 i戦士篇

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

一つ前へ 2009年9月(中旬)
一つ後へ 2009年10月(上旬)

ホームへ

2009年09月30日

■_

・読んだ
最新ケータイを支える技術 ~超薄型・高性能の裏側をのぞく
最新ケータイを支える技術 ~超薄型・高性能の裏側をのぞく (テック・ライブ!)
気になったり印象に残ったところをざっと。

メタリック仕上げの塗料にはアルミが入っていて、電波に対するシールド効果が出てしまう。
折りたたみ式のケータイの開き方には「フリーストップ」と「セミオート」がある
日本はフリーストップ。海外はセミオート。
消費電力を減らすために、表示している画像の明るさによってバックライトの明るさを調節する
リーク電流
音楽を聴くための機器として使うもの
デジタル音楽プレイヤーにつづいて携帯電話
携帯電話での音楽再生は、以前はメインCPUで行っていたが、いまは補助的な専用LSIでやったり
ハード(専用LSI)の開発と並行(先行)しての開発ソフト開発
「オーバーヘッド」を嫌う日本の開発姿勢
iPhoneのようにまるっきり新しい操作体系を持たせるようなものは作りづらい
(アプリの入れ替えが大量になる)
「足枷」になる「過去の資産」
最新のハードウェアを生かし切れないソフトウェア。
「古い基盤」に「新しいもの」を積み上げる

・がーん
c.mosの日記::閉店します
Obj-Cに挫折したのも、やめる原因(^^; >仕事人さん
ううむ。

・多摩テック閉演
なにもかもみななつかしい…

■_ 求むメンター

Point-Free style: What is it good for? | OJ's rants

Point-Free style: What is it good for?

Posted on June 27, 2009, 21:49, by OJ

If you're not interested in what inspired this post, then skip this section and jump 
to the more interesting bits.

もしあなたがこの post によって inspire されることに興味がないのであれば
このセクションをスキップして興味のあるところに飛んでください。

A little bit of history…

ちょっとした歴史を…

Recently I've been delving into Haskell quite a bit. It's part of my apparently 
never-ending quest to learn as much as I can about as many languages as I can (well, 
those that appeal to me at least :)). While I love playing around with a language, 
toying with ideas, writing small programs, reading books, blog posts, etc it's not 
really the same as having an on-call expert to help and guide you.

わたしは最近、Haskell について少々詳しく調べたことがありました。それは決して終わらない
ことがはっきりしている冒険 (never-ending quest) であり、わたしに可能な限りの数多くの言
語を学ぶというものでした(そう、少なくともこれはわたしにはアピールするものなんです :))。
わたしはプログラミング言語で何かするのがとても好きでたとえば何かのアイデアを試してみる
とか、小さなプログラムを書く、本を読む、blog をポストするなどなどといったことをします。
これはあなたを助け導いてくれる on-call expert とはぜんぜん違うものです。

While I'm aware of, and frequently visit, the Haskell IRC channell I find that the 
level of understanding there is so great that my piddly noob questions tend to get 
lost amongst the bombardment of much more advanced & interesting discussions. In 
short, while I find it a great place to go, it's not a great place to find someone 
who's happy to help guide me through the maze and go over topics in quite a bit of 
detail while I annoy them with questions.

わたしが気にかけていて頻繁に訪れていたのがHaskell の IRC チャンネルでそたが、そこはわ
たしのくだらない質問 (piddly noob questions) をより高度で興味深いディスカッションでか
き消してしまうようなとても great な場所であることを思い知らされるところでした。手短に
いうと、わたしは  great place to go を見つけはしたのだけど、そこは喜んでわたしをガイド
してくれるような誰かを見つけるのには great な place ではなくてわたしが発する質問で彼ら
をいらいらさせてしまう場所だったのです。

Haskell is one of those languages where having a mentor is really beneficial. So I set 
about finding myself one. Thankfully, I found a rather helpful chap based in the UK, 
(he shall remain anonymous, as I don't want to violate the man's privacy), Peter 
Marks, who has been very forthcoming with information. He's humoured me and been 
incredibly patient so far, and I'm very grateful for his time.

Haskell はメンター (mentor) を持つことが非常に重要な言語の一つです。ですから、わたしは
自分のメンターを探しました。ありがたいことに、わたしは英国に住んでいるHaskell の情報に
ついてとても協力的な Peter Marks という非常に親切な方を見つけました(その方のプライバシ
ーを侵害したくはないので仮名にしておきます)。彼は信じられないくらい我慢強くわたしに合
わせてくれました。わたしは彼にとても感謝しています。

One of the questions that I asked him was:
わたしが彼に質問したことの一つにこういうものがあります:

    Why is it that everyone seems to strive to get their code into Point-Free style? I 
    can see how a lot of the implementations are more concise, but many of those lose 
    readability.

    なぜ誰もが自分のコードをポイントフリースタイル (Point-Free style) で書こうとするので
    すか? ポイントフリースタイルにするのがより一貫性のあるものだということはわたしにもわ
    かるのですが、読みやすさを大幅に失ってしまうのではないでしょうか。

    What is so special about it?

    ポイントフリースタイルのなにがそんなに特別なことなんですか?

The discussion that followed was really insightful. That is what has inspired me to 
write this post.

そのあとのディスカッションはとても示唆に富むものでした (insightful)。
そしてそれがこのポストを書くことをわたしに inspire させたのです。

Please note, any errors in this post are totally my own. They are not the fault of my 
mentor :)

あらかじめお断りしておきますが、このポストにある間違いはすべてわたし自身に帰するものです。
記述に間違いがあったとしてもそれはわたしの mentor の過ちではありません :)

The purpose of the post: Why aim for Point-Free style?
(このポストの目的: なぜポイントフリースタイルにするのか?)

So it is just me, or does anyone else out there feel that there's a bit of a “thing” 
going on for Point-Free style? Sometimes I share my terrible code with people and I 
get shunned when it's not Point-Free and it could be.

So it is just me, or does anyone else out there feel that
there's a bit of a “thing” going on for Point-Free style?
まさにわたしのことですし、

わたしは自分の酷いコード (terrible code) を他の人と共有し
それがポイントフリーにできるのにしていなかったりしたときには
わたしは shunned していたのです。

Anyone? (みんな?)

I hope it's not just me :) Let's start with taking a quick look at what Point-Free 
style actually is.

わたしだけではないことを望みます :)
ポイントフリースタイルが実際にどういうものなのかについて見ていきましょう。

So what is Point-Free style? (結局、ポイントフリースタイルってなんなわけ?)

If we take a look at the Wikipedia we can see that..

Wikipedia でポイントフリーについて調べると次のようなことが書かれています

    Tacit [point-free] programming is a programming paradigm in which a function definition 
    does not include information regarding its arguments, using combinators and function 
    composition (but not ?-abstraction) instead of variables.

    関数定義においてその関数に関係する引数についての情報を含めず、変数の代わりにコンビネーター
    (combinators) や関数合成 (function compositon) を使うようなプログラミングパラダイム。

Simple eh? :) In essence, it basically means that your function definition doesn't 
reference any of its arguments/variables. For a crass definition, think point == 
argument and it should make sense.

単純ですね? :) In essence, ポイントフリーとは、基本的には
あなたが関数定義をするときにその関数の引数や変数を一切参照しないということです。
そしてわたしたちは関数に対する引数を直接参照することなしに関数を記述します。
Haskell やこの機能をサポートするその他の言語に馴染みのない人たちのために
例を挙げてみることにしましょう:

-- sum : take a list of numbers and add them all up to get a total
-- start with the base-case: an empty list
--  数値のリストを受け取り、それらすべてを加算して合計を求める
sum [] = 0
sum (x:xs) = x + sum xs

We can see that the above function is written in such a way that the arguments passed 
into the function are actually referenced in the body of the code. This is how a 
standard imperative programmer would write this function if he/she was new to Haskell. 
If we instead used a fold, we could define it like so:

この例にある関数ではその引数を関数本体のコードの中で実際に参照するやり方で書かれている
ことがわかります。このやり方は標準的な命令型プログラマー (standard imperative 
programmer) がHaskell にあまり慣れていないときに関数をこのように書くだろうというもので
す。ここで fold を使うようにすると関数の定義を次のようにできます:

sum xs = foldr (+) 0 xs

This does exactly the same thing as the previous definition, but as you can see the 
grunt work is done by the fold function. Now that we have this definition, we can 
easily move to Point-Free style:

これは前の定義と全く同じものなのですが、見てわかるように grunt work は fold 関数がやっ
ています。このとき、この関数定義をポイントフリースタイルにするのは簡単にできます。

sum = foldr (+) 0

Here we can see that no reference is made to the arguments of the function. Since we 
haven't referenced any “points”, we have a Point-Free implementation.

ここでわたしたちは関数の引数が参照されないようにされているということを確認できます。
一切の“ポイント”(points)を参照していないので、ポイントフリーな実装を得たというわけです。

Awesome. Cool. Sweet. Nifty.
素晴らしい。クール。いいね。イカす。

But what does it give me? Why is it better?
でもこれがわたしにとってどんな利益をもたらすの? なにが良いの?

Why use Point-Free style? (なぜポイントフリースタイルを使うの?)

This section is based totally on my own opinion and is not an official definition :) I 
think that Point-Free style fits in the same category as many other coding patterns 
and styles, and that it's usually down to the individual programmer to determine the 
when and the why. So take my view with a pinch of salt.

このセクションは全体的にはわたし自身の意見に基づいているものであり、公式の定義ではあり
ません :)わたしはポイントフリースタイルがほかのコーディングパターンやコーディングスタ
イルのようなものと同じカテゴリにフィットすると考えているからです。そしてそれは、So 
take my view with a pinch of salt. 手短に書くと、ポイントフリースタイルでは書き手に対し
て“what” ではなく “how”に焦点を当てさせるようになります。

It might be just me, but imperative programs seem to have a large focus on the data. 
The code which operates on the data is lost within a plethora of code that isn't 
necessarily specific to what the program needs to do. I've found that functional 
programming tends to be very different, at least in Haskell. Haskell lets me focus on 
what it is I need to do, and I feel that Point-Free is another step in the same 
direction. Is this good? I think so :) But I'll let you decide.

ひょとしたらこれはわたしだけかもしれませんが、命令型のプログラム (imperative program) 
というのはデータに対する large focus を持っているように思われるのです。データに対して
操作を行うコードは、プログラムが行う必要のあることを特定する必要のないコードの 
plethora の中で失われています。わたしは関数型プログラミングが非常に異なる傾向にあるこ
とに気づきました。少なくとも Haskellでは。Haskell はわたしにわたしが行う必要のあること
について焦点を当てさせて、わたしはポイントフリーが同じ direction の中のもう一つのステ
ップであると感じていました。これはよいことではないでしょうか?わたしはそう思っています :) 
しかし判断はあなたにお任せします。

As well as the focus on the what I've found that aiming for a Point-Free solution can 
aid in helping you understand your problem better. This claim sounds like fluff, so 
let's go through an example and hopefully you'll see what I mean.

As well as the focus on the what
I've found that aiming for a
Point-Free solution can aid in helping you understand your problem better.
Point-Free solution はあなたが自分の問題をよりよく理解することを手助けするかもしれない
この主張は fluff のように聞こえるので、
例を挙げてわたしが言っていることをあなたが理解できることを期待します。

Where Point-Free helped me get a better understanding
(ポイントフリーがわたしの理解をより一層助けるところ)

Haskell developers use the composition operator (.) a lot. It actually aids in 
creating Point-Free style. I love the irony here. We add points (.) to remove points 
(arguments).

Haskellの開発者たちは composition operator (.) を多用します。それは実際にはポイントフ
リースタイルの実行を手助けします。わたしはこの irony が大好きです。わたしたちはポイン
ト(引数)を取り除くためにポイント((.))を付加しているのです。

Anyway, the composition operator's definition, according to Prelude is:

いずれにしても、composition operator の定義は Prelude によれば次のようなものです:

(.)       :: (b -> c) -> (a -> b) -> a -> c
(.) f g x = f (g x)

This operator takes two functions and produces a function which is composed of the two. 
This function takes the output of one function and sends it through as the input to 
another function, returning the result of that call.

この演算子は二つの関数を取り、それらを compose した関数を返します。
結果として得られた関数はある関数の出力を受け取って
それを別の関数の入力として送ります。そして呼び出した結果を返します。

This is really handy. We can do some interesting things like:

これはとても便利です。次のような面白いことができます:

ghci> let doubleAndAdd5 = (+5) . (*2)
ghci> doubleAndAdd5 20
45
ghci> :m +Data.List
ghci> let sumColumns = map sum . transpose
ghci> sumColumns [[1,2,3],[4,5,6],[7,8,9]]
[12,15,18]

Very handy indeed. While handy, it doesn't necessarily allow us to do everything we 
might want to do. One example is handling cases where we want to compose a function 
where the right-hand function takes two arguments instead of one.

とても handy で役に立ちます。handy である一方で、わたしたちが行いたいと望むかもしれな
いすべてのことを行えるように許可する必要はありません一つの例が右辺にある関数が引数を一
つではなく二つとるような関数をcompose したいケースに対処するというものです。

So if we wanted to create a function that would take two values, add them together and 
double the result, all while using Point-Free style, we'd like to do something like 
this:

ですからわたしたちが引数を二つ取る関数を作り出したいのであれば、二つの引数を足し合わせ
てからその結果を二倍すればよいのです。全部をポイントフリースタイルを使ってやってみると
次のようなものになるでしょう:

ghci> let addAndDouble = (*2) . (+)

:1:20:
    No instance for (Num (a -> a))
      arising from a use of `*' at :1:20-21
    Possible fix: add an instance declaration for (Num (a -> a))
    In the first argument of `(.)', namely `(* 2)'
    In the expression: (* 2) . (+)
    In the definition of `addAndDouble': addAndDouble = (* 2) . (+)
ghci>

As you can see, ghci doesn't like it. And rightly so! This is because the composition 
operator's signature is:

見ての通り、ghciではうまくいきません。 And rightly so!
これは composition の演算子のシグネチャが次のようになっているためです:

(.) :: (b -> c) -> (a -> b) -> a -> c

That is:

   1. It takes an argument which is a function which takes a value of type b which 
      returns a value of type c
      型 c の値を返す型 b の値を取る関数である引数を一つ取る

   2. It takes a function which takes a value of type a which returns returns a value 
      of type b
      型 a の値を取って型 b の値を返す関数を返す関数を一つ取る

   3. It returns a new function which takes a value of type a and returns a value of 
      type c

      型 a の値を取って型 c の値を返す新しい関数を返します。

This doesn't work in our case, as we want our right-hand function to take two 
arguments. That is, we want a type signature that looks like this:

これはわたしたちのケースではうまく動作しません。それは右側の関数で二つの引数を取るよう
にさせたかったからですつまりわたしたちが欲していた型シグネチャは次のようなものだったの
です:

foo :: (b -> c) -> (a -> a1 -> b) -> a -> a1 -> c

So everywhere we had (a -> b), what we really want is (a -> a1 -> b). Given 
that we don't have an operator that does that for us, let's define one. We'll start 
with the definition of the (.) operator and work towards a function that does what we 
need.

ですから (a -> b) としていたすべての場所で、本当に望んでいたものは
(a -> a1 -> b) なのです。わたしたちのために仕事をする定義されていない演算子を
与えて定義してみましょう。(.) 演算子の定義から始めて、わたしたちが必要とすることを行
う関数にしていきます。

-- here is the composition operator again
--  composition 演算子再び
(.) f g x = f (g x)
-- here's our new operator's definition
--  わたしたちの新しい演算子の定義
(.^) f g x y = f (g x y)

Simple! Let's see what ghci says about it:
シンプルですね! ghci ではどうなるか見てみましょう:

ghci> let (.^) f g x y = f (g x y)
ghci> :t (.^)
a :: (t2 -> t3) -> (t -> t1 -> t2) -> t -> t1 -> t3

Looks good! This is exactly what we need. Now that we have a working function, let's 
aim to write this in Point-Free style. We do this by breaking down the function slowly 
and eliminating arguments by moving them to the far right hand side of the function 
definition.

いいですね! これはわたしたちが必要としていることそのものです。いまやわたしたちは動作す
る関数を手に入れましたから、これをポイントフリースタイルで書いてみましょう。わたしたち
はこれをこの関数を slowly にブレークダウンして、引数を関数定義の右辺のさらに外側に移動
することによって消去するという手順で行います。

The first argument to get rid of is ‘y', as this is the last argument passed in:

取り除くべき最初の引数は 'y' です。これは最後の引数として次のように渡されています:

-- start by moving y to the right
-- y を右側に動かすことから開始
(.^) f g x y = f (g x y)
-- becomes
-- こうなります
(.^) f g x y = f . (g x) $ y

These are functionally equivalent, and now that ‘y' is out on it's own, we can drop 
it from our function definition:

これらは機能的には等価なもので、'y' はこれで外側に出ましたから、関数定義から取り除くこ
とができます:

ghci> let (.^) f g x = f . (g x)
ghci> :t (.^)
(.^) :: (b -> c) -> (t -> a -> b) -> t -> a -> c
ghci>

Excellent, we're a step closer. Now we need to do the same with ‘x'. This takes a 
little more fiddling:

すばらしい。we're step closer.
今度は同じことを 'x' について行う必要があります。
これはもう少し fiddling になります。

-- we need to take the original definition
--   オリジナルの定義を持ってくる必要があります
(.^) f g x = f . (g x)
-- and change it so that it uses prefix notation instead of infix
--   そしてそれを中置記法ではなく前置記法を使うように変更します
(.^) f g x = (.) f (g x)
-- which is the same as
-- これは次のものと同じで
(.^) f g x = ((.) f) (g x)
-- what we're doing is calling g with x and applying the result to f
-- わたしたちが行っているのは x を引数とする g の呼び出しとその結果のf に対する適用です
-- and hence we can compose the composition of f with the call to g
-- そしてそれによって f の composition を g の呼び出しと compose することができます
-- giving us the following
--  次のようなものを与えると
(.^) f g x = ((.) f) . g $ x
-- finally leaving us with
--  最終的な結果はこうなります
(.^) f g = ((.) f) . g

Phew :) I hope you can see the progression. We've managed to move x out of the picture, 
so now we're down to a fairly crazy looking definition. Let's see what ghci has to say:

Phew :) あなたがこの progression を理解できると良いのですが。わたしたちは x を定義から
無くそうとして、その結果こうして fairly crazy looking definition にたどり着きました。
Let's see what ghci has to say:


ghci> let (.^) f g = ((.) f) . g
ghci> :t (.^)
(.^) :: (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c

So we've got rid of two variables, but there are still two more to go! Remember, ‘f' 
and ‘g' are still variables, they just carry functions. So let's get rid of ‘g':

わたしたちは二つの変数を取り除きましたが、まだ三つ以上変数が残っています! ここで、
'f' と 'g' はまだ変数であるということを思い出してください。これらは単なる carry 関数で
す。それでは 'g' を取り除いてみましょう:

-- start with what we had before
--   以前の結果から開始
(.^) f g = ((.) f) . g
-- change to prefix notation again
--   再度前置表記に変更する
(.^) f g = (.) ((.) f) g
-- and drop g
--  g を落とす
(.^) f = (.) ((.) f)

This is looking rather crazy :) Again, let's make sure we haven't done anything stupid:

これはとっても crazy に見えますね :)
再度、わたしたちがおバカなことをやっていないことを確認しましょう:

ghci> let (.^) f = (.) ((.) f)
ghci> :t (.^)
(.^) :: (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c

Excellent. We've still got what we need. One more point needs to be dropped, so let's 
get rid of ‘f':

すばらしい。わたしたちにはまだ必要とされていることがあります。
もう一つ drop する必要のある引数があります。
では 'f' を取り除いてみることにしましょう:

-- start with what we had before
-- 以前のところから始めます
(.^) f = (.) ((.) f)
-- which means that we're composing a composition with a function composed of f and something else
--  f と何かを compose した関数と composition を compose するということです
(.^) f = (.) . (.) $ f
-- and we finally drop f
-- そして最後に f を drop します
(.^) = (.) . (.)

Isn't that just crazy! Let's again check ghci:

ghciで再度確認してみましょう:

ghci> let (.^) = (.) . (.)
ghci> :t (.^)
(.^) :: (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c

So there we have it, our operator completely in Point-Free style.

このように、わたしたちの演算子は完全にポイントフリースタイルです。

This is where the penny dropped for me. The whole exercise of moving through to 
Point-Free made me really understand what it was I was doing in the first place. The 
final definition makes it very clear. We're composing two separate compositions.

This is where the penny dropped for me.
ポイントフリーに変形するというエクササイズを通じて
わたしはそれが最初に自分がおこなっていたものだったことを本当に理解しました
最終的な定義はそれを非常に明確なものにしました。
わたしたちは二つの分かれた compositions を compose しています。

Let's see if our function behaves itself using the example we listed above.

わたしたちの関数がどのように振舞うのかを上でリストにあげた例を使って見てみましょう。

ghci> let addAndDouble = (*2) .^ (+)
ghci> :t addAndDouble
addAndDouble :: Integer -> Integer -> Integer
ghci> addAndDouble 10 15
50
ghci> addAndDouble 21 3
48

It does exactly what we need it too.

これもまたわたしたちが必要としていることそのものをおこなっています。

Conclusion (結論)

To sum up, Point-Free helps you tidy your code into more concise implementations which 
tend to aid you in understanding what it is you are trying to do. I feel it really 
helps you focus on what you're doing as opposed to what you're doing it to. It's 
down to you to determine whether you feel this is a good thing or not!

要約すると、ポイントフリーはあなたが自分のコードを tidy して
何をしようとしているものなのかを理解しやすいような
より concise な実装にするための手助けをします。
I feel it really helps you focus on what you're doing as opposed to what you're doing it to.
It's down to you to determine whether you feel this is a good thing or not!


It is ultimately down to the developer to dictate when it should be used. There are 
definitely cases where the resulting function might not actually help in making things 
clearer. But on the whole, Point-Free style seems to help me understand what it is I'm
doing (or, arguably, not doing).

It is ultimately down to the developer to dictate when it should be used. 
開発者に結果として得られた関数が明快に理解するのを助けないことがある場合も確かにあります。
しかし全体としては、ポイントフリースタイルは
自分が何をしようとしているかを自分自身が理解するのを助けてくれるように
思えるのです。

Of course, you could just get sick and tired of trying to come up with variable names, 
in which case Point-Free is the bomb :)

もちろん、うんざりして変数名を探しだそうという試みに疲れてしまうだけかもしれません。
その場合は Point-Free が爆弾だったのでしょうね :)

■_ ばぐ

ようやく潰した。が。GNU regex と鬼車の動作の違いが気になる (で、鬼車の動作のほうが理屈に合ってるような気はする)。

■_ 本日の巡回から

2009年09月29日

■_

・まだじっくりとは読んでないんですが
楽しげな数学本を発見。 数学戦士―マセマティカ王国の秘法

・読みたい
が、買うのもアレだし図書館に入るか微妙だし。
本土決戦幻想 オリンピック作戦編   昭和史の大河を往く第七集
本土決戦幻想 コロネット作戦編 昭和史の大河を往く第八集

・買った
蘭陵王
この小説の主人公のような人物は大好きなので早く読もう。
油断してたら 小説フランス革命4 議会の迷走< img src="" alt="議会の迷走 (小説フランス革命 4)" /> が出ていたので買う。 というかその前の巻も積読してたので急いで読んでいるところ。
聖者の戦い (小説フランス革命 3)
表紙はタレイランで、確かに登場してるんだけど、ミラボー辺りのほうが活躍しているような 印象を受けてしまうのはなぜだろう?w

■_ 肩書き

What's the coolest startup programmer job title? - Stack Overflow から、プログラマーの肩書きにどんなのがいいかとかそんなの。 名称だけ抜き出して、アルファベット順に並べ替えています。 What's the coolest startup programmer job title?

  1. 0110001101101111011001000110010101110010
    #分からない人にヒント: $_.scan(/.{1,8}/){|c|$><<c.to_i(2).chr}
  2. Analyst I
  3. Antigrammer
  4. Apprentice to Jon Skeet
  5. Assembly Astronaut
  6. Automator automate
  7. Better Still
  8. Bhagwan Shree Programastra
  9. Bit Director
  10. Bit Twiddler
  11. Black Collar Coder
  12. Blue Collar Coder
  13. Bug Zapper
  14. Chief Craftsman
  15. Chief Hacking Officer
  16. Chief propellerhead
  17. Code Magician
  18. Code Monkey
  19. Code Slinger
  20. Code Warrior
  21. Codemaster
  22. Coding Extraordinaire
  23. Coding Zombie
  24. Computational Linguist
  25. Conqueror of Evil
  26. Cowboy Coder
  27. Creative Director
  28. Creative Technologist
  29. Creator of Worlds.
  30. Creator of the Functionality
  31. Da Shiznit
  32. Dark Lord of Quality
  33. Destroyer of the Bug
  34. Director of Doing Things Better
  35. Director of Inhuman Resources.
  36. Engineering Coding Ninja Zombie Monkey Transmitter
  37. Engineering Ninja
  38. Enterprise Synergy Consultant
  39. Eponymous
  40. Evil Genius
  41. Founder and Junior Vice President Compu-Global-Hyper-Mega-Net
  42. Grand Master Architect
  43. Great Voodoo Master
  44. Grey Collar Coder
  45. Hack Prime
  46. JOAT (Jack of All Trades)
  47. Jedi Knight
  48. Jon Skeet
  49. Keeper of the Quality
  50. Key maker
  51. Luddite
  52. Man With Whip
  53. Master Blaster
  54. Master Chief
  55. Master Shit Solver
  56. Master of Interweb Experiences
  57. Mega Sultan.
  58. National programming team leader
  59. Point-Guard-Convergence-Specialist!
  60. President of Strategic Insanity
  61. Programmer-at-Arms.
  62. Protocols Maven
  63. Purveyor of Fine Software
  64. RP (Renaissance Programmer)
  65. Resident Genius
  66. Rich Internet Solutions Developer
  67. Rocket Surgeon
  68. SQL Guru Ninja
  69. Sara Chipps
  70. Senior Frost Giant
  71. Senior Vice Master of the Code
  72. Senor developer
  73. Sir Codes A lot
  74. Smack Foo Master
  75. Software Architect
  76. Software Craftsman
  77. Software Developer
  78. Software Engineer
  79. Software Neurosurgeon.
  80. Software Ninjaneer
  81. Software Samurai
  82. Software Simian
  83. Supreme Overlord
  84. Technomagician
  85. Tester
  86. The All-In-One
  87. The Compiler
  88. The Setup and the Deployment
  89. Tool Hand
  90. Toolsmith
  91. True Believer
  92. Uber Coder
  93. Ultra Mega Sultan
  94. White Collar Coder

Ninja とか Samurai とかおまいらわ…w

■_ 演算子(perl 6)

前回気がつかなかったのだけど、なんか楽しいことしてない?

Perl 6
Perl Table Index

    * !< - not less, synonym for ">="
    * !<= - not less or equal, weird synonym for ">"
    * != - compare op, true if numeric unequal, short for "!=="
    * !=:= - compare op, tests negated on binding
    * !== - compare op, tests inequality in numeric context, negated form
    * !=== - compare op, tests identity, negated form
    * !> - synonym for "<="
    * !>= - synonym for "<"
    * !~~ - negated smartmatch operator
    * !eq - synonym for "ne"
    * !eqv - negated form of dynamic equivalence
    * !ge - synonym for "lt"
    * !gt - synonym for "le"
    * !le - synonym for "gt"
    * !lt - synonym for "ge"

    * <= - less than or equal, numeric comparison operator
    * <== - leftward pointing feed operator
    * <=> - numeric less-equal-greater comparison for Order class

    * =:= (Op) - compares binding, if both vars are bound to same memory location
    * == (Op) - equality of value (numeric)
    * === (Op) - equality of value and type
    * => (Op) - pair (and hash) constructor, fatarrow
    * > (Op) - greater than, numeric comparison operator; ends grouping with autoquoting (formerly qw())
    * >= (Op) - greater than or equal, numeric comparison Op

    * ~~ - smartmatch operator, compares (almost) all data types

    * eq - equal, string comparison
    * eqv - compares the dynamic state of objects and values, in contrast with static ===

    * ge - greater than on equal, string comparison
    * gt - greater than or equal, string comparison

    * le (comparison op) - lower than or equal, string comparison
    * lt (string comparison op) - lower than, string comparison

ある演算子に!を引っ付けた「演算子」があらかじめ定義されているということだよね。これ。 gt (より大きい) を否定した形の !gt (等しいか小さい)とか。 わかりやすいっちゃあわかりやすい? !(foo gt hoge) → foo !gt hoge とか。んー。

■_

うーむ。


この会社辞めようと思った腐れ上司の一言0x27 
60 仕様書無しさん [sage] 2009/09/28(月) 22:28:34 ID: Be:
    上司つーか先輩だけど、午前中に、お前のPCから開発中のシステムで、こういう操作をやってみろって言うんで、
    言われたとおりやって、バグって、
    「そこでもバグるか、俺のPCでもバグるけど、あそこのPCからだとバグらないんだよ、環境がウンヌン」みたいな話。

    自分でも同じ手順で操作して、怪しい箇所をステップ実行して、1,2分でバグの箇所を発見。
    でも、ふだん俺がバグを教えると機嫌が悪くなるような先輩だし、特に俺に意見を求めてるわけでもないので、
    それは知らせなかった。

    で、終業ちかくなって、先輩のあたりで3人くらい集まって「最新のソース取ってる?」「あそこのDBに接続してるとバグる」とか
    わいわいやってて、まだ解決してないのかってビックリ。
    はたで聞いてると、正解にかすりもしないっていうか遠ざかっていくので、さすがにこれはと思って教えてあげた。

    その先輩、こういう手順だとバグる、こうだとバグらない、とか延々とやってそれでバグの原因を推測しようとしてるのな。
    再現率100%のバグで、デバッガとかもふつーに使えるし「あーイライラする、そんなもん、ささっと直接見ろや!」 とオモタ今日の出来事。 

61 仕様書無しさん [sage] 2009/09/28(月) 23:04:50 ID: Be:
    午前中に分かって終業近くまで教えないとか何やってんだよ
    不機嫌になるからとか仲良し倶楽部のノリで過ごしてんじゃねーぞ 

62 仕様書無しさん [sage] 2009/09/28(月) 23:11:08 ID: Be:
    なんという馬鹿なブラックボックステスト・・・ 

63 仕様書無しさん [sage] 2009/09/28(月) 23:11:40 ID: Be:
    わかんなかったら悩んでないで訊きにこいよ。

64 仕様書無しさん [sage] 2009/09/28(月) 23:14:58 ID: Be:
    は? 

65 仕様書無しさん [sage] 2009/09/28(月) 23:18:58 ID: Be:
    >>61
    人の仕事に首をつっこむべきではないと教わらなかったか? 

66 仕様書無しさん [sage] 2009/09/28(月) 23:42:26 ID: Be:
    そんなくだらない事教わらないね

    >>60の状況はほんの一時的だけど
    上司(先輩)に首つかまれてそっちの方へ顔を向けさせられた状況だろ
    だったら自分のわかった範囲のことは報告すべきだ 

67 仕様書無しさん [sage] 2009/09/28(月) 23:46:17 ID: Be:
    それで機嫌が悪くなるってんなら
    タイミングが悪いか言い方が悪いか上司(先輩)の頭か性格が悪い

    いずれにしろ「仕事」なんだから
    なすべきことを曲げちゃダメだ 

68 仕様書無しさん [sage] 2009/09/28(月) 23:46:55 ID: Be:
    勝手にデバッグするな
    とか理不尽な怒りを買いたいのですねわかります 

69 仕様書無しさん [sage] 2009/09/28(月) 23:54:32 ID: Be:
    出した成果を理解出来る相手なら、躊躇なんて誰もしないだろう
    要するにバカって事さw 

70 仕様書無しさん [sage] 2009/09/29(火) 00:15:41 ID: Be:
    >>60の先輩のCのソースを眺めてたら、

    char hoge[100]; を、memset(hoge, 0, _MAX_PATH); と初期化してるとか、
    strncpy()を使ってるけど、バッファサイズ最大長のデータがきたとき、0をつけてないとか、
    つけているところでも、バッファ長 + 1のところにはみ出してつけているとか、
    バグっているけど、表面化してないような箇所がいっぱいあった。

    数が多いし、基本的に動いているし、指摘するのは躊躇するなぁ。

71 仕様書無しさん [sage] 2009/09/29(火) 00:20:49 ID: Be:
    >>70
    そりゃー関わらないようにするべきだな。

    混ぜるな危険!のレベル。 

72 仕様書無しさん [sage] 2009/09/29(火) 00:22:42 ID: Be:
    嫌過ぎる…
    自分がどんなに完璧なコードを書いても
    領域破壊されたら自分の担当箇所でバグる可能性があるじゃないか 

73 仕様書無しさん [sage] 2009/09/29(火) 00:57:52 ID: Be:
    >>70
    ソースコードレビューしろよ…。

    システムテスト以降では、デバッガで解決するような事は少ないので
    あれこれ考えたり、ログ入れたりする方が有効な事が多い。
    なので >60 の事は独りよがりな奴と思っていたが、
    コード品質が >70 の状態なら、納得。 >60 の態度は正しい。

74 仕様書無しさん [sage] 2009/09/29(火) 02:02:31 ID: Be:
    数年前はXPとか五月蝿く雑誌とかに乗ってたのにな 

75 仕様書無しさん [sage] 2009/09/29(火) 03:20:21 ID: Be:
    わかってて指摘しないとか
    デスマが無くならない理由がわかった
    そんなこったからデジドカなんて言わて地位が向上しないんだよ 

76 仕様書無しさん [sage] 2009/09/29(火) 04:32:24 ID: Be:
    後輩が指摘するなんて生意気だ死ね

    って感じでリンチしまくるから新人がいつまで経っても伸びないんだよ。

77 仕様書無しさん [sage] 2009/09/29(火) 04:41:28 ID: Be:
    >>75
    指摘してもどうしようもない予感。
    >終業ちかくなって、先輩のあたりで3人くらい集まって
    こういう連中だしな。 

78 仕様書無しさん [sage] 2009/09/29(火) 08:56:58 ID: Be:
    気持ちがわからんでもない。
    1つ2つのバグならまだしも、くだらないバグが大量にあると
    注意する気もうせる。
    それが、他人のプロジェクトならなおさら。

79 仕様書無しさん [sage] 2009/09/29(火) 09:13:47 ID: Be:
    あんまり首突っ込むといつの間にか担当のような扱いされて
    本来の自分の仕事が回らなくなったりするからな 

80 仕様書無しさん [sage] 2009/09/29(火) 09:45:03 ID: Be:
    >>79
    そうそう。
    「分かるんでしょ?ならやってよ」

    いやいや、俺の担当じゃないし。
    俺も仕事ありますから・・・って話だよな。

81 仕様書無しさん [sage] 2009/09/29(火) 11:37:46 ID: Be:
    >>70
    先輩じゃなくって、その上の上司に申告せよ。 

82 仕様書無しさん [sage] 2009/09/29(火) 21:03:24 ID: Be:
    >>81
    上司にしてみれば、そんな管理上どうでもいいことをゴチャゴチャ言ってくる奴は鬱陶しい。 

83 仕様書無しさん [sage] 2009/09/29(火) 21:54:07 ID: Be:
    >char hoge[100]; を、memset(hoge, 0, _MAX_PATH); と初期化してるとか、
    これまずいっしょ
    VCのデバッグモードとかなら領域後方に余裕設けられてるからなんとかなるかも知れないけど
    hoge後方のメモリ壊してる 

84 仕様書無しさん [sage] 2009/09/29(火) 22:21:12 ID: Be:
    >>83
    ソースの先頭のほうで、
    char hoge1[100];
    char hoge2[100];
    char hoge3[100];
    :
    :
    みたいに大量に変数を宣言してるんで、hoge1からはみ出しても助かってる。
    hoge1, hoge2, hoge3と順番に処理してるんで、hoge1の初期化でhoge2が破壊されてても、
    その後にhoge2に値をセットしてるんで、表面的にはバグになってない。


85 仕様書無しさん [sage] 2009/09/29(火) 22:28:06 ID: Be:
    >>84
    多分経験から得た裏技なんだぜ・・・
    そんなマは嫌だけどな 

86 仕様書無しさん [sage] 2009/09/29(火) 22:45:54 ID: Be:
    >>83
    >これまずいっしょ
    んなこと、言われなくてみんなわかってるから。

87 仕様書無しさん [sage] 2009/09/29(火) 22:54:17 ID: Be:
    >>84
    MAX_PATHは256くらいだったはずから、hoge3までぶっ壊してるなw
    最後の変数の初期化をどうやってるか気になるところだw 

88 仕様書無しさん [sage] 2009/09/29(火) 23:01:00 ID: Be:
    >>87
    最後の2つがダミーなんだよ。きっと。 

89 仕様書無しさん [sage] 2009/09/29(火) 23:05:08 ID: Be:
    >>84
    ローカル変数が宣言順に領域確保される保証は無い。
    なので、コンパイルの度にルーレット回しているようなモノだな。 

90 仕様書無しさん [sage] 2009/09/29(火) 23:08:50 ID: Be:
    >>89
    さすがにコンパイラを変えない限りは一緒だろw 

91 仕様書無しさん [sage] 2009/09/29(火) 23:09:45 ID: Be:
    char hoge1[100];
    char hoge2[100];
    char hoge3[100];
    char hoge4[100];
    char hoge5[100];
    char hoge6[100]; //バグるので消すな
    char hoge7[100]; //バグるので消すな 

92 仕様書無しさん [sage] 2009/09/29(火) 23:13:15 ID: Be:
    // 消すとなぜか動かなくなる
    とかコメント系スレで見覚えがあるよね。

93 仕様書無しさん [sage] 2009/09/29(火) 23:17:35 ID: Be:
    理由は(書いた当人以外)みんなわかってるのに、誰も治さないものの一つ 

「基本的に動いている」つーのはなあ。 strncpy は使い方難しい(面倒くさい)からなあ。 strlcpy 使おうよ。標準関数じゃないけどw

■_ 本日の巡回から

■_ あともうちょい

かなりのところまで絞れたと思うんだけど、 今度はライブラリ(鬼車)の動作を確認しないといけないからなあ。 鬼車のバグとは思わないけど、GNU regexと予期していない非互換性があったのかもしれない。

■_ あれ

ひょっとしてこれって前にも翻訳本出てたっけ? まあ見つけたらちょっとチェックだ。 Amazon.co.jp: CERT Cセキュアコーディングスタンダード: Robert C. Seacord, 久保 正樹, 戸田 洋三: 本

2009年09月28日

■_

・今日は何の日
9月28日は「パソコンの日」だったそうです。


「とある科学の超電磁砲」の番宣での初春の表情の変化の描き方がいいなあなどと ヲタ丸出しのつぶやきをしてみる。

■_

推薦図書/必読書のためのスレッド 51 
828 デフォルトの名無しさん [sage] 2009/09/28(月) 02:03:25 ID: Be:
    プログラマ向けの数学の本や、論理学の推薦書はありますでしょうか?

829 デフォルトの名無しさん [sage] 2009/09/28(月) 02:29:34 ID: Be:
    数学の何を知りたいかにもよるが…
    コンピュータの数学とか、いかにして問題を解くかとか
    より実践的なのが良いならTAOCPとかハッカーのたのしみとか 

831 デフォルトの名無しさん [sage] 2009/09/28(月) 07:44:24 ID: Be:
    >>828
    全てにおいて入門レベルだが網羅的。

    離散数学-コンピュータサイエンスの基礎数学 (マグロウヒル大学演習)
    http://www.amazon.co.jp/dp/4274130053 

832 デフォルトの名無しさん [sage] 2009/09/28(月) 08:07:55 ID: Be:
    >>829
    コンピュータにどう数学が関連しているのか
    プログラムを書く上での数学的な基礎知識
    論理学は、もれなく条件分岐を正確に行うた
    めに磨かなければいけないと考えています。

    頂いた情報でアマゾン見てみます


    >>831
    数学基礎が適当で、大まかな基礎も学びたいと
    考えていますので有難いです。 

833 デフォルトの名無しさん [sage] 2009/09/28(月) 09:30:25 ID: Be:
    サーバー関係の知識がまったくないのですが
    入門向けの本って何ですか? 

834 デフォルトの名無しさん [sage] 2009/09/28(月) 09:34:02 ID: Be:
    サーバでなにするかによる。 

835 デフォルトの名無しさん [sage] 2009/09/28(月) 09:54:37 ID: Be:
    >>832
    数学とプログラミングの関連はいくつかあるけど、もし望んでいるのが、
    数学の知識を元に正確なプログラミングをしたい、あるいは、与えられた
    課題を正確に定義した上でそれをプログラムに落とし込みたい、だと仮定する。

    そうであるなら、論理/集合/関数が基礎になる。どれも高校数学レベルの知識。
    もしそれに不安があるのなら、まずは優しい入門書で、それらの思考法や
    表記法に慣れる事。たとえば、以下の書籍。
    ・論理と集合のはなし, 大村平著, 日科技連
    ・ろんりの練習帳, 中内伸光著, 共立出版

    数学的な基礎ができたら、次は二つの道がある。一つは課題を正確にとらえる
    「形式的仕様記述(formal description technique)」という道。Amazonでキーワード検索すれば
    いくつも書籍が見つかるから、自分に合ったものを選べばいい。たとえば以下の書籍。
    ・IEEEソフトウェア'88, 岩波書店 - IEEEの論文集
      この中の "仕様をきちんと書くには" バーランド・メイヤー著という論文
    ・ソフトウェア仕様技術の先進技法 - Z言語, B.ポター他著. プレンティスホール
    これらの書籍はどちらも論理/集合/関数の知識が前提になる。この先には、
    関数型仕様記述/論理型仕様記述/代数型仕様記述などへと続くが、すべてはここが出発点になる。

    (続く) 

836 835 [sage] 2009/09/28(月) 09:55:17 ID: Be:
    (>>835の続き)

    もう一つの道は数学的知識を直にプログラミングに生かす道。ここでは、CやJavaといった
    手続き型言語から離れ、関数型あるいは論理型のプログラミング言語の使い方に慣れる。
    たとえば以下の書籍。
    ・関数プログラミング, R.バトラー他著, 近代科学社
    ・Prologのソフトウェア作法, 黒川利明著, 岩波書店
    ・岩波講座 情報科学12 算法表現論, 木村泉他著, 岩波書店
    ・岩波講座 ソフトウェア科学17 モデルと表現, 米澤明憲他著, 岩波書店
    前の2冊はプログラミングの入門書。後の2冊はプログラミングという行為を数学(主に関数)的な
    観点で形式的に理解する方法を学ぶもので、少し難しくなるしラムダ計算の知識があれば望ましい。

    ここにあげた書籍はどれも自分が手にした書籍で、どれも古い物ばかり。正直なところ、
    最近の書籍の中からお勧めを紹介できないのが残念。ただ、Amazonもいいけど、専門書を扱う
    大きな書店や図書館で、自分に合った書籍と出会うまで散策するのが良い、という事だけは言える。

    # 他に推薦書があれば(たぶんあると思う)、挙げてくれ >>スレ住人さん達 

837 デフォルトの名無しさん [sage] 2009/09/28(月) 10:34:38 ID: Be:
    バトラーって誰やねんRichard.S.birdとPhilip.Wadlerがfusionしたのかよw 

838 デフォルトの名無しさん [sage] 2009/09/28(月) 11:05:26 ID: Be:
    >>832からすると>>835の前半だけでおk

    まあ勉強の方針が立たないだろうから
    情報処理技術者試験でも受けてみたらどうだろ 

839 835 [sage] 2009/09/28(月) 12:15:17 ID: Be:
    >>837

    あ、ホントだ。最初にバトラーと読み間違えていたらしく、今までずっとバトラー本だと思い込んでたw

    [>>836を訂正]
    X:>・関数プログラミング, R.バトラー他著, 近代科学社
    O:>・関数プログラミング, R.バード・P.ワドラー共著, 近代科学社 

840 デフォルトの名無しさん [sage] 2009/09/28(月) 12:44:52 ID: Be:
    関数プログラミングは原著の方、新しい版が出ているから読めるのならそっちが良いよ
    日本語訳はいくら何でも古すぎだし 

841 デフォルトの名無しさん [sage] 2009/09/28(月) 13:02:18 ID: Be:
    ぶっちゃけ高卒が主戦力なIT業界、
    それでなりたっているのだから、
    数学の知識なんて必要ない。 

842 デフォルトの名無しさん [sage] 2009/09/28(月) 13:19:35 ID: Be:
    必要ない人には必要ないだろうな 

843 デフォルトの名無しさん [sage] 2009/09/28(月) 13:48:50 ID: Be:
    「数学基礎」というのは、高校数学にそういう科目があるんだよ

    ある程度の数学的素養がないと発想は貧困になるし
    新しいものを吸収する力がなくなるけど
    現実的な線としては

    > 数学基礎が適当で、
    という人が>>835の後半、さらには>>836に進むのは、
    仮に進むにしてもかなり先のことになるだろう。

    さしあたっては「PROLOG入門」後藤滋樹 サイエンス社
    あたりを図書館で探してもらうのがいいと思う 

844 デフォルトの名無しさん [sage] 2009/09/28(月) 13:49:44 ID: Be:
    >>834何ができるかもわからないんです
    よろしくおねがいします 

845 デフォルトの名無しさん [sage] 2009/09/28(月) 13:54:28 ID: Be:
    >>828
    学問的な評価はわからないけど、私にとっては、以下の二冊がよかった。
    「論理と計算のしくみ」 萩谷昌己・西崎真也
    「知識処理論」 荻野達也
    同系列の本ということになるかも。 

846 デフォルトの名無しさん [sage] 2009/09/28(月) 14:00:24 ID: Be:
    >>841
    専門/高卒が主戦力なのは確かかもしれないけど、
    彼らに仕様を提示する側の立場にいる修士/学部卒でさえ、
    その多くが数学的な素養を持っていないことが問題なのさ 

847 デフォルトの名無しさん [sage] 2009/09/28(月) 14:03:00 ID: Be:
    プログラミングに役立つかどうかは別にしても
    論理学とか面白いよな
    昔はまったときは飯食うのも忘れてひたすら証明してたわ 

848 デフォルトの名無しさん [sage] 2009/09/28(月) 15:24:18 ID: Be:
    >>844
    ここんところの流れに悪ノリするなら、Prologでサーバ書くのが
    面白いんじゃないかな。 

849 デフォルトの名無しさん [sage] 2009/09/28(月) 20:07:10 ID: Be:
    >>846
    数学っていうか、全般的にコンピュータリテラシーから足りないような
    感じだよな。 

850 デフォルトの名無しさん [sage] 2009/09/28(月) 21:01:47 ID: Be:
    >>835
    皆様、丁寧に有難うございます

    >>論理/集合/関数
    なんとなくプログラム上で実用できる。と言ったレベルでしかありません。
    高校の数学は、まったくもって勉強していませんでした。

    >数学の知識を元に正確なプログラミングをしたい、あるいは、与えられた
    >課題を正確に定義した上でそれをプログラムに落とし込みたい、だと仮定する。
    はい、該当します。

    関数型言語… Lispは使えますが、やはりそれなりのレベルでしかりません。
    進んでいった後、見える世界がどう変わるか…面白そうですw

    まずは基礎からみっちり…ですね。
    多くの情報を頂き、有難うございます。 

851 デフォルトの名無しさん [sage] 2009/09/28(月) 21:19:25 ID: Be:
    >>865

    コンピュータを意識した論理学関連では

    萩谷 昌己,西崎 真也「論理と計算のしくみ」岩波書店(内容豊富)
    林 晋「数理論理学」コロナ社 (品切れ?)
    もうひとつの論理からプログラムへ
    林 晋,小林 聡 「構成的プログラミングの基礎」遊星社
    なお林晉のウエブから
    ”PX: A Computational Logic, S. Hayashi and H. Nakano,1988, The MIT Press”
    のPDFがダウンロードできたと思う。

    バーランド・メイヤーといえば
    「プログラミング言語理論への招待―正しいソフトウェアを書くために」アスキー(品切れ?)

    全部手っ取り早くやるのは
    大堀 淳 , ジャック ガリグ, 西村 進,田辺 誠 , 中島 玲二 , 長谷川 真人
    「コンピュータ・サイエンス入門」岩波書店 (品切れ)

852 デフォルトの名無しさん [sage] 2009/09/28(月) 21:21:59 ID: Be:
    >>851
    >>836へのアンカーtypo 


840 が言及している新しい版というのはこれでいいんでしょうか?
Introduction Functional Programming (2nd Edition) (Prentice Hall Series in Computer Science)

んで、functioanl progamming で検索したら結構面白そうなものが引っかかった。 F# の本が何冊も出てる(これからのものも含めて)けど、そんなに人気なんだろうか。
Monad (Functional Programming) Lambda-calculus, Combinators and Functional Programming (Cambridge Tracts in Theoretical Computer Science) Functional Programming in C#: Classic Programming Techniques for Modern Projects Real World Functional Programming: With Examples in F# and C#

■_ 本日の巡回から

■_ バグがつぶれん

ひとつは潰せたが、もうひとつの原因がつかめん。

2009年09月27日

■_

・うーむ 8bit年代記は買ってはいけない本ですよ: FAF特殊戦第5飛行戦隊装備班

■_ よく誤解されていること(C/C++編)

What are the often misunderstood concepts in C++? - Stack Overflow

C++ is not C with classes!

C++ はクラスつきのCじゃない

And there is no language called C/C++. Everything goes downhill from there.

C/C++と呼ばれる言語なんてない。


The difference between assignment and initialisation:
代入と初期化の違い

string s = "foo";    // initialisation
s = "bar";           // assignment

Initialisation always uses constructors, assignment always uses operator=
初期化は常にコンストラクターを使用し、代入は常に operator= を使う


Arrays are not pointers
配列はポインターではない

They are different. So &array is not a pointer to a pointer, but a pointer to an 
array. This is the most misunderstood concept in both C and C++ in my opinion. You 
gotta have a visit to all those SO answers that tell to pass 2-d arrays as type** !


C++ is a multi-paradigm language. Many people associate C++ strictly with OOP.
C++はマルチパラダイムの言語である。
多くの人がC++をstrictlyにOOPと結び付けてしまっている。


C++ is not C with string and vector!
C++は string と vector を持ったCじゃない!


C++ is not a typical object oriented language.

(ry

If you insist on doing oop with pointers, you'll usually have large (gigantic!) 
classes, with clearly defined ownership relationships between objects to avoid memory 
leaks. And then even if you do that, you're already too far from the Java/C# idiom of 
oop.

    Actually I made up the term "object-oriented", and I can tell you I did 
    not have C++ in mind.

    -- Alan Kay (click the link, it's a video, the quote is at 10:33)

Although from a purist point of view (e.g. Alan Kay), even Java and C# fall short of 
true oop

A pointer is an iterator, but an iterator is not always a pointer
ポインターはイテレーターであるが、イテレーターはいつでもポインターであるとは限らない

This is also an often misunderstood concept. A pointer to an object is a random access 
iterator: It can be incremented/decremented by an arbitrary amount of elements and can 
be read and written. However, an iterator class that has operator overloads doing that 
fulfill those requirements too. So it is also an iterator but is of course not a 
pointer.

これも頻繁に誤解されているコンセプトである。
あるオブジェクトへのポインターはランダムアクセスイテレーターである。
インクリメントやデクリメントすることができる。
任意の量の要素により
読み書きが可能。
しかし、
イテレータークラスは



I remember one of my past C++ teachers was teaching (wrongly) that you get a pointer 
to an element of a vector if you do vec.begin(). He was actually assuming - without 
knowing - that the vector implements its iterators using pointers.


site design and logo is c 2009 stackoverflow.com LLC; user contributed content 
licensed under cc-wiki with attribution required

■_



Twitter / ssc RiSK: More Effective C++ 読んでるけど, ...
More Effective C++ 読んでるけど,日本語が難しい。「参照はがし」にちょっとびっくり。 
dereference って,多分「間接参照」のことだよね…。

dereference と間接参照は無関係ではないけれども、同じものではありません。


Dereferencing Pointers
Dereferencing Pointers

A variable of type tex2html_wrap_inline73359 is said to point at an object of type T. What this really means is that the value of the tex2html_wrap_inline73359 variable is the address of another variable of type T. For example, in Figure gif the variable q is has type int*, i.e., it is a pointer to an int. The value of p is 1004, which is the address of the variable j.

To access the variable to which a pointer points, we must dereference  the pointer. E.g., to dereference the pointer q we write *q. Whereas q denotes the pointer variable itself, *q denotes the int to which the pointer points.

If we use *q in a context where an r-value is expected, then we get the r-value of the variable to which q points. E.g., since q points to the variable j, the assignment

i = *q;

takes the r-value of j (31) and assigns it to i.

Similarly, if we use *q in a context where an l-value is required, then we get the l-value of the variable to which q points. E.g., since q points to the variable j, the assignment

*q = 31;

takes the l-value of j (1004) and stores 31 at that location. Notice that the l-value of *q is identical to the r-value of q.


こんなの発見



C++ Labyrinth
dereference

もちろん、読者諸氏は、"dereference" の意味をご存じだろう。つまりは、 * 演算子のことであるが、C/C++ の世界において、この言葉ほど、 さまざまな訳語が当てられてきたものは他になかろう。私がこれまでに目にした 訳語を挙げていくと、

    * 参照剥がし
    * 参照外し
    * 逆参照
    * 間接参照
    * 参照分解

等々がある。*演算子がやっていることを考えると、「参照」という 中間段階を取っ払って、指している先の値を得るわけであるから、「参照剥がし」 あるいは「参照外し」というのが意味的には正しいように思われる。

…しかし、訳語としては、ちょっとイタダケナイのではないか? ということで、僭越ながら、ここで一つ、新たな訳語を提案させていただく。

「脱参照」

というのはいかがであろうか。ご明察どおり、"deconstruction" 「脱構築」からの パクリなのだが、Google で検索するかぎり、キーワード「脱参照」では、一件も ヒットしなかった。意外な感もあるが、まあ、プログラマというのは、ブツさえ 動いてくれれば、それが何と呼ばれようと気にしない人種だとも言えよう。

初出: 2001年3月1日


dereference の意味とは - 英和辞典 Weblio辞書
dereference
―【動】 《ポインター》 から参照先の値を取得する; 《変数やリンク》 の(表わす)参照を解釈する, 参照先のデータを取得する.
・This expression *ptr dereferences ptr to yield i as an integer. この *ptr という式によって (ポインター) ptr の参照先の値 i が整数として取得される. 《変数 ptr で表わされたアドレスに書かれている値を取得する》
・Cannot dereference non-pointer type. 《表示》 ポインター型でない変数を参照として解釈することはできません. / 間接参照演算子 ("*") のオペランドはポインター型でなければなりません.
・use this base URL to dereference relative URLs この基準 URL を使って間接 URL が指している場所にアクセスする
―【名】 参照先のデータの取得.
・a dereference operator 間接参照演算子《C 言語で ポインターで表わされるアドレスの値を取得する演算子 *》
・NULL (pointer) dereference ヌル(ポインター)の参照先を取得しようとすること《エラーになる》

dereference は上の定義を見てもわかるように動詞でもあるので、 dereference == 間接参照 にすると、翻訳するときに困ったりする(ことがある)ねんで?



Dereference Definition | Definition of Dereference at Dictionary.com
Computing Dictionary

dereference programming
To access the thing to which a pointer points, i.e. to follow the pointer. E.g. in C, the declarations

int i; int *p = &i;

declare i as an integer and p as a pointer to integer. p is initialised to point at i 
("&i" is the address of i - the inverse of "*"). The expression
*p dereferences p to yield i as an lvalue, i.e. something which can appear either on
the left of an assignment or anywhere an integer expression is valid. Thus

*p = 17;

would set i to 17. *p++ is not the same as i++ however since it is parsed as *(p++), 
i.e. increment p (which would be an invalid thing to do if it was pointing to a single 
int, as in this example) then dereference p's old value.

The C operator "->" also dereferences its left hand argument which is 
assumed to point to a structure or union of which the right hand argument is a member.

At first sight the word "dereference" might be thought to mean "to 
cause to stop referring" but its meaning is well established in jargon.
(1998-12-15)

2009年09月26日

■_

・ダムエー
オリジン、オールカラーなのはうれしいけどページ数が… 教えてください富野ですはマイクロバブルのはなし。

・絶望先生
アニメ三期も終わり。だいぶ新しいところも使ってきてるから、次は難しいかなあ。

・GA
四コマ誌連載の作品はとっとと終わっちまう喃。 ひだまりスケッチみたいに何回もやるのもあるけどw

■_ 演説ネタ

Lisp はあったけどScheme は初出?

Lisp Scheme Part28 
161 デフォルトの名無しさん [sage] 2009/09/26(土) 14:28:18 ID: Be:

    諸君 私はschemeが好きだ
    諸君 私はschemeが好きだ
    諸君 私はschemeが大好きだ

    MITが好きだ
    PLTが好きだ
    Biglooが好きだ
    Guileが好きだ
    Gaucheが好きだ
    Stalinが好きだ
    Ypsilonが好きだ
    Sigが好きだ
    Moshが好きだ

    Windowsで MacOSで
    Linuxで BSDで
    Solarisで HP-UXで
    AIXで IRIXで
    Monaで 黒板で

    この地上で実行される ありとあらゆるschemeプログラムが大好きだ 

162 デフォルトの名無しさん [sage] 2009/09/26(土) 14:30:12 ID: Be:
    命令列をならべたS式の手続きが 轟音と共にリストを吹き飛ばすのが好きだ
    空中高く放り上げられたリストがapply valuesでばらばらになった時など心がおどる

    filterの操る高階関数の述語が 要素を選択するのが好きだ
    悲鳴を上げて 燃えさかるリストから飛び出してきた要素を
    map (lambda (n) (...))で変換した時など胸がすくような気持ちだった

    アキュムレータをそなえた再帰の手続きが 末尾の再帰を最適化するのが好きだ
    恐慌状態の新兵プログラマが 既に()に達したリストを
    何度も何度もcdrダウンしている様など感動すら覚える

    t-nil主義の逃亡兵達が#f上にconsしていく様などはもうたまらない
    泣き叫ぶclist達が 私の降り下ろしたknilとともに
    金切り声を上げるkonsに ぱたぱたとfoldされるのも最高だ

    哀れなCommon Lisper達が 雑多な小機能で健気にもdisってきたのを
    R5RSのhygienic macroがgensymごと木端微塵に粉砕した時など絶頂すら覚える

    仕様策定の混乱に滅茶苦茶にされるのが好きだ
    必死に守るはずだったKISSの原則が蹂躙され ミニマリズムが犯され殺されていく様は
    とてもとても悲しいものだ

    純粋関数型言語の参照透過性に押し潰されて殲滅されるのが好きだ
    Haskellに追いまわされ 害虫の様に地べたを這い回るのは屈辱の極みだ 

163 デフォルトの名無しさん [sage] 2009/09/26(土) 14:33:47 ID: Be:
    諸君 私はschemeを 地獄の様なschemeを望んでいる
    諸君 私に付き従う大隊戦友諸君
    君達は一体 何を望んでいる?

    更なるschemeを望むか?
    情け容赦のない 糞の様なschemeを望むか?
    鉄風雷火の限りを尽くし 三千世界の言語を殺す 嵐の様なschemeを望むか?

    よろしい ならばschemeだ

    我々は満身の力をこめて今まさに振り下ろさんとする握り拳だ
    だがこの暗い闇の底で四半世紀もの間 堪え続けてきた我々に
    ただのschemeでは もはや足りない!!

    大schemeを!! 一心不乱の大schemeを!!

    我らはわずかに一個大隊 千人に満たぬ言語オタクにすぎない

    だが諸君は 一騎当千の古強者だと私は信仰している
    ならば我らは 諸君と私で総兵力100万と1人のハッカー集団となる

    我々を忘却の彼方へと追いやり 眠りこけている連中を叩き起こそう
    髪の毛をつかんで引きずり降ろし 眼を開けさせ思い出させよう
    連中に恐怖の味を思い出させてやる
    連中に我々のevalの音を思い出させてやる

    天と地のはざまには 奴らの哲学では思いもよらない事があることを思い出させてやる

    一千人の言語オタクの戦闘団で
    世界を燃やし尽くしてやる 

164 デフォルトの名無しさん [sage] 2009/09/26(土) 14:36:18 ID: Be:
    僕の肛門もdisられそうです><


165 デフォルトの名無しさん [sage] 2009/09/26(土) 15:13:56 ID: Be:
    >>161-163
    症状が落ち着いてきたら病院へ逝こうね。

166 デフォルトの名無しさん [sage] 2009/09/26(土) 15:38:34 ID: Be:
    >>164
    そこは Common だろう。 

167 デフォルトの名無しさん [sage] 2009/09/26(土) 16:25:46 ID: Be:
    >165
    ヘルシング OVAを見れば判るさ。 


171 デフォルトの名無しさん [sage] 2009/09/26(土) 21:32:57 ID: Be:
    >>167

    http://www.youtube.com/watch?v=QUX0SXbiW34

そういえば C++ 版ってあったっけ?

■_ むむむ


wgetを使ってみる - nuke - attack with nuclear weapons -
なかなかかっこいいので、全部貰ってくることにした。それにしてもたくさんありすぎる。

htmlを整形してとってきた。こんな感じ。

    wget http://2tunes.livedoor.biz/archives/51258878.html

    cp 51258878.html test.txt

    cat test.txt |sed 's/\.jpg"/\.jpg\n/g' > test2.txt

    cat test2.txt |sed 's/.*http/http/g' |grep "^http" > test3.txt

    cat test3.txt | grep -v '\-s.jpg'|grep '.jpg' >test4.txt

    cat test4.txt |awk '{print "wget " $0 }' > wget.sh

    sh ./wget.sh

ちょっとひっかかったのが、grep -v '-s' って箇所で、シングルクォートであっても、-s のよ
うな引数は grepが拾ってしまい、これがないので叱られていた。\ エスケープしてやるとOK.

[追記]

同じ事をやるのでも、やり方はいくつもあって、コマンド1発でシンプルなほうがいいですね。
コメント

Rocco 2009/09/26 20:20 awk (gawk) を使うのであれば、

$ gawk -v RS='[<> ="]' '/jpg/&&/imgs/{print $0}' 51258878.html

のようにすれば一度に抜き出せます。(落としているものがあったらごめんなさい)

ついでに、

$ gawk -v RS='[<> ="]' '/jpg/&&/imgs/{system("wget " $0)}' 51258878.html

で同時に落とすこともできます。

Rocco 2009/09/26 20:23
先ほどのコメントで system() 関数でくくったかどうかを忘れました。

$ gawk -v RS='[<> ="]' '/jpg/&&/imgs/{system("wget " $0)}' 51258878.html

であれば大丈夫だと思います。

nuke 2009/09/26 20:49
わー、すごいすごい。ありがとうございます。コマンド1行でいけちゃう
わけですね。自分のヘタレ具合が分かりました。orx..

-- でオプション引数の終わりを明示できるので、grep -v -- '-s.jpg' とか、 grep 自体のオプションに引数文字列を指定するための -e ってのがあるので grep -v -e '-s.jpg' とか書いたほうが良いと思う。 大昔から伝承されていた技には grep -v '[-]s' なんてのもw

Usage: grep [OPTION]... PATTERN [FILE] ...
Search for PATTERN in each FILE or standard input.
Example: grep -i 'hello world' menu.h main.c

Regexp selection and interpretation:
  -E, --extended-regexp     PATTERN is an extended regular expression
  -F, --fixed-strings       PATTERN is a set of newline-separated strings
  -G, --basic-regexp        PATTERN is a basic regular expression
  -P, --perl-regexp         PATTERN is a Perl regular expression
  -e, --regexp=PATTERN      use PATTERN as a regular expression
  -f, --file=FILE           obtain PATTERN from FILE

(略)
  -o, --only-matching       show only the part of a line matching PATTERN

あと、wget は取得対象の URLをファイルから与えることができて、 それは UNIXのツールに良くあるように - で標準入力からの入力と解釈されるので、

$ gawk -v RS='[<> ="]' '/jpg/&&/imgs/{system("wget " $0)}' 51258878.html

これだとwget をファイルの数だけ起動することになってよろしくないから オプション指定でパイプから食わせるようにして

$ gawk -v RS='[<> ="]' '/jpg/&&/imgs/' 51258878.html | wget --input-file=-

てな具合でいけるかと。

ん、GNU grep で -o オプション使えばgrep と wget ですみそうだなw 元ファイルがどういうフォーマットか正確にはわからないけど、たぶん grep -o 'http://[^"]*[^-][^s]\.jpg' あたりで。 でもこれだと f.jpg とか gg.jpg みたいなのは取りこぼしてしまうので、 無理せずに grep を二段構えにして、二段目で -s.jpg なパターンを弾く方が頭を使わないですむか。

■_

MIT の新入生向け講義で使うプログラミング言語が Scheme から Python に変わったという話で。

Dan Weinreb’s blog ≫ Blog Archive ≫ Why Did M.I.T. Switch from Scheme to Python?
Why Did M.I.T. Switch from Scheme to Python?

I've been seeing mail and blog postings, particularly from people in the Lisp
community, why MIT has switched from using Scheme to Python in the freshman core
curriculum for the department of Electrical Engineering and Computer Science.

特にLispコミュニティの人たちのなぜ MIT は department of Electrical Engineering and 
Computer Scienceの新入生向けコアカリキュラムで使う言語を Scheme から Python に切り替え
たのかということに言及したメールやblogへのポストをみました。

At the International Lisp Conference, Prof. Gerry Sussman gave a short impromptu talk 
explaining the new freshman curriculum.  Just to get a second opinion, I later called 
Prof. Jacob White, one of the designers of the curriculum and lecturers for the core 
courses.  (Digression: Jacob and I have been close friends since I was six years old!) 
He confirmed Gerry's description.

International Lisp Conference において、Prof. Gerry Sussman は新しい新入生向けカリキュ
ラムを説明する短い impromputs talk をしました。セカンドオピニオンとして、後ほど教授を
お呼びします。Jacob White はコアコースに関するカリキュラムやレクチャーの designer の一
人です。(Digression: Jacob と わたしは、わたしが6歳! の頃からのとても親しい友人です)彼
は Gerry の description を confirm しました。

http://www.international-lisp-conference.org/2009/index
http://www.eecs.mit.edu/ug/newcurriculum/index.html

Asking why they changed languages is, in some sense, the wrong question.

なぜ彼らが言語を変更したかということを問うこと、はある意味においては間違った質問
(wrong question)です。

The freshman software engineering course, since 1985, has been based on the book
Structure and Interpretation of Computer Programs (known as SICP), which uses Scheme.
The course is now nearly thirty years old.  Engineering has changed quite a lot in
thirty years.  Since 1995, Gerry and his co-author Prof. Hal Abelson have advocated
changing the freshman curriculum radically, not basing it on SICP.

1985 年から、新入生向けソフトウェアエンジニアリングコースではStructure and 
Interpretation of Computer Programs (known as SICP)という Scheme を使った本に基づいて
講義が行われていました。このコースは現在、約30年ほどの歴史があります。エンジニアリング
はこの 30年の間に大きく変化しました。1995年以来、Gerry と彼の co-author Prof. である 
Hal Abelson は新入生向けカリキュラムを劇的に変更したことを advocate していますが、これ
は SICP を basing するものではありません。

In 1980, computer engineering was based on starting with clearly-defined things
(primitives or small programs) and using them to build larger things that ended up
being clearly-defined.  Composition of these fragments was the name of the game.

1980年には、コンピューターエンジニアリングは(primitives や 小規模なプログラムのような) 
明確に定義されたことがらから始め、そしてそれらを使ってより大きなものを明確に定義された
形で構築していったのです。このような断片 (fragments) を集成することが  name of the 
game だったのです。

However, nowadays, a real engineer is given a big software library, with a 300-page
manual that's full of errors.  He's also given a robot, whose exact behavior is
extremely hard to characterize (what happens when a wheel slips?). The engineer must
learn to perform scientific experiments to find out how the software and hardware
actually work, at least enough to accomplish the job at hand.  Gerry pointed out that
we may not like it this way (”because we're old fogies”), but that's the way it is,
and M.I.T. has to take that into account.

しかし今日においては、本物のエンジニアには 300ページにも及ぶマニュアルつきの full of 
errors な巨大なソフトウェアライブラリが与えられています。彼らにはまた、正確な動作 
(exact behavior) を characterize することがとても難しい (車輪がスリップしたときに何が
起きるでしょう?) ロボットが与えられています。エンジニアはハードウェアとソフトウェアが
実際にどのように動いているのかを少なくとも自分の手で仕事を完了するのに十分なだけは(at 
least enough to accomplish the job at hand.)、理解するために学ばなければなりません。

Gerry pointed out that we may not like it this way (”because we're old fogies”),
but that's the way it is, and M.I.T. has to take that into account.

(自分たちは old forgies なので) わたしたちはこういったやり方を好まないだろうと
Gerry が指摘しましたが、
that's the way it is,  and M.I.T. has to take that into account.

The new approach also has the big advantage that it combines computer science with
electrical engineering, whereas the old one taught them as entirely separate
disciplines.  This way, students see how they interrelate.  Also, as Jacob points out,
some of the same macro-principles apply to both software and hardware, and the
students see this illustrated.  There is extensive lab work, making robots and mobile
applications.

新しいアプローチにはまた、古いアプローチでは完全に分かれていた disiplines と考えられて
いたコンピューターサイエンスと電気工学(electrical engineering) とを結びつけるという大
きなアドバンテージがあります。このやり方では、学生はそれらがどのように interrelate す
るかをみます。また、Jacob が指摘したように、macro-principles の一部をソフトウェアとハ
ードウェアの両方に適用し学生たちはこれが illustrated するものを観察します。There is 
extensive lab work, making robots and mobile applications.ロボットとモバイルアプリケー
ションを作成する extensive な lab work があります。

It just so happens that the robotics substrate software that comes with the system 
they're using is programmed in Python. Similarly, the mobile software environment is 
based on Python.  (Or, at least, the original plan was to use such a substrate, 
although it may have changed for various business reasons.)

なぜ Pythonなのかといえば、それは単にロボティクスを substrate するソフトウェアが 
Python でプログラムされたシステムを使っているからです。同様に、モバイルソフトウェア環
境も Python をベースにしたものです。(あるいは、少なくとも、元々のプランではそういった 
substrate を使うようになってたのに、さまざまなビジネス上の理由によって変更されたかもし
れません)

Changing programming languages was absolutely not a goal of the curriculum change.  It
was merely the result of the consequences of various decisions.  We can always discuss
how it came to be that the robots and mobile devices are using Python instead of some
other language, but that's not the question being addressed here.  M.I.T. has nothing
against Scheme. (And, of course, M.I.T. does teach classic software engineering, later
in the curriculum.)

プログラミング言語を変更するということはカリキュラムを変えることの目標では決してありま
せん。それは単なる consequences of various decisions の結果にすぎません。わたしたちは、
どのようにして他のどの言語でもなくPython を使ったロボットやモバイルデバイスを扱うよう
になったのかを常に議論することが可能ですしかしそれは今ここで考えようとしている問題では
ありません。
M.I.T. has nothing against Scheme.
(そしてもちろん、M.I.T ではあとの方のカリキュラムで classic なソフトウェアエンジニアリ
ングも教えています)

This entry was posted on Sunday, May 10th, 2009 at 8:00 am and is filed under
Education, Lisp, Software Engineering. You can follow any responses to this entry
through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

■_ 本日の巡回から

■_ 予告編

あー、Lisp Machine のやつあとちょっと残ってんっだった。


Good Programmers are Not Lazy

Cort Dougan

Abstract:
In this article I provide a practical analysis of programming practices and education. 
The phrase ``Good programmers are lazy'' is very often offered to students as a guide 
to good programming. This statement is very wrong and reflects some of the problems 
with attitudes in computer science today.

この article において、わたしはプログラミングに関する practices と education の
practical analysis を行います。``Good programmers are lazy'' (優れたプログラマーは怠惰
である)というフレーズは優れたプログラミングのための指針 (guide) として学生たちに非常に
頻繁に offer されています。この statement はとんでもなく間違ったものであり今日のコンピ
ューターサイエンスにおける姿勢 (attitudes) に関する問題の一部を反映したものです。

Lazy Programmers are Bad Programmers (怠惰なプログラマーは悪いプログラマーである)

In this paper I present some basic ideas for how computer science education and 
attitudes are flawed and should be reformed. This is not an irrelevantly academic 
treatise that waxes philosophical about the art of programming. Instead, it provides 
critical analysis of trends and attitudes that must be stopped, what has likely caused 
these trends, as well as offering real-world advice on what to do to end these 
problems.

この paper では、コンピューターサイエンスの教育と attitudes (態度、姿勢)がいかに損なわ
れていて (flawed) 再構築すべきものなのかということについていくつかの基本的な考え方を示
します。これはプログラミングの技芸 (the art of programming) に関する哲学についてwaxes 
する学術的な論文 (academic treatise) ではありません。そうではなく、これらの問題を解決す
るための行動についての実世界でなされるアドバイスとして、トレンドの critical な調査と止
めるべき姿勢を示します。
# "what has likely caused these trends, " がどう収まるのかわからん

``Good programmers are lazy'' is a phrase that is repeated and adhered to as much as 
``go to use considered harmful'' is. There is rarely understanding behind either 
statement, though. Few people who quote Dijkstra's paper[#!dijkstra!#] on the use of 
goto have even read it (even worse, few actually thought about it). Instead, they've 
heard the phrase and take the literal meaning of it as a guide instead of studying the 
actual cautions presented in the paper.

「優れたプログラマーは怠惰である」というフレーズは 「go to を使うことは有害である」
(``go to use considered harmful'' )と同じくらい繰り返され、adhered されています。しか
し残念なことに、これらのいずれの statement に対してもその背後に込められたものが理解さ
れていることは滅多にありません。goto を使っている中のほんのわずかな人だけがダイクスト
ラの論文を引用していて、実際に論文を読んでいる人はさらに少ないのです(even worse, few 
actually thought about it)。大多数の人はそのフレーズを耳にしたらその字面そのものを指針
として受け取ってしまいます。その論文に書かれている本当の警告 (actual cautions) につい
て学ぶことをしないのです。

I've met and worked with lazy programmers and every one of them have been very bad 
programmers. A better statement would be ``Good programmers find efficient, 
maintainable and throughly thought out solutions to problems''. This admonishment to 
be lazy is usually made by some well meaning and ignorant instructors while students 
are studying in college. I was given the same advice when I was a student but I have 
learned better since then. Good programmers are hard working, methodical, determined 
and driven - not lazy. The path of least resistance is for dairy cows, not for 
intelligent engineers and programmers.

わたしは怠惰なプログラマーたちと会ったことがあり、一緒に働いたこともありますが、そうい
った人たちは皆、非常に劣ったプログラマー (very bad programmers) でした。より良い 
statement は``Good programmers find efficient, maintainable and throughly thought out 
solutions to problems'' (優れたプログラマーは問題に対する、効率的(efficient)で、保守が
容易な(maintanable)、throughly な解決策を考え出す)のようなものになるでしょう。この怠惰
になれという admonishment (警告、忠告、叱る) は通常学生が大学で学んでいるときに一部の 
well meaning かつ ignorant (無知、無学) な教官 (instructor) たちによってつくられます。
わたしは同じアドバイスを自分が学生のときに受けました。しかしわたしはそのあとより良いこ
とを学んだのです。優れたプログラマーは熱心に働き、几帳面で (methodical)、 決然としてい
て(determined) driven です。怠惰ではありません。
path of least resistance は dairy cows のためのものであって、
知恵のあるエンジニアやプログラマー (intelligent engineers and programmers)
のためのものではありません。

Programming as Engineering (エンジニアリングとしてのプログラミング)

2009年09月25日

■_

・土曜出勤
土曜日に出なきゃらならないとなると、連休も良し悪しだなあ。

■_ VCもあまり変わらなかったでござるの巻

Open Watocm C のライブラリのソースを見てがっくしきてましたが VCもあまり変わりませんでしたw たとえば mbclen。

/***
*mbclen.c - Find length of MBCS character
*
*       Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
*       Find length of MBCS character
*
*******************************************************************************/

#include <mtdll.h>
#include <cruntime.h>
#include <mbdata.h>
#include <mbctype.h>
#include <mbstring.h>
#include <stddef.h>


/***
* _mbclen - Find length of MBCS character
*
*Purpose:
*       Find the length of the MBCS character (in bytes).
*
*Entry:
*       unsigned char *c = MBCS character
*
*Exit:
*       Returns the number of bytes in the MBCS character
*
*Exceptions:
*
*******************************************************************************/

size_t __cdecl _mbclen_l(
        const unsigned char *c,
        _locale_t plocinfo
        )

{
        /*  Don't return two if we have leadbyte, EOS.
            Don't assert here; too low level
        */
        return ((_ismbblead_l)(*c, plocinfo) && c[1]!='\0')  ? 2 : 1;
}

(略)

/***
*mbrtowc.c - Convert multibyte char to wide char.
*
*       Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
*       Convert a multibyte character into the equivalent wide character.
*
*******************************************************************************/
(略)
     /* complete two-byte multibyte character */
        ((char *)pmbst)[1] = *s;
        if (_loc_update.GetLocaleT()->locinfo->mb_cur_max <= 1 ||
            (MultiByteToWideChar(
                _loc_update.GetLocaleT()->locinfo->lc_codepage,
                MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,
                (char *)pmbst,
                2,
                dst,
                (dst != NULL ? 1 : 0)) == 0))
        {
            /* translation failed */
            *pmbst = 0;
            errno = EILSEQ;
            _ASSIGN_IF_NOT_NULL(dst, 0);
            _ASSIGN_IF_NOT_NULL(pRetValue, -1);
            return errno;
        }
        *pmbst = 0;
        _ASSIGN_IF_NOT_NULL(pRetValue, _loc_update.GetLocaleT()->locinfo->mb_cur_max);
        return 0;
    }
    else if ( _isleadbyte_l((unsigned char)*s, _loc_update.GetLocaleT()) )
    {
        /* multi-byte char */
        if (n < (size_t)_loc_update.GetLocaleT()->locinfo->mb_cur_max)
        {   /* save partial multibyte character */
            ((char *)pmbst)[0] = *s;
            _ASSIGN_IF_NOT_NULL(pRetValue, -2);
            return 0;
        }
        else if ( _loc_update.GetLocaleT()->locinfo->mb_cur_max <= 1 ||
                  (MultiByteToWideChar( _loc_update.GetLocaleT()->locinfo->lc_codepage,
                                        MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,
                                        s,
                                        _loc_update.GetLocaleT()->locinfo->mb_cur_max,
                                        dst,
                                        (dst != NULL ? 1 : 0)) == 0) )
        {
            /* validate high byte of mbcs char */
            if (!*(s+1))
            {
                *pmbst = 0;
                errno = EILSEQ;
                _ASSIGN_IF_NOT_NULL(dst, 0);
                _ASSIGN_IF_NOT_NULL(pRetValue, -1);
                return errno;
            }
        }
        _ASSIGN_IF_NOT_NULL(pRetValue, _loc_update.GetLocaleT()->locinfo->mb_cur_max);
        return 0;
    }
    else {
        /* single byte char */
(略)

■_ 本日の巡回から

■_ Perl 6

ちょっと前のが元なので、最新版では変更されている部分がある鴨。


blog | Perlgeek.de Blog :: Custom Operators

Custom Operators (カスタム演算子)

NAME

"Perl 5 to 6" Lesson 13 - Custom Operators

SYNOPSIS

    multi sub postfix:<!>(Int $x) {
        my $factorial = 1;
        $factorial *= $_ for 2..$x;
        return $factorial;
    }
    
    say 5!;                     # 120

DESCRIPTION

Operators are functions with unusual names, and a few addtional properties like 
precedence and associativity. Perl 6 usually follows the pattern term infix term, 
where term can be optionally preceeded by prefix operators and followed by postfix or 
postcircumfix operators.

演算子とは、普通ではない名前を持った関数で、それに加えて優先順位とか結合規則のような幾
つかの属性がついています。通常Perl 6は pettern term として infix term を採用しますが
term はその前に前置演算子 (prefix operators)をつけることや後ろに後置演算子もしくは後置
サーカムフィクス演算子 (pstcircumfix operators)をつけることができます。


    1 + 1               infix (中置)
    +1                  prefix (前置)
    $x++                postfix (後置)
    <a b c>             circumfix
    @a[1]               postcircumfix

Operator names are not limited to "special" characters, they can contain 
anything except whitespaces.

演算子の名前は“特殊なキャラクタ”に限定されることはなく、空白以外の好きなキャラクタ
をその名前を構成するものとして使うことが許されます。

The long name of an operator is its type, followed by a colon and a string literal or 
list of the symbol or symbols, for example infix:<+> is the same as infix:'+', 
and it's the operator in 1+2. Another example is postcircumfix:<[ ]>, which is 
the same as postcircumfix:('[', ']').

演算子の長い名前は、その型に続けてコロン、文字列リテラルもしくはシンボル(かsymbols?)の
リストがあるものです。たとえば infix:<+> と infix:'+' は同じ意味であり、1+2 のよ
うな式に使われる演算子です。別の例を挙げると、postcircumfix:<[ ]> は 
postcircumfix:('[', ']') と同じ意味です。

With this knowledge you can already define new operators:

この知識があれば、新たに演算子を定義することがもう可能になっています。

    multi sub prefix:<?> (Str $x) {
        2 *  $x;
    }
    say ?4;                         # 8

Precedence 優先順位

In an expression like $a + $b * $c the infix:<*> operator has tighter precedence 
than infix:<+>, which is why the expression is evaluated as $a + ($b * $c).

$a + $b * $c のような式において infix:<*> 演算子は
infix:<+> 演算子よりも強力な優先順位を持っていますので、
この式は$a + ($b * $c) と解釈されることになります。

The precedence of a new operator can be specified in comparison to to existing 
operators:

新しい演算子の優先順位は既に定義済みの演算子との比較によって特定することができます:

    multi sub infix:<foo> is equiv(&infix:<+>) { ...  }
    mutli sub infix:<bar> is tighter(&infix:<+>) { ... }
    mutli sub infix:<baz> is looser(&infix:<+>) { ... }

Associativity 結合規則

Most infix operators take only two arguments. In an expression like 1 / 2 / 4 the 
associativity of the operator decides the order of evaluation. The infix:</> 
operator is left associative, so this expression is parsed as (1 / 2) / 4. for a right 
associative operator like infix:<**> (exponentation) 2 ** 2 ** 4 is parsed as 2 ** 
(2 ** 4).

ほとんどの中置演算子は引数を二つだけ取ります。1 / 2 / 4 のような式があったとき、演算子
の結合規則がその式の評価をどのように行うかを決定します。infix:</> 演算子は左結合
なので、先の式は (1 / 2) / 4 のように解釈されます。infix:<**> のような右結合の演
算子(べき乗)であれば2 ** 2 ** 4 は 2 ** (2 ** 4) のように解釈されます。

Perl 6 has more associativities: non forbids chaining of operators of the same 
precedence (for example 2 <=> 3 <=> 4 is forbidden), and infix:<,> has list 
associativity. 1, 2, 3 is translated to infix:<,>(1; 2; 3). Finally there's the 
chain associativity: $a < $b < $c translates to ($a < $b) && ($b 
< $c).

Perl 6ではこの他にも結合規則があります: 同じ優先順位を持つ演算子の chaining を禁止しません
(2 <=> 3 <=> 4 は許されません)し、infix:<,> は list associativity を持
っています。1, 2, 3 は infix:<,>(1; 2; 3) に変換されます。最後の結合規則は chain 
associativity で、$a < $b < $c が ($a < $b) && ($b < $c) に変換さ
れます。

    multi sub infix:<foo> is tighter(&infix:<+>)
                          is assoc('left')
                          ($a, $b) {
        ...
    }

Postfcircumfix and Circumfix

Postfcircumfix operators are method calls:
Postfcircumfix 演算子はメソッドコールです:

    class OrderedHash is Hash {
        method postcircumfix:<{ }>(Str $key) {
            ...
        }
    }

If you call that as $object[$stuff], $stuff will be passed as an argument to the 
method, and $object is available as self.

$object[$stuff] として呼び出しを行ったとき、$stuffは引数として method に渡されます。
このとき $object は selfとなります。

Circumfix operators usually imply a different syntax (like in my @list = <a b 
c>;), and are thus implemented as macros:

Circumfix 演算子はたいていの場合は(my @list = <a b c>;のような)
異なる構文を含んでいて、そのためマクロとして実装されます。

    macro circumfix:≪< >≫($text) is parsed / <-[>]>+ / {
        return $text.comb(rx/\S+/);
    }

The is parsed trait is followed by a regex that parses everything between the 
delimiters. If no such rule is given, it is parsed as normal Perl 6 code (which is 
usually not what you want if you introduce a new syntax). Str.comb searches for 
occurences of a regex and returns a list of the text of all matches.

これは デリミタに囲まれたすべてを解析する正規表現が後続する parsed trait です。もしそ
のようなルールが与えられていなければ、通常の Perl 6のコードとして扱われます(新しい構文
を使ったのであれば、大抵それはあなたが望んだことではないでしょう)。Str.comb は 
occurences of a regex を探し、マッチしたすべてのテキストのリストを返します。

"Overload" existing operators
(既存の演算子の「オーバーロード」)

Most (if not all) existing operators are multi subs or methods, and can therefore be 
customized for new types. Adding a multi sub is the way of "overloading" 
operators.

既存のほとんどの演算子は multi subs もしくは multi methods なので、新しい型のためにカ
スタマイズすることが可能です。multi sub の追加は演算子のオーバーロード方式を使います。

    class MyStr { ... }
    multi sub infix:<~>(MyStr $this, Str $other) { ... }

This means that you can write objects that behave just like the built in 
"special" objects like Str, Int etc.

これはつまり、StrだとかIntなどのような組み込みの“特殊な”オブジェクト
のように振舞うオブジェクトを記述することができるということです。

MOTIVATION (動機)

Allowing the user to declare new operators and "overload" existing ones 
makes user defined types just as powerful and useful as built in types. If the built 
in ones turn out to be insufficient, you can replace them with new ones that better 
fit your situation, without changing anything in the compiler.

ユーザーが新しい演算子を宣言することとオーバーロードをすることを許すことによって既存の
演算子がユーザー定義型をあたかも組み込みの型のように強力かつ便利なものにします。仮に組
み込みの演算子の効率が良くないのであれば、コンパイラには一切変更加えることなしに、あな
たの状況によりフィットした新しい演算子でもって置き換えることが可能です。

It also removes the gap between using a language and modifying the language.

これはまた、言語を使うことと言語を修正することとの間のギャップを取り除きます。

SEE ALSO

http://perlcabal.org/syn/S06.html#Operator_overloading

If you are interested in the technical background, ie how Perl 6 can implement such 
operator changes and other grammar changes, read 
http://perlgeek.de/en/article/mutable-grammar-for-perl-6.


Copyright 2008: Moritz Lenz
This page my be used under the terms of a Creative Commons license.
Layout based on YAML, powered by mowyw and blosxom

2009年09月24日

■_

・権藤権藤雨権藤
鈴木敏夫のジブリ汗まみれ - TOKYO FM 80.0 - 鈴木敏夫 に、ベイスターズで監督をされた権藤さんがゲストの回があるというので聴いてみました。 いや面白かった。 今現役の監督の中で評価しているのはドラゴンズの落合(とおまけでライオンズのナベQ?)だけとか。 もし自分がいま監督としてチームを指揮したとしても、落合のチームとはやりたくないとかw あとは、二軍のコーチ時代に、それまでは「鬼軍曹」として 「こんなこともできないのか」と叱り飛ばしてばかりだったのが、 アメリカのルーキーリーグでのとある出来事以来がらっと変わったとか (どんなことがあったのかは聴いてのお楽しみ)。 あとは 1998年の日本シリーズ、第六戦で先発に川村を選んだ理由とか(これは以前にもどこかで 聞いたことがあったかも)。

■_ ヲチ

Agda の名前が /.J にでたりしましたね。

関数型プログラミング言語Haskell Part11 
46 デフォルトの名無しさん [sage] 2009/09/24(木) 10:00:51 ID: Be:
    10年前にmonadと出会って以来、何千回と挫折してきた俺がついに悟った!

    これは

    単なる

    イディオムだ

48 デフォルトの名無しさん [sage] 2009/09/24(木) 14:13:51 ID: Be:
    WINDOWS VISTA 環境に以下を参考にghcを導入した。

    http://d.hatena.ne.jp/coppieee/20090416/1239903149
    導入したEclipse SDKはVersion: 3.3.2
    Eclips用のHaskell モジュールが最新のEclips 3.5に未対応な為
    リンク先の
    >> 5. Windw -> Preferences -> Functional Programming -> Haskell -> Compiler -> GHC compiler -> Browseボタンでインストールしたghcのコンパイラ選択。
    に有るように、正確にGHCの場所を指定しなくても動作する
    ただし、インタープリタGHCiの場所を認識しないので、ghcの場所は正確に指定し
    インタープリタghciの接待タブでghcの場所設定を利用するにチェックを入れる。

    Eclipsの日本語化はhttp://mergedoc.sourceforge.jp/ を参考にどうぞ

    少し疲れたw 

49 デフォルトの名無しさん [sage] 2009/09/24(木) 16:19:33 ID: Be:
    >>32
    元の構造は保たないと。
    ファンクタなんで。 

50 デフォルトの名無しさん [sage] 2009/09/24(木) 18:50:01 ID: Be:
    函手じゃなくて自然変換じゃないか。
    一意に決定しないと使い物にならない。 

51 デフォルトの名無しさん [sage] 2009/09/24(木) 19:34:22 ID: Be:
    函手って見ると
    ハルヒの射手座の日を思いだす

    理由はよくわからない 

52 デフォルトの名無しさん [sage] 2009/09/24(木) 23:04:26 ID: Be:
    slashdotのコメント欄はわかってないヤツが多いな。
    http://slashdot.jp/developers/09/09/24/039226.shtml

    こういう連中がいる会社は最悪だろうな。まさに老害。 

53 デフォルトの名無しさん [sage] 2009/09/24(木) 23:21:28 ID: Be:
    どういう連中か目に浮かぶようだ 

54 デフォルトの名無しさん [sage] 2009/09/24(木) 23:30:38 ID: Be:
    Agdaって今世界でもっとも難しい言語の1つだよね?
    極めれば即仙人になれる難しさだよね?

    俺写像定義するだけで投げたレベルだからあれだけど 

55 デフォルトの名無しさん [sage] 2009/09/24(木) 23:33:40 ID: Be:
    ほんとか!ちょっとAgda勉強しにいってくる。 

56 デフォルトの名無しさん [sage] 2009/09/24(木) 23:48:37 ID: Be:
    魔法使い卒業検定には使えますか? 

57 デフォルトの名無しさん [sage] 2009/09/24(木) 23:49:59 ID: Be:
    卒業なんてない。
    死ぬまで学徒。 

仙人養成言語…

■_ わとこむ

gawkやらをビルドするのに使うコンパイラーをVCからOepn Watcom Cに乗り換えようかと いろいろ調べてたりするんですが

OW18src/bld/clib/streamio/c
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  Implementation of printf() - formatted output.
*
****************************************************************************/
  

という具合に、ファイルの先頭がライセンスに関する記述、それに続いて そのファイルで記述されている関数の簡単な説明となっているんですが、 マルチバイト文字やらワイド文字関連のライブラリ関数のファイルを見ると

*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


#include "variety.h"
#include <bstring.h>
#include "farfunc.h"


_WCRTLINK int _NEARFAR(mblen,_fmblen)( const unsigned char _FFAR *s, size_t n )
{
    return( _NEARFAR(mbtowc,_fmbtowc)( NULL, s, n ) );
}

  

何やってるか把握できたらその説明を書いてくれ?

*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


#include "variety.h"
#include <errno.h>
#include <mbstring.h>
#include <wchar.h>
#include "farfunc.h"
#include "seterrno.h"


_WCRTLINK int _NEARFAR(mbrtowc,_fmbrtowc)( wchar_t _FFAR *pwc, const char _FFAR *s, size_t n, mbstate_t _FFAR *ps )
{
    int                 rc;

    /*** Check the simple cases ***/
    if( s == NULL )  return( 0 );           /* always in initial state */
    if( n == 0 )  return( -2 );             /* can't process nothing */

    /*** Check for a valid multibyte character ***/
    rc = _NEARFAR(mbtowc,_fmbtowc)( pwc, s, n );
    if( rc != -1 ) {
        return( rc );
    } else if( n < MB_LEN_MAX  &&  _ismbblead( *s ) ) {
        return( -2 );                       /* incomplete, possibly valid */
    } else {
        __set_errno( EILSEQ );              /* encoding error */
        return( -1 );
    }
}
  

これも。

*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


#include "variety.h"
#include <mbstring.h>
#include "farfunc.h"



/****
***** Convert a multibyte character string to a wide character string.
***** Returns the number of wide characters written (excluding NULL if
***** one was encountered) on success, or -1 on error.
****/

_WCRTLINK size_t _NEARFAR(mbstowcs,_fmbstowcs)( wchar_t _FFAR *pwcs, const char _FFAR *s, size_t n )
{
    int                 numChars = 0;
    int                 rc;

    if( pwcs != NULL ) {                /* convert the string */
        while( n > 0 ) {
            if( *s != '\0' ) {
                rc = _NEARFAR(mbtowc,_fmbtowc)( pwcs, s, MB_LEN_MAX );
                if( rc == -1 )  return( -1 );
                n--;
                s = _NEARFAR(_mbsinc,_fmbsinc)( s );
                pwcs++;
                numChars++;
            } else {
                *pwcs = L'\0';
                break;
            }
        }
    } else {                            /* get required size */
        for( ;; ) {
            if( *s != '\0' ) {
                rc = _NEARFAR(mbtowc,_fmbtowc)( NULL, s, MB_LEN_MAX );
                if( rc == -1 )  return( -1 );
                s = _NEARFAR(_mbsinc,_fmbsinc)( s );
                numChars++;
            } else {
                break;
            }
        }
    }
    return( numChars );
}

  

えーとひょっとして UTF-16 は対応してないよね? ○| ̄|_

そして止め。

/****
***** Convert a multibyte character to a wide character.
****/

_WCRTLINK int _NEARFAR(mbtowc,_fmbtowc)( wchar_t _FFAR *pwc, const char _FFAR *ch, size_t n )
{
#ifdef __NT__
    int                 rc;
    int                 len;
    wchar_t             wch;
#endif

    /*** Catch special cases ***/
    if( ch == NULL )  return( 0 );
    if( n == 0 )  return( -1 );
    if( *ch == '\0' ) {
        if( pwc != NULL )  *pwc = L'\0';
        return( 0 );
    }
    if( _ismbblead( ch[0] )  &&  ch[1] == '\0' )  return( -1 ); /* invalid */

    /*** Convert the character ***/
    #ifdef __NT__
        len = _NEARFAR(_mbclen,_fmbclen)( ch );
        rc = MultiByteToWideChar( __MBCodePage, MB_ERR_INVALID_CHARS,
                                  (LPCSTR)ch, min(n,len), (LPWSTR)&wch, 1 );
        if( rc != 0 ) {
            if( pwc != NULL )  *pwc = wch;
            return( len );                      /* return mbchar size */
        } else {
            return( -1 );                       /* cannot convert */
        }
    #else
        if( _ismbblead(*ch) && n>=2 ) {         /* lead byte present? */
            if( pwc != NULL ) {
                *pwc = (((wchar_t)ch[0])<<8) |  /* convert to lead:trail */
                        (wchar_t)ch[1];
            }
            return( 2 );                        /* return char size */
        } else if( !_ismbblead(*ch) ) {
            if( pwc != NULL ) {
                *pwc = (wchar_t)ch[0];          /* convert to 00:byte */
            }
            return( 1 );                        /* return char size */
        } else {
            return( -1 );                       /* n==1, but char 2 bytes */
        }
    #endif
}

  
/**
 * Return the number of bytes in a given multi-byte character.
 */

_WCRTLINK size_t _NEARFAR(_mbclen,_fmbclen)( const unsigned char _FFAR *ch )
{
    return( _ismbblead( *ch ) ? 2 : 1 );
}

  

その実装はないわ~ ○| ̄|_

■_

2009年09月23日

■_

・Poken新型欲しいな
今までもぜんぜん使ってないけどね。

・バルト9
新宿南口から建物見えるのね。

・ついった経由で知った人と飲んだ。

・はっしゅ
おくじさんさんのところの最新エントリ を見てふと思い出したのですが、 本当はむずかしいハッシュテーブル - sumiiの日記 の解説は一体いつ…と思って見返してみたら これは解説する予定はありませんが、他の方の解答・コメントは歓迎します。 とか。最初からこれ書かれてましたっけ?

・してやられたはなし
昨日「文○堂にしてやられた」とだけ書きましたがもうちょっとだけ説明を。 ちくま学芸文庫のとある本を探していたわけなんですが、 書籍データベースで検索→在庫ありと出た→ここにおかれているという案内に従ってその場所に行く →ない。 でまあ、時間差があったりするので(リアルタイム、は厳しいとしても数十分単位くらいで 反映できないものなんだろうか)売れたのかなあと諦めたのですが、 全然別の本を探しているときに先ほど探していた本が平積みにされているのを発見。 しかしですね、 探していた本というのは 通信の数学的理論 (ちくま学芸文庫) だったのですが、 見つけた場所というのが戦史や戦記などの歴史物が置かれているところだったのです。 …なぜ? で、その場所はレジの真正面だったりしたので、本を買うときに検索結果を印刷した紙を見せて 「あのー、この本なんですが検索すると××にあると出てるんですけど、そこにはなくて ここに積まれてるんですけど…」とか話をしたら、(レジ番の店員さんではなく) 脇から女性の店員さんが手を伸してその紙片を取り 「あ、すみません。入力を直します」とかいいながら端末に向かってぽちぽちと。 別にぺこぺこ頭下げて謝れとはいわんのですがもうちょっと申し訳なさそうにして欲しかったなあ。 げしょ。

■_

ちと昔のを仕上げて。 Perlでサブルーチンの引数をハッシュ経由で名前つき引数のようにして呼び出すことに絡めていろいろ。

The value of declarations
We are all familiar with the standard advice. Use strict.pm. It catches typos.

strict.pm を使え。そうすれば typo を捕捉できる。
こんな standard advice にわたしたちは慣れ親しんでいます。

But have you noticed that most other scripting languages don't agree with us? If you
look at JavaScript, PHP, Ruby and Python you will look in vain for any corresponding
piece of standard advice that makes variable declarations required. Why is this?

しかし Perl 以外のほとんどのスクリプティング言語がこれに従っていないということに気がつ
いていましたか? JavaScript や PHP、Ruby、Python をみても、Perl のそれに対応するような 
変数宣言を必須とする piece of standard advice は見当たりません。これはなぜなのでしょう
か?

My theory is that it is an over-reaction to statically typed languages. When you come
from a world where you are used to typing:

わたしの理論では変数宣言とは静的に型付けする言語に対する over-reaction です。あなたが 型
付け (typing) を使っている世界から来たとすると:

FooBar fooBar = new FooBar();

over and over again it is easy to overreact to the realization that constantly
declaring types gave you no real benefit. It is more convenient to not declare the
types at all, so why not go all of the way and remove the declaration entirely?

constantly に型の宣言をすることは本当の利益をあなたにもたらしてはくれない
realization のための overreact を何度も何度も繰り返すことに陥りがちです。
型を宣言することなんてしないほうがずっと使いやすいのです。
なのになぜ go all of the way して宣言を完全に取り除かないのでしょうか?

As we all know, the answer is that the answer is that the apparent convenience is
misleading. Required declarations automatically catch a class of real bugs for you.
Not requiring declarations forces eternal vigilance. As I noted in Re: Avoiding silly
programming mistakes, eternal vigilance is a bad thing.

わたしたち全員が知っているように、一見便利なように見えている答えは実は misleading なの
です。要求された宣言は自動的にreal bugs のクラスとして捕獲されあなたに通知されます。宣
言の要求は  eternal vigilance を強制することはありません。わたしが Re: Avoiding silly 
programming mistakes で注記したように eternal vigilance は悪いことなのです。

#eternal 永遠の、絶え間のない、不変の
#vigilance 警戒

However it seems to me that Perl programmers have less cause to be smug than might
appear. It seems to me that as a culture we have internalized the practice, but not
the principle.

しかし、Perlプログラマーは見た目よりも smug になることは少ないように思われます。
わたしたちが internalized したのは principle (原則)ではなくpractice (実践)という文化を
持っているからのようにわたしには思えるのです。

#smug ひとりよがり

Let me give a simple example that many of us have experienced. Have you ever written
any logfile processing? It is pretty straightforward. You parse lines into hash refs,
then work with the hash refs. Not exactly hard, and you've likely done it.

あなたはこれまでなんらかのログファイルの処理を書いたことがありますか?それはとてもわか
りやすい (straightforward) ものです。行を解析してハッシュリファレンスへ変換し、それか
らそのハッシュリファレンスに対して作業を行います。難しいことはありませんから、あなたも
そういったことをした経験があるでしょう。

Did you think of using Hash::Util's lock_keys function to catch typos in your hash
access? I will confess that for years I did not. For me the moment of revelation was
when I read Damian Conways PBP and he argued against using Hash::Util because it
wasn't secure. And I argued back at the page, "Of course it isn't secure! It
isn't supposed to be! It is a strict declaration for hashes!" Then I decided to
use it the next time the opportunity came up to see if it was helpful.

Hash::Util の lock_keys 関数をハッシュアクセス時の typo を捕捉するのに使うことを考えた
ことがありますか? I will confess that for years I did not.わたしにとっての moment of 
revelation は Damian Conway の PBP (Perl Best Practices) を読んだときのことで、彼はそ
れが安全ではないという理由で Hash::Util を使うことに反対していました。そしてそのページ
に戻ってわたしは主張しました。
"Of course it isn't secure! It isn't supposed to be! It is a strict declaration for hashes!"
(もちろんそれは安全 (secure) ではない! (Hash::Utilが)あることを前提にしてはいけない!
ハッシュに対する strict な宣言だ!)それからわたしは次の機会にもしそれが便利なものであれ
ば使うことにしようと決めたのです。

When that opportunity arose I found that there is a serious performance penalty, but 
while developing the log processing I caught 2 bugs that would have otherwise taken me 
much longer to catch. And found that once developed I could avoid the speed penalty by 
commenting out one line. I've been using the technique ever since.

その機会が訪れたとき、わたしはパフォーマンス面で深刻なペナルティがあることに気がつきま
したしかし開発している間に、他のやり方では解決するのにもっともっと時間がかかったであろ
う二つのバグをログ処理によって捕捉しました。バグを見つけたあとは一行コメントアウトする
だけでスピード面のペナルティはなくすことが可能です。それ以来わたしはこの手段を使いつづ
けています。

Let's move on to argument processing. Most of us know that using named arguments to 
functions is a good thing. It is common to see people pass hashes into functions, and 
then process them for exactly that reason. You've probably done it. (If not, then 
consider it.) But how many of you have a check to find when named arguments are passed 
in that are not on the list of allowed arguments? I do that, and frequently catch 
errors where I pass in baz and should have passed in bar. Those errors would otherwise 
be much harder to catch because to see it you have to carefully compare the function 
call and definition which are in different pieces of code.

引数の処理についてのことに話題を変えましょう。わたしたちのほとんどは関数に対して名前付
き引数を使うことが良いことであると知っています。ユーザーが関数にハッシュを渡すコードを
書いているのを見るのはよくあることで、確たる理由があるのでそれを処理しているのです。あ
なたもおそらくそうしたことがあるでしょう(もしないのなら、それについて考えてみてくださ
い)。ところで受け付ける引数のリストの中にない名前つき引数が渡されたときそれを検出する
ための検査をあなたはどのくらい行っていますか?わたしはそういった検査をしていますし、bar 
を渡すべきところで baz を渡してしまっているようなエラーの場所をしばしば捕捉しています。
この種のエラーは他の手段では非常に見つけるのが困難なものです。それは、この間違いを見つ
けるにはコードの別々の場所に置かれている関数の呼び出し部分と定義の部分とを注意深く比較
しなければならないからです。

Now let me give a somewhat more bothersome example, which is what prompted this
meditation.

さて今度はもっとこの mediation を prompted している bothersome な例を出してみましょう。

Not long ago I had to prepare a small Catalyst site as a code sample. In the process
of doing that I was quite surprised to find that if a template variable called a
method that wasn't there, you had missing data but no error message to help you track
it down. Luckily Template::Stash::Context doesn't suffer from that bug.

それほど昔ではないのですが、わたしはコードのサンプルとして小規模な Catalyst のサイトを
立ち上げた (prepare) ことがあります。テンプレート変数が存在しないメソッドをう呼び出し
たことを見つけたときにとても驚いたプロセスの実行時にあなたはデータを失ってしまったので
すがあなたがそれを追跡することの助けになるようなエラーメッセージはありませんでした。好
都合なことに Template::Stash::Context はこの種のバグを経験していなかったのです。

But that stash does not catch the use of template variables that were not passed in.
But I already had a piece of code for that. Which took more work to produce when I
needed it than it really should have. (Sorry, highly non-reusable code for reasons
that are mostly out of my control. For Catalyst I also added a few variables that were
OK to not pass in.)

しかしその stash は、渡されていないテンプレート変数の使用を捕捉しませんでした。それで
もわたしはすでに piece of code for that を持っていました。わたしがそれを必要としたとき
に生成するために、本当にすべきものよりも多くの作業を必要としました(申し訳ない。highly 
non-reusable code となることの理由はわたしの制御のほとんど及ぶところではありません。
Catalyst ではわたしは OK to not pass in であった幾つかの変数を追加しました)

And there we have it. The most popular web framework in Perl, using the most popular
templating solution, defaults to silently swallowing the most egregious possible signs
of error. And unless you really know what you're doing you're not going to find the
option of making it helpfully give you a hint of what you did wrong.

And there we have it.
Perl によるweb フレームワークのほとんどは最もポピュラーなテンプレート方式を使っていて
デフォルトでは大部分のエラーの可能性の徴候をだまって飲み込んでしまっていました。
実際にそのようなオプションが存在することを知らない限り
あなたが間違ったことをしたことのヒントをあなたに与えてくれるのを
助けるようにしてくれるオプションを探そうとしていない

So the next time you sit down to write some Perl, pause and give thought to this issue.
Think through in different contexts what a "declaration" looks like, and how
you might automatically catch things that were not properly declared. The first bug
that you automatically catch will likely be your own.

ですからあなたが次になにかを Perl で書こうと席についたときにはちょっと手を休めてこのこ
とについて考えてみてください。異なる文脈で“宣言”とはどういったものかということや、適
切な宣言をしなかったときにどうやれば自動的にそれを捕捉できるのかについて考えてみましょ
う。自動的に捕捉した最初のバグはあなた自身のバグになることでしょう

■_

いや、それは…w

【入門】Common lisp その6【質問よろず】
586 デフォルトの名無しさん [sage] 2009/09/23(水) 05:16:22 ID: Be:
    なぜかやたらSDLにご執心のようだからおおかたHSP畑の人なんじゃね・・と書こうとしたら

        |
      \ _ /
     _ (m) _
        目   ピコーン
      / `′ \
       ∧∧
       (・∀・)
      ノ( )ヽ
       < >

    HSP <-> I_ISP <-> liSP 俺って天才? 

587 デフォルトの名無しさん [sage] 2009/09/23(水) 10:58:03 ID: Be:
    >>586
    天才。 

588 デフォルトの名無しさん [sage] 2009/09/23(水) 13:08:59 ID: Be:
    >>586
          _人人人人人人人人人人人人人人人_
            >      な、なんだってー!!    <
            ̄^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ ̄
       ∩___∩              ∩____∩
       | ノ     u ヽ            / u     u └|  ∩____∩
      / # ●   ● |           | ●   ● # .ヽ/  u    └|
      | u   ( _●_)  ミ          彡   (_●_ ) u  |●   ● # ヽ
     彡、   |∪|  、`\        /     |∪|    彡  (_●_) u   |
    / __  ヽノ /´>  )       (  く   ヽ ノ   / u   |∪|    ミ
    (___)   / (_/        \_ )      (  く   ヽ ノ     ヽ

589 デフォルトの名無しさん [sage] 2009/09/23(水) 13:14:10 ID: Be:
    >>586
    お前天才だな 


■_ 結構変わってるな(Perl 5.10.0 → 5.10.1)

時間が開いただけのことはあるのか。


Perl Training Australia - What's new in Perl 5.10.1
What's new in Perl 5.10.1

In late August, Perl 5.10.1 was officially released. In this tip, we'll examine what's 
changed between Perl 5.10.0 and 5.10.1.

In addition to this Perl tip, you can read the Perl 5.10.1 delta document that 
describes the changes in more detail.

Bug-fixes and optimisations

Perl 5.10.1 is primarily a maintenance release, which means a large collection of 
bug-fixes, optimisations, additional tests and tuning. In particular, 5.10.1 runs 
significantly faster than 5.10.0 with many common subroutine calls.

If you're already using 5.10.0, you may find that upgrading to 5.10.1 will give your 
code a significant speed boost.

Range operators

Perl's .. operator is now always interpreted as being in boolean context when used 
inside a when statement. In practical terms, this now means that structures like the 
following now work:

Perl の .. 演算子は、when 文の中で使われたときには常に boolean コンテキストで
評価されるようになりました。practical terms では、次のような記述がうまく動作する
ようになったということです。


    while (<>) {
        given ($_) {
            when ( /START_HEADER/ .. /END_HEADER/ ) { next; }   # Skip header
            when ( /^\s*#/ )                        { next; }   # Skip comments
            default { process_line($_); }
        }
    }

Under Perl 5.10.0, the header skipping code above would never trigger, however under 
5.10.1 it now works as intended. To use given/when to match a range, an array 
reference should be used (in both 5.10.0 and 5.10.1):

5.10.0 では、上記のヘッダーをスキップするコードはけっして条件が成立することが
ありませんが、5.10.1 では期待通りに動作します。given/when をレンジに対するマッチに
使用するには配列リファレンスを使用すべきです (5.10.0と5.10.1の両方で)。

    given ($number) {
        when ( [1..10] ) { say "In range"     }
        default          { say "Out of range" }
    }

Smart-match

Perl 5.10.1 introduces significant changes to the ~~, the smart-match operator. The 
most important changes are detailed below:

Perl 5.10.1 では スマートマッチ演算子 ~~ に対して大きな変更が行われました。
最も重要な変更は以下で詳しく説明します:

Better encapsulation

Smart-match no longer works on objects unless they have overloaded the smart-match 
operator. This prevents smart-match for breaking encapsulation and poking around in 
the internals of your objects when you don't want it to. Objects that don't overload 
smart-match, but do overload stringification or numerification, will be treated as 
strings or numbers, respectively.

スマートマッチは、スマートマッチ演算子をオーバーロードして持っていない限り、
オブジェクトに対しては働かないようになりました。
これは encapsuslation を壊したり、ユーザーのオブジェクトの内部に対して
望まないときに poking してしまうことを防ぐためです。
オーバーロードされたスマートマッチを持たないが、
stringification もしくは numerification をオーバーロードしている
オブジェクトは文字列か数値として扱われます。


No longer commutative

In Perl 5.10.0, the ordering of the operands to smart-match did not matter. In 5.10.1, 
they do matter, with the rightmost argument primarily determining behaviour.

Perl 5.10.0 では、スマートマッチのオペランドの順番は重要ではありませんでした。
Perl 5.10.1 では順番が重要であり、最も右にある引数が primarily に動作を
決定します。

The following common idioms work in both 5.10.0 and 5.10.1:

次の一般的なイディオムは 5.10.0 でも 5.10.1 でも動作します:

    $key ~~ %hash       # Does $key exist in %hash ?
    $value ~~ @array    # Does $value exist in @array?

But be careful! The following are now always false in 5.10.1:

しかし注意してください!
以下の記述は 5.10.1 では偽になるようになりました。

    %hash ~~ $key
    @array ~~ $value

In a given/when construct, the given argument is always considered to be the left 
operand, and the when argument is always considered to be the right operand.

given/when 構造では、given の引数は常に左オペランドとみなされます。
そして when の引数は常に右オペランドとみなされます。

The new smart-match table can be found in perlsyn .

新しいスマートマッチテーブルは perlsyn にあります。

Distributive

Where possible, the new smart-match is distributive, and will apply itself recursively 
across large data structures. For example, the following expression is true when 
evaluated under 5.10.1, but false under 5.10.0:

可能である場合には新しいスマートマッチは distributive になります。そして
大きなデータ構造に対して再帰的に自分自身を適用します。たとえば、
次の式は 5.10.1 では評価の結果が真となりますが、5.10.0では偽となります。

    'bar' ~~ [ 'foo', [ 'bar', 'baz' ], 'qux' ]

In the same vein, given the following code:

    [ 'foo', 'bar', 'baz' ] ~~ \&subroutine

Perl 5.10.1 will call the subroutine three times (once for each element), and the 
whole expression will be considered true if all the results are true. On the other 
hand, Perl 5.10.0 would call the subroutine only once, passing in the whole data 
structure.

Perl 5.10.1 はサブルーチンを三回呼び出します(各要素につき一回ずつ)。そして
すべての結果が真であったときに式全体が真とみなされます。一方 Perl 5.10.0 では
サブルーチンはただ一度だけ呼び出され、データ構造が丸ごと渡されます。

autodie

Perl 5.10.1 includes the autodie pragma as part of the distribution, meaning it can 
now be used out-of-the-box in new code. Using autodie causes Perl's built-ins to 
succeed or die, meaning you can write code like the following:

Perl 5.10.1 では autodie プラグマを distribution の一部として取り入れました。
これにより新しいコードで out-of-the-box を使うことが可能となっています。
autodie を使うことでPerl のビルトイン関数が成功するか die するかのいずれかの
状態になるように変わります。このため、以下のような記述が可能となります:

    use autodie;

    chdir($some_dir);
    open(my $fh, '<', $some_file);

    # Process records

    close($fh);

If the chdir, open or close functions fail, they'll automatically throw an exception, 
removing the tiresome need to add or die... guards to these lines.

ここで chrdir、open、close のいずれかの関数が失敗した場合、その関数は
自動的に例外を送出します。これにより、関数を呼び出した行にガードのための
or die ... を付け加える必要がなくなります。

We've discussed autodie extensively in a previous Perl tip.

[ Perl tips index ]
[ Subscribe to Perl tips ]

■_ 本日の巡回から

A-Z 、いつの間にか Groovyを取り上げてた。
COBOL のところで a-z と小文字になっているのは何か深い意味があるのだろうか?

COBOL turns 50 - a-z of programming languages, COBOL, programming - Computerworld
http://www.computerworld.com.au/article/319269/cobol_turns_50

The A-Z of programming languages: Groovy - a-z of programming languages, groovy - Computerworld
http://www.computerworld.com.au/article/318392/-z_programming_languages_groovy?fp=39&fpid=27106


さてドンだけ伸びるか。

Flash sucks!! Memory leaks, security holes, instability, etc. How did Flash get to its point of ubiquity and how can we get rid of it? : programming
http://www.reddit.com/r/programming/comments/9n26m/flash_sucks_memory_leaks_security_holes/

Why use Java? : programming
http://www.reddit.com/r/programming/comments/9ncox/why_use_java/

2009年09月22日

■_

・文教堂
してやられた○| ̄|_

■_

この辺はいつももめるよなあ。

Emacs Part 31 
188 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:06:04 ID: Be:
    Emacsはオープンソースではない
    フリーソフトウェアだ。 

189 テスト結果 [sage] 2009/09/18(金) 11:11:42 ID: Be:

    >>188のIQ=68

190 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:18:05 ID: Be:
    フリーソフト⊇オープンソースだっけ?
    それとも両者は直行する概念? 

191 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:20:50 ID: Be:
    http://www.gnu.org/philosophy/free-sw.ja.html
    を満たせばフリーソフトウェア。
    http://www.opensource.jp/osd/osd-japanese.html
    を満たせばオープンソース。 

192 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:22:16 ID: Be:
    >>190
    オープンソースであってもフリーではないソフトを書くことは
    法律上可能。Emacsがオープンソースなのは自明。 

193 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:24:06 ID: Be:
    オープンソースだけどフリーじゃない
    みたいなものってあるのかなー 

194 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:24:29 ID: Be:
    >>191
    そのフリーソフトはFSFがそう主張しているというだけで、世間的には
    無料で利用できるソフトをそう呼んでる。 

195 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:24:59 ID: Be:
    あなる 

196 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:27:07 ID: Be:
    >>194
    FSFが主張してるのは「フリーソフトウェア」。 

197 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:29:33 ID: Be:
    FSFがいくら主張したって「フリーソフト」と「フリーソフトウェア」を
    区別しろとか、いまさら無理。いくらがんばって布教しても絶対に無理。 

198 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:33:18 ID: Be:
    スレチだ。他でやれカスども 

199 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:37:15 ID: Be:
    スレチとケンカはUNIX板の華 

200 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:38:00 ID: Be:
    なんで>>188なんて話が出てきたんだろ。
    誰もオープンソースだなんて言ってないのに。 

201 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 11:40:03 ID: Be:
    >>200
    >>184 

202 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 15:12:44 ID: Be:
    フリーソフトは“自由なソフト”と呼ぼう--リチャード・ストールマン氏
    http://www.nikkeibp.co.jp/archives/243/243177.html 

203 名無しさん@お腹いっぱい。 [] 2009/09/18(金) 17:31:08 ID: Be:
    >>202
    うわ、これってリチャストからの提案だったのか。
    「自由なソフト」って英語の話を日本語にしてるから意味わからんのだと思ってたけど
    普通に日本語での話だったのね。確かに多義性はないけど、センス的に誰も使わんだろうな。
    俺だったら「無制限ソフト」とかにするけど。 

204 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 17:33:33 ID: Be:
    rmsは、それ、昔っから言ってる。
    「Think GNU」で読んだ記憶があるぞ。 

205 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 20:02:42 ID: Be:
    英語にこだわるからいかんのだ

    リーブル(libre)ソフトウェア
    リベルタ(libert )ソフトウェア
    フライハイト(Freiheit)ソフトウェア
    ヴリヘイド(Vrijheid)ソフトウェア 

206 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 20:14:20 ID: Be:
    フリーソフトの「フリー」は「無料の」という意。 

207 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 20:28:11 ID: Be:
    フリーマーケッ卜と同じだ 

208 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 20:31:41 ID: Be:
    スーパーフリーの「フリー」と同じだな 

209 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 20:53:06 ID: Be:
    >>207
    フリーマーケッ卜の「フリー」は「株価操作/政府介入/不自然な規制の無い」という意味。

210 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 21:08:27 ID: Be:
    flea market 

211 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 22:14:48 ID: Be:
    マーケッ卜とマーケットぐらい違うだろ 

212 名無しさん@お腹いっぱい。 [] 2009/09/18(金) 22:18:46 ID: Be:
    自由の方のフリーソフトじゃなくて、無料の方のフリーソフトを変えるという発想はないのかね。
    プライスレスソフトとか。 

213 名無しさん@お腹いっぱい。 [sage] 2009/09/18(金) 22:23:46 ID: Be:
    無料のくずソフト 

214 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 00:55:41 ID: Be:
    有料くずソフトだらけだもんな 

215 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 10:26:00 ID: Be:
    まぁ自分が使えないものはくずっていうからな 

216 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 13:18:33 ID: Be:
    RMS も落ちたなあ。

    ゴードンフリーマンをゴードン自由なマンとは言わんだろ。
    寝ごといってる暇があったらさっさとマルチスレッド実装しろよ… 

217 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 13:56:45 ID: Be:
    > RMS も落ちたなあ。

    いつから言い出したと思ってるんだ。昨日きょうじゃないんだよ。

218 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 14:03:03 ID: Be:
    オープンソースなんて話が出てくるよりずっと前から言ってるな。 

219 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 15:20:56 ID: Be:
    おまいら、>>216みたいな基地外を一々相手するな 

220 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 15:57:37 ID: Be:
    >>216はさびしいとしんじゃうの>< 

221 名無しさん@お腹いっぱい。 [] 2009/09/19(土) 16:02:25 ID: Be:
    無駄にRMS擁護してるやつってフリークライミングとかも自由なクライミングとか言ってんの?
    まあ言い張るのは自由だけど、みっともねえよ。 

222 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 16:09:42 ID: Be:
    オープンソースかどうかが重要であるが、フリーであるかどうかなんか重要じゃないの?
    おわかり? 

223 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 16:15:14 ID: Be:
    RMSは、ハッカーというよりは、政治家だから
    だから、思想や理念がはいる、運動だっていってるし 

224 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 16:21:33 ID: Be:
    今はソースコードがオープンであればいいやって人がほとんどだから
    RMSがいうフリーという思想はそりゃ最終的な理想だろうけどな
    まず実現しない 

226 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 18:31:03 ID: Be:
    >>222

    日本語で頼むよ。 

228 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 20:21:22 ID: Be:
    free 【形】
    1.自由な、束縛を受けない、〔正当な〕権利を制限されない、
    2.無料の、タダの

    RMS は1.の意味で free と言っていたはず
    ”〔不当なプロプライエタリ・ライセンスに束縛されない〕自由なソフトウェアが必要だ”
    という論調だったと記憶しているが

    ttp://www.youtube.com/watch?v=QP2dXeDg_cs&NR=1
    の 5:46 あたりから RMS 自身が説明している

    このスレの住人なら見たことあると思うが。
    初めて見たときは面白かったよ Revolution OS は 

229 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 20:31:43 ID: Be:
    これほど「何を今更」な話題も無いな 

230 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 20:32:04 ID: Be:
    RMS は Scheme とか CL のコードも書いてるのかな。
    一時期 GNU は Guile に力を入れてたみたいだけど、
    その後あんまり聞かないね。やっぱり elisp が一番
    手に着いてるのかな。 

231 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 20:34:25 ID: Be:
    つうか今でもコード書いてるんだろうか 

232 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 21:22:56 ID: Be:
    ところで、GNUとかFSFの関係とか人物相関図みたいなのよくわからんから
    誰かまとめて。 

233 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 21:47:57 ID: Be:
    >>231
    ちょっと前までは
    ときどき commit しては revert されてたけど
    最近あまり見ないかな?

234 名無しさん@お腹いっぱい。 [sage] 2009/09/19(土) 22:17:21 ID: Be:
    >ときどき commit しては revert されてたけど

    RMS かわいいなw 

commit しては revert されってのは知らなかったな。

C言語なら俺に聞け(入門篇) Part 53 
197 デフォルトの名無しさん [sage] 2009/09/22(火) 06:18:21 ID: Be:
    文章をコピーする関数で

    void copy(char *to,const char *from)
    {
    while(*to++ = *from++)
    ;
    }

    だと「不正な代入」と警告が出てしまう
    プログラム自体は動くがこの書き方だとまずい? 

198 デフォルトの名無しさん [sage] 2009/09/22(火) 06:36:10 ID: Be:
    別に問題ないけど、気になるんだったら
    while((*to++ = *from++))
    とすると警告出さなくなるかもしれない。 

199 197 [sage] 2009/09/22(火) 06:47:06 ID: Be:
    >>198の通りにやっても警告が出てしまう・・・
    本に書いてある通りの書き方だから多分大丈夫だと思うし深く考えなくていいかな 

200 デフォルトの名無しさん [sage] 2009/09/22(火) 06:49:30 ID: Be:
    つ
    memcpy 

201 デフォルトの名無しさん [sage] 2009/09/22(火) 06:50:39 ID: Be:
    なんでマニアックな書き方すんだ _?

202 デフォルトの名無しさん [sage] 2009/09/22(火) 07:03:40 ID: Be:
    マニアックでも何でもねーよ
    K&R本にも「このような書き方はマスターすべきである」と書いてあるし 

203 デフォルトの名無しさん [sage] 2009/09/22(火) 07:20:17 ID: Be:
    memcpyつかったほうが速いし、その本みたことないが
    不必要な場面でも使えとは書いてないだろ。  

204 デフォルトの名無しさん [sage] 2009/09/22(火) 07:23:47 ID: Be:
    なんでmemcpyが出てくるんだ?
    速いからったってstrcpyと比較しなきゃフェアじゃないだろ 

205 デフォルトの名無しさん [sage] 2009/09/22(火) 07:36:21 ID: Be:
    >>199
    なら while((*to++ = *from++) != 0)
    ってすればいい。

206 デフォルトの名無しさん [sage] 2009/09/22(火) 07:37:25 ID: Be:
    >>203
    もしかして、「K&R」の名前も知らないの?

    ここはC言語のスレだよね? 

207 デフォルトの名無しさん [sage] 2009/09/22(火) 07:48:32 ID: Be:
    K&R至上主義の方がちょくちょく現れるが、今の時代に合わせて変えていくことも大事だよ。
    この記法についてはidiomとして十分浸透しているものだから別にあれこれ言うつもりはないし、
    すんなり読めるようになっておくべきだとも思う。
    けれど、K&Rが絶対であるという考えは(そのように言ってはいないのかもしれないが)
    やめておいた方がいいよ。
    K&RのHello Worldは今ではタブーなコードであるし。 

208 デフォルトの名無しさん [boke] 2009/09/22(火) 07:49:39 ID: Be:
    Ken TompsonとDennis Ritchieはこの世界じゃ神様だもんな
    知らないモグリが回答なんてするはずないよね 

211 デフォルトの名無しさん [sage] 2009/09/22(火) 08:05:44 ID: Be:
    別にK&Rを読めとか崇拝しろとか言っているわけじゃない。
    もちろん、盲信すべきでもない。

    が、K&Rの名前も知らない
    つまり、まともに知識を得ようとすれば必ず知っているはずの名前を知らない
    という事実が問題。
    他の言語でも大抵最初に扱われる、「Hello worldの由来」としても。

    この点は、K&Rの知名度よりはだいぶ劣るが
    C FAQについても言える。
    何かについて詳しく知ろうと調べていけば、普通はこの存在を知ることになるし
    Cでまともなコードを書こうとしている人なら、存在自体は知っていなければおかしい。
    そして、鵜呑みにする必要は無いが、どんなことが書いてあるか等は目を通しておくべき。 

237 デフォルトの名無しさん [sage] 2009/09/22(火) 23:11:49  ID: Be:
    どうせ「第二版」というものを開いた事も無いような奴が寝言言ってるだけだろ 

238 デフォルトの名無しさん [sage] 2009/09/22(火) 23:19:42 ID: Be:
    タブーなんていう曖昧な表現をするあたり、何か問題があるにしても
    個人的な思い込みに反してるだけだろうしな 

239 デフォルトの名無しさん [sage] 2009/09/22(火) 23:31:39 ID: Be:
    return がないとかそういう話かね。 

240 デフォルトの名無しさん [sage] 2009/09/23(水) 00:06:28 ID: Be:
    main(argc,argv)
    int argc;
    char **argv
    {
    printf(""Hello world!);
    }

241 デフォルトの名無しさん [sage] 2009/09/23(水) 00:19:02 ID: Be:
    笑っちゃうね、もう少し勉強してからきてね 

242 デフォルトの名無しさん [sage] 2009/09/23(水) 00:29:53 ID: Be:
    >>240
    それはK&R1。 

■_ reddit に訊け!

Ask Programming Reddit: What do you smart guys think the next great leap in computing will be? : programming

Sex with robots. I'm waiting on you Japan.

待て、何だその意見はw

■_ Perl 6

ほんとわけわからん。


blog | Perlgeek.de :: Rats and other pets

Tue, 22 Sep 2009

Rats and other pets


If you follow perlmonks (or just about any other programming forum) you'll notice 
recurring questions related to floating point arithmetics not being accurate. A 
typical example would be

my $a =  1 / 10;
my $b = 1;
for ( 1..10 ) {
    $b -= $a;
}
if ( $b == 0 ) {
    print "yes\n";
} else {
    print "no\n";
}

printf "%.20f\n", $b;

When you run this with perl5 the output is

Perl 5でこれを実行すると出力は

no
0.00000000000000013878

And the reason is that 1/10 is an infinite binary fraction, and perl uses floating 
points internally with only a finite number of bits for the mantissa. So it subtracts 
ten times not exactly one tenth, but a number close to that, and in the end the result 
is not exactly zero, but of the order of magnitude of the machine precision.

となりますが、これは 1/10 が二進数では無限小数になるということと、perl が内部的に
使っている浮動小数点数は仮数部に有限のビットしか持っていないためです。
このため、上記の引き算で十回引かれているものは正確な1/10ではなく、その近似値に
なります。したがって計算結果は正確に0にはならず、機械イプシロンの magnitude の
orderの値になります。

However when you run the very same program with Perl 6, you get

しかしまったく同じプログラムを Perl 6で実行した場合の結果は次のようになります

yes
0.00000000000000000000

Why? Introspection helps:

なぜでしょうか?

$ perl6 -e 'say (1/10).WHAT'
Rat()
$ perl6 -e 'say (1/10).perl'
1/10

So 1/10 produces not a floating point number, but a Rat object. Rat is short for 
Rational, and it's a fraction that stores the numerator and denominator as an integer 
each, allowing exact arithmetics without floating point errors.

1/10 が生成するのは浮動小数点数ではなく、Rat オブジェクトになっています。
Rat とは Rational (有理数) の短縮形で、各々が整数で表現される
numerator と denominator として格納される fraction となっています。
これは浮動小数点数の誤差を排除して正確な計算 (exact arithmetics) を可能にしています。


(略)

■_ 本日の巡回から

2009年09月21日

■_

・小宮山引退
二年だけでしたがベイスターズにも在籍してましたし、まずはお疲れ様。 でも入団の経緯も退団のときも微妙だったなあ(^^;

・ペースが上がらない
この連休中に日数×2 冊くらい積読から崩していきたいところなんだが。 新書やコミックはともかくハードカバーとか、大判の技術書はきついw

■_


Twitter / Tajima: スラドだなぁ。ハードウェア命令にBCD演算が存在する ...
スラドだなぁ。ハードウェア命令にBCD演算が存在するとか想像できないんだろうな。
  > 言語のコア仕様にBCD演算を入れるのは変態仕様としか思えない。 

50周年を迎えたCOBOLの話ですか。 最近のトピックかと思ったら(先週あたりに50周年だったので)何ヶ月か前の だったのですね → COBOL生誕 50 周年、しかしまだまだ現役 - スラッシュドット・ジャパン

元のコメントにはライブラリに切り分けてとかあったんですが、 COBOLの成立時期やら考えるとそれも無理な話ではあるんですよね。 「標準ライブラリ」というのが言語そのものとは独立して決まるようになったのって 多分 Cの前後辺りだったような。Pascal でも「標準ライブラリ」はないですし、 Writeln のような手続きもライブラリに独立していなくて言語仕様に入ってますよね。

んで細かいところは覚えてないんですが、単にBCD演算使うということだけじゃなくて こういう演算すると有効桁がどうなるとかかなり細かく決められていたような。

■_

C++のラムダ式についてあーだこーだ書いたら なんかこの辺調べろという電波を受信したので。



Using and Porting the GNU Compiler Collection (GCC) - C 言語ファミリに対する拡張機能

入れ子関数

(略)

入れ子関数のアドレスをどこかに格納したり別の関数へ渡したりすることによって、 入れ子関
数の名前が有効なスコープの外部からでも、 入れ子関数を呼び出すことができます。

hack (int *array, int size)
{
  void store (int index, int value)
    { array[index] = value; }

  intermediate (store, size);
}

ここで、 関数intermediateはstoreのアドレスを引数として受け取っています。 intermediate
がstore を呼び出すと、 storeに渡された引数はarrayへの値の格納に使われます。 しかし、 
このテクニックは、 入れ子関数を包含している関数 (この例ではhack) が終了しない限りに
おいてのみ有効です。

入れ子関数を包含する関数が終了した後に、 その入れ子関数のアドレスを使ってその入れ子関
数を呼び出そうとすると、 とんでもない事態が発生することになるでしょう。 入れ子関数を包
含するスコープが終了した後にその入れ子関数を呼び出してしまい、 その入れ子関数が既にス
コープ内には存在しない変数を参照したとしても、 運良く問題に遭遇せずにすむこともあるか
もしれませんが、 そのような危険を冒すのは賢明なことではありません。 しかし、 スコープ
内には存在しなくなってしまったものを 入れ子関数がまったく参照していないのであれば、 何
も問題は発生しないはずです。

GNU CCは、 入れ子関数のアドレスの獲得を、 トランポリン(trampoline)と呼ばれるテクニッ
クを使って実装しています。 これに関する解説が、 
`http://master.debian.org/~karlheg/Usenix88-lexic.pdf' にあります。

入れ子関数を包含する関数から継承されたラベルが、 その包含関数の中で明示的に宣言されて
いるのであれば、 入れ子関数はそのラベルにジャンプすることができます (局所的に宣言され
たラベルを参照)。 そのようなジャンプは、 gotoを実行した入れ子関数だけでなく、 その入れ
子関数が呼び出されるまでに途中で呼び出された関数をすべて終了させ、 即時に包含関数側に
制御を戻します。 以下に例を示します。

bar (int *array, int offset, int size)
{
  __label__ failure;
  int access (int *array, int index)
    {
      if (index > size)
        goto failure;
      return array[index + offset];
    }
  int i;
  ...
  for (i = 0; i < size; i++)
    ... access (array, i) ...
  ...
  return 0;

 /* access がエラーを検出すると、
    制御は access からここへ移る */
 failure:
  return -1;
}

ということでこれから Usenix88-lexic.pdf を読むところです。 まあ、トランポリンやらなんやらはすでに知ってはいるんですが。

■_ Strawberry

知らんかった。


モダンPerlの世界へようこそ:第16回 Perl::Dist::Strawberry:何味のアイスクリームがお好きですか?|gihyo.jp … 技術評論社

Strawberry Perlに欠けているもの

ただ,Strawberry Perlは,まだまだ一般に浸透しているとは言えません。もちろんその最大の
理由は,ActivePerlに比べて10年も後発だからでしょうが,メンテナ側に本職のWindows使いが
ほとんどいないこともあって,Windows的なフリーウェアを期待しているユーザにとっては随所
に違和感が残っていることもその理由のひとつかもしれません。たとえば,インストーラの使い
勝手の点ではActivePerlに及びませんし(ちなみに,最新版では残念ながらWindows 2000へのイ
ンストールができなくなっています),結局PPMのバンドルを余儀なくされたように,ライトユ
ーザ,特にWindowsネイティブのライトユーザにとって,CPAN+gccというのは(うまく動いてい
る分には問題ないですが)ひとたびエラーが出ると対処に困るものでしかない,というのも残念
ながら真実でしょう(ふだんからCPANに親しんでいる我々にとってはなんでもないことですが,
「Strawberry Perlさえ入れれば,あとはなんでもCPANからインストールできる」という謳い文
句だけ聞かされていた人にとっては,モジュールをインストールしようとしたらエラーが出るな
んて話が違う,というのが正直な感想だろうと思います)。

もっとも,Strawberry Perlがそのような層をターゲットにすべきかどうかはまた別問題。コミ
ュニティベース,しかもそのほとんどが片手間にしかWindowsを使わない開発者ばかりの
Strawberry Perlが,かれこれ15年近くもWindows向けPerlやWin32専用のモジュール群のメンテ
ナンスに関わってきたActiveState社のActivePerlと同じ土俵で相撲を取っても勝ち目はないの
ですから,初心者にはひとまずActivePerlを勧めて,Strawberry PerlはActivePerlに飽き足ら
なくなった中級者以上をターゲットにする,と棲み分けるのが無難な選択肢,と思われるのです
が,Strawberry Perl界ではいま,ActivePerlに追いつけ,追い越せとばかりに,Strawberry 
Perlに欠けている大きなピースを埋めるための作業が続けられています。

次回はそのピースについて,簡単に現状をまとめておこうと思います。

Windows 2000 にインストールできないのか(ということは9xもだめなんだよね?)。 んで、


モダンPerlの世界へようこそ:第16回 Perl::Dist::Strawberry:何味のアイスクリームがお好きですか?|gihyo.jp … 技術評論社

ActivePerlの興隆

(略)

Perlが初めてWindows(や,それ以前のMS-DOS)で動くようになったのがいつだったのかは調べ
きれなかったのですが(少なくともjperlが1991年当時すでにMS-DOS上で動いていたことは記録
に残っています),ことPerl 5に関していえば,Microsoft社が1995年当時カナダのHIP 
Communications社にいたディック・ハルト(Dick Hardt)氏のチームに出資してPerlの移植を依
頼したのがそもそもの起こりだったようです。

(略)

また,このMicrosoft社との提携はもうひとつ,PPM(Perl Package Manager)と呼ばれる副産物
も生み出しました(そのベースとなったOpen Software Description Formatの仕様は1997年に
Microsoft社らが策定したものです)。このPPMを使うことで,ActivePerlのユーザはCPANモジュ
ールを(Perlバイナリと同じコンパイラでコンパイルした)バイナリの状態でインストールでき
るようになりました。CPANモジュールをインストールするためだけに高額なMicrosoft社の
Visual C++を買う必要はなくなりましたし,わざわざMinGWやCygwinのコンパイラをインストー
ルする必要もなくなりました(※1)。「ActivePerlさえインストールしておけば,あとは何も
入れなくて大丈夫」という手軽さが,Unix系のディストリビューションに比べて圧倒的にユーザ
ベースの多いWindows環境でライトユーザの獲得にどれほど貢献したかは説明するまでもないで
しょう。

※1

    なお,この辺Windows環境でPerlを使わない方からはよく誤解されるのですが,ActivePerl
であっても,MSVCやMinGW環境を適切に設定すればCPANから直接モジュールをインストールする
ことはできます。PPMはあくまでもコンパイラの設定やリンクするライブラリが異なることによ
るXSモジュールの不具合を防ぐため,クライアントのアーキテクチャにあわせてコンパイル&テ
ストされたモジュールをインストールできるようにする仕組みであって,牧大輔氏の『モダン
Perl入門』にあるような「PPMレポジトリ形式になっていないとモジュールをインストールする
ことができません」ということはありません。

DOS 用 jperl はもう一、二年遡れそうな気がするなあ。 っても多分 pcs の junk.test に投稿されたものだろうから、 はっきりとした日付はやっぱりわからないか。 serow さんは今どこでなにをしてらっしゃるのでせうか。

■_

今月号の Software Designに掲載されているカーニハン大先生への インタビュー記事は必読だと書きましたが、翻訳前のものがWeb上に公開されているようです。


Software Designers~The People Behind the Code~(英語):#6 Brian Kernighan Professor, Computer Science, Princeton University|gihyo.jp … 技術評論社

2009年9月21日

初出:Software Design2009年10月号(2009年9月18日発売)

Bart Eisenberg

Brian Kernighan is one of the founding fathers of modern programming. He was a member 
of the technical staff at Bell Laboratories at the time UNIX and C were developed, and 
co-authored the book The C Programming Language with C’s inventor, Dennis Ritchie. 
Another among his eight books is the classic The Elements of Programming Style. But 
since 2000, Kernighan has taken on a different role, that of master teacher, mentor, 
and at times friendly critic of students at Princeton University.

(略)

What skills do you want them learn?

    I would like them to have a repertoire of tools at their disposal, including 
    different ways of thinking about how to attack a programming problem. I want
    them to think about all of the potential tradeoffs they will encounter, to
    understand that you never get something for free: if you push really hard in
    one direction, other directions are going to suffer. I work hard on getting
    them to do things that will always be important, like testing their programs.
    I want them to consider building special-purpose tools or languages that will
    help them automate some process, to use the machine to do more of the work for
    them. And I want them not only to build systems, but be able to talk and write
    about them, informally and in formal presentations. That’s pretty important
    regardless of what they are doing.

(略)

How has software design changed since you were at Bell Labs?

    It’s gotten incredibly more complicated, with larger systems requiring more 
    complex tools. We now have development environments like Visual Studio, Eclipse,
    and Xcode ‐ all very powerful tools for building software. But these tools also
    hide what’s going on under the hood, which means you can find yourself with a
    problem too complicated to figure out, at least in a finite time with ordinary
    intelligence. I grew up in an environment where if I had a good idea, I could make
    a prototype with a few thousand lines of code. I understood all the pieces, I could
    be pretty confident that the prototype would do what it should, and if it didn’t,
    I could figure out why. Today, I might use JavaScript to glue together client-side
    libraries and connect it all to other libraries sitting on a server. I might write
    the same amount of code, and if I got it to work, it would be enormously more
    sophisticated than what could have been done 30 years ago. But I would understand
    much less about what was actually happening, and if it didn’t work, it would be
    far harder to figure out why. 

(略)

是非とも今月号を買って、翻訳のほうを読んでください。

■_


一つ前へ 2009年9月(中旬)
一つ後へ 2009年10月(上旬)

ホームへ


Copyright (C) 2009 KIMURA Koichi (木村浩一)
この文書の無断転載はご遠慮ください(リンクはご自由にどうぞ)。

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