■_
BOOKSCANにユーザー登録したはいいが、待ち時間が ○| ̄|_
Pythion の辞書リテラルの要素の評価順の件(ぐ、「の」が続きすぎ)ですが チケットが→ Issue 11205: Evaluation order of dictionary display is different from reference manual. - Python tracker
一つ前へ
2011年2月(上旬)
一つ後へ
2011年2月(下旬)
BOOKSCANにユーザー登録したはいいが、待ち時間が ○| ̄|_
Pythion の辞書リテラルの要素の評価順の件(ぐ、「の」が続きすぎ)ですが チケットが→ Issue 11205: Evaluation order of dictionary display is different from reference manual. - Python tracker
たぶんマ板のどっかのスレから Hacker News | Stackoverflow: Are there any famous one-man-army programmers? → Are there any famous one-man-army programmers? - Programmers - Stack Exchange で、名前だけ抜き出してみた。
Are there any famous one-man-army programmers? - Programmers - Stack Exchange Lately I have been learning of more and more programmers who think that if they were working alone, they would be faster and would deliver more quality. Usually that feeling is attached to a feeling that they do the best programming in their team and at the end of the day the idea is quite plausible. If they ARE doing the best programming, and worked alone (and more maybe) the final result would be a better piece of software. I know this idea would only work if you were passionate enough to work 24/7, on a deadline, with great discipline. So after considering the idea and trying to learn a little more, I wonder if there are famous one-man-army programmers that have delivered any (useful) software in the past? programmer one-man-army
John Carmack Jamie Penney Donald Knuth Sean Bright Steve Woznia Jason Baker Richard M. Stallman (RMS) Steve Rowe Chris Sawyer Michael Itzoe Linus Torvalds Bill Joy Graeme Perrow Guido van Rossum (author of Python) John Resig Jonathan Sampson Larry Wall Anders Hejlsberg Mehdi Asgari Bram Cohen Michael Stum Bjarne Stroustrup Yukihiro Matsumoto Chris Lutz Oren Eini aka Ayende Rahien DJ Bernstein Jon Skeet David Basarab _why Geo ChrisW Matt Briggs Steve Gibson Sid Meier Phil Katz Chuck Moore John Backus - Fortran Stephen Wolfram - Mathematica package Sid Meier - Civilization Tim Berners-Lee - inventor of World Wide Web Phil Zimmermann - PGP Gus Mueller. Paul D. Waite Khaled Mardam-Bey David Morton
面倒になったので最初の方だけw
Last Friday’s change of strategy was a surprise and shock for the whole Qt organization.
ソフトの場合、経年劣化はしない。そのかわり、周囲状況が変化する。もともとテストしていた環境がかわってしまうのだ。a
自動販売機の商品の入れ替えがあってコーンスープがなくなったのを見ると、 もうすぐ春なのかと思ったり思わなかったり。
他から引っ張ってきた文章ばかりでごめんなさい。と誰となく。
買ってみた
Amazon.co.jp: 速く・正確に読む ITエンジニアの英語: 平井 通宏: 本
読んだ
ノムさんが好きでないってのは、この本で書かれているような話があるからなんだよね。
ってまあどちらの言い分を信じるかということになるのだけど。
長島一茂のエピソードは面白かった。
那須野の話もちょっとあったけど、あんまり思い出したくないな(笑)
そこまでの金を積んでとるほどの選手かとかきつい。
reddit でコメント1000個越えてた。
Another coding story There's a little 3-digit LED that shows the suit's temperature, and he's putting the temperature into string form for displaying there. So his code looks something like this: スーツの温度を表示する三桁のLED があって、彼はスーツの温度の数値を文字列化して LED 表示するようにしたのだけど、彼の書いたコードはこんな感じだった temp_to_str (int temp) { char str[4]; sprintf (str, "%d", temp); and so forth. I tell him, "Hey, this is no good, because if the temperature ever goes over 1000 (or under -100), you'll overflow your string and the game will just totally crash without warning." わたしは彼に「おいおい、これはダメだよ。温度が1000度を超えたりマイナス100度を下回ったり したら文字列がオーバーフローしてゲームが警告もなしにクラッシュしちゃうよ」と指摘しました。 He says, "Oh yeah, okay, whatever, I'll fix it." 彼は「ああ、そうですね。直します」と答えました。 So I look back at the code a couple days later, to make sure that he's fixed it, and he has indeed changed the code. It now looks like this: 数日後にコードを見直してみたところ、確かに彼は修正を行ってコードを変更していましたが それは次のようなものでした temp_to_str (int temp) { char str[4]; if (temp <= -100 || temp >= 1000) fprintf (stderr, "WARNING: PROGRAM IS ABOUT TO CRASH!\n"); sprintf (str, "%d", temp);
この手の話がたくさんあるらしいです → This pretty much describes most programmers I've hired :( : programming
sedの正規表現がひどい件 - 檜山正幸のキマイラ飼育記
で、
Emacsだと \| とか使うけど、* が使えるのに \+ と \? はないでしょうよ。
と憤慨されていますが、実はそれらは本来の sed のものではなく、GNU による拡張です。
以下 info から。
`\+' As `*', but matches one or more. It is a GNU extension. `\?' As `*', but only matches zero or one. It is a GNU extension.
`REGEXP1\|REGEXP2' Matches either REGEXP1 or REGEXP2. Use parentheses to use complex alternative regular expressions. The matching process tries each alternative in turn, from left to right, and the first one that succeeds is used. It is a GNU extension.
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]... -n, --quiet, --silent suppress automatic printing of pattern space -e script, --expression=script add the script to the commands to be executed -f script-file, --file=script-file add the contents of script-file to the commands to be executed -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if extension supplied) -l N, --line-length=N specify the desired line-wrap length for the `l' command --posix disable all GNU extensions. -r, --regexp-extended use extended regular expressions in the script.
かなり大まかに書くと、 ed/sed/grep → egrep/awk で変更があり、その後 Perl が登場して大きく変わってきています。 この最初のグループの場合、 繰り返しを表すメタ文字は '*' だけ。 選択のメタ文字 ('|') はない。 後方参照ができる。 '(' (と ')' はメタ文字ではなく、グルーピング(もしくはキャプチャー)は '\(' と '\)' で行う。 といった特徴があります。 最後のカッコにエスケープをつけるのは、ソースコードで関数呼び出し部分を検索するときなどに カッコがメタ文字だといちいちエスケープする必要があるのは面倒だからそうなった。 という話をどこかで目にした覚えがあります。
そして egrep (と awk)。こちらは 繰り返しを表すメタ文字に '+' と '?' が増えた。 選択のメタ文字 ('|') が増えた。 グルーピングのメタ文字は '(' と ')' に。ただし後方参照はできない (といいつつ GNU 拡張ではできたりします)。 というものでした。 最後の制限は、おそらく最初は(単純な) DFA を使った実装であったからだと思われます。
概ねこれらの特徴を持った BASIC Regular Expression と EXTENDED Regular Expression というものが POSIX で規定されています。 GNU での拡張で BASIC ~ の方で '+' や '?'、'|' をそのまま使わなかったのは 多分既存のスクリプトの誤動作を避けるためであったと思われます (どこかでそんな記述を見た覚えが)。
話を GNU sed に戻すと、
-r, --regexp-extended use extended regular expressions in the script.
このオプションを指定すると、egrepやawkのような正規表現、
つまり '+'、'?'、'|'、'('、')' が使えます。
また、コンパイル時にPCREが使えるようにしておくと、
もうひとつオプションが増えて、Perlっぽい正規表現記述ができるようになります。
「Perlの正規表現」といっても最近増えたものは使えないとかいろいろあるのですが長くなりますので割愛。
新山さんとこで紹介されてたライブラリのコードが気になったのでちょっと調べてみた。 2011年2月
2011年2月 #include <string.h> #include <stdlib.h> #include <stdint.h> #include <limits.h> #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) size_t strlen(const char *s) { const char *a = s; const size_t *w; for (; ((uintptr_t)s & ALIGN) && *s; s++); if (*s) { for (w = (const void *)s; !HASZERO(*w); w++); for (s = (const void *)w; *s; s++); } return s-a; }
この ALIGN やらはヘッダーファイルじゃなくてそれを使う .c でいちいち 定義してるのね。
んで、ALIGN はまあいいとして、
#define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
HASZERO が気になった。
まず、ONES はどういうものかというと、各バイトが 01 となっている size_t のデータを作る。
01_01_01_01
こんなん。で、HIGH は
80_80_80_80
のように、各バイトの最上位ビットだけがたったものを作る。
そして問題の HASZERO。この前半部分の (x)-ONES & ~(x)
(ある値から1引いたものと、ビット反転したものとの and をとる)
には見覚えがあったのだけど、具体的な目的(動作)が思い出せなかったw
確か「ハッカーのたのしみ」だよなあと思いつつも、例によってこんなときに本が行方不明w 仕方がないのでぐぐるさんの力を借りてみた。
Bit Twiddling Hacks Determine if a word has a zero byte あるワードがゼロのバイトを含むかどうか判定する // Fewer operations: unsigned int v; // 32-bit word to check if any 8-bit byte in it is 0 bool hasZeroByte = ~((((v & 0x7F7F7F7F) + 0x7F7F7F7F) | v) | 0x7F7F7F7F); The code above may be useful when doing a fast string copy in which a word is copied at a time; it uses 5 operations. On the other hand, testing for a null byte in the obvious ways (which follow) have at least 7 operations (when counted in the most sparing way), and at most 12. // More operations: bool hasNoZeroByte = ((v & 0xff) && (v & 0xff00) && (v & 0xff0000) && (v & 0xff000000)) // OR: unsigned char * p = (unsigned char *) &v; bool hasNoZeroByte = *p && *(p + 1) && *(p + 2) && *(p + 3); The code at the beginning of this section (labeled "Fewer operations") works by first zeroing the high bits of the 4 bytes in the word. Subsequently, it adds a number that will result in an overflow to the high bit of a byte if any of the low bits were initialy set. Next the high bits of the original word are ORed with these values; thus, the high bit of a byte is set iff any bit in the byte was set. Finally, we determine if any of these high bits are zero by ORing with ones everywhere except the high bits and inverting the result. Extending to 64 bits is trivial; simply increase the constants to be 0x7F7F7F7F7F7F7F7F. For an additional improvement, a fast pretest that requires only 4 operations may be performed to determine if the word may have a zero byte. The test also returns true if the high byte is 0x80, so there are occasional false positives, but the slower and more reliable version above may then be used on candidates for an overall increase in speed with correct output. bool hasZeroByte = ((v + 0x7efefeff) ^ ~v) & 0x81010100; if (hasZeroByte) // or may just have 0x80 in the high byte { hasZeroByte = ~((((v & 0x7F7F7F7F) + 0x7F7F7F7F) | v) | 0x7F7F7F7F); } There is yet a faster method — use hasless(v, 1), which is defined below; it works in 4 operations and requires no subsquent verification. It simplifies to bool hasZeroByte = (v - 0x01010101UL) & ~v & 0x80808080UL; The subexpression (v - 0x01010101UL), evaluates to a high bit set in any byte whenever the corresponding byte in v is zero or greater than 0x80. The sub-expression ~v & 0x80808080UL evaluates to high bits set in bytes where the byte of v doesn't have its high bit set (so the byte was less than 0x80). Finally, by ANDing these two sub-expressions the result is the high bits set where the bytes in v were zero, since the high bits set due to a value greater than 0x80 in the first sub-expression are masked off by the second. Paul Messmer suggested the fast pretest improvement on October 2, 2004. Juha Järvi later suggested hasless(v, 1) on April 6, 2005, which he found on Paul Hsieh's Assembly Lab; previously it was written in a newsgroup post on April 27, 1987 by Alan Mycroft.
そのものが見つかってしまったw
bool hasZeroByte = (v - 0x01010101UL) & ~v & 0x80808080UL;
1引いたものと~ の解説はこんなん。
ビットを数える・探すアルゴリズム MSB から (LSB から) 0 が立っている数を数える レジスタの中のビット列の左側 Leftmost bit から見て 0 が連続している数を Number of Leading Zero (NLZ) という (0 の場合には 32 が返る)。 言い換えると 0 ビット目から見て 1 が最初に立っているビット位置のことである (1 がどこにも立っていない場合には 32 が返ると する)。 同様にレジスタの中のビット列の右側 Rightmost bit からみて 0 がいくつ連続してい るかを Number of Training Zero (NTZ) と呼ぶ。 例をあげると NLZ こっちから 0 の数を数える → 0000010010000100 NTZ 0000010010000100 ← こっちから 0 の数を数える 32-bit 値 0000010010000100 の場合、 NLZ は 5 で、NTZ は 2 となる。 NTZ を求める NTZ は比較的簡単である。 x&(-x) を行うと左側から最初に 1 が立っているアドレスのみ を残して 他のビットは 0 で埋まるので、 (x&(-x))-1 を 計算しそのビット数を数えれば よい。 x&(-x) 0101100 → 0000100 (x&(-x))-1 0101100 → 0000011 count_bits((x&(-x))-1) 0101100 → 2 NTZ は NTZ(x) = count_bits((~x)&(x-1)) でもよい。
ちと調べごとをしていたら Algol-W に行き当たりまして。
Algol W - Progopedia - Encyclopedia of Programming Languages Algol W ALGOL-W is a programming language. It was based on a proposal for ALGOL-X by Niklaus Wirth and Tony Hoare as a successor to ALGOL 60 in the IFIP Working Group 2.1. When the committee decided that the proposal was not a sufficient advance over ALGOL 60, the proposal was published Niklaus Wirth & C. A. R wikipedia: Hoare (1966). Wirth supervised a high quality implementation for the IBM/360 at Stanford University that was widely distributed. It represented a relatively conservative modification of ALGOL 60, adding string, bitstring, complex number and reference to record datatypes and call-by-result passing of parameters, introducing the while statement, replacing switch with the case statement, and generally tightening up the language. The implementation was written in PL/360, an ALGOL-like assembly language designed by Wirth. The implementation included influential debugging and profiling capabilities.
call-by-result ってどんなんだっけか。 bitstring はあるけど、集合型は持ってないのかな?
http://www.fh-jena.de/~kleine/history/languages/AlgolW-Manual.pdf
そういやなんで #! なのだろうかと。 「#!」 (SheBang)の語源を徹底追求 「切り刻んでビックリ」 - karasuyamatenguの日記
The #! magic, details about the shebang/hash-bang mechanism The Origin See an old mail from Dennis Ritchie introducing the new feature, quoted in 4.0 BSD /usr/src/sys/newsys/sys1.c. So this #! mechanism origins from Bell Labs, between Version 7 and Version 8, and was then available on 4.0BSD (~10/'80), although not activated per default. (The abovementioned path to sys1.c was an option, the regular path was /usr/src/sys/sys/). Two important differences to current implementations are: The length of the line was limited to 16 (Research Unix) or 32 (BSD) bytes. "Arguments" were not delivered. It was then implemented by default on 4.2BSD (~09/'83), /usr/src/sys/sys/kern_exec.c by Robert Elz. This implementation delivered all #! arguments as a single one. Less than a year after 4.0BSD, but more than two years before 4.2 BSD, #! was also added to 2.8BSD (~07/'81), but not active by default. 2.x BSD is a different development line, independent from 4 BSD. It's a 7th edition (V7) kernel with fixes activated by macros. The macro for the #! code is not present in a makefile, so you had to activate it yourself. The code wording is slightly different from 4 BSD. On 2.8 BSD, #! seems to come from the U.S. Geological Survey in Menlo Park, not from Berkeley. (Thanks to Gunnar Ritter for pointing out the origins in 4.0 and 4.2BSD in de.comp.os.unix.shell, to Jeremy C. Reed for mentioning Robert Elz, and to Richard Kettlewell for spotting 2.8BSD on TUHS mailing list.) In 4.3BSD Net/2 the code was removed due to the license war and had to be reimplemented for the descendants (e.g., NetBSD, 386BSD, BSDI). Among the public releases from Bell Labs, #! was not added until SVR4 ('88) according to a TUHS list discussion. System III and SVR1 definitely had not implemented it, yet.
Why do some scripts start with #! ... ?
PDP だか VAX のそれっぽい機械語になるとかだったら面白かったのに> #!
…そもそもなんでコメントが # になったんだっけ?
Why are there so many Schemes and which one should I choose? : lisp Here are the Scheme implementations I can see with my package manager in Debian squeeze: * Scheme9 * MIT Scheme * Scheme->c * PLT Scheme * Gambit-C * scsh * Scheme48 * Elk * Scm * Sigscheme * Ikarus * CHICKEN * Gauche * TinyScheme * Stalin Okay, some of these are interpreters, some are compilers, some are both. But in general - are these very different? Should I try each one? Should I just stick with something standard (what's that?) Why are there so many? (I'm interested mostly in teaching myself Lisp/Scheme and playing around with it. I work as a research assistant in computational linguistics and write a fair amount of code.)There are so many implementations because: そんなにも多くの実装があるその理由は 1. It's a very small language. At the same time, it's a very flexible, powerful language. Taken together, these characteristics mean that it's relatively easy toi implement, but you still get something pretty useful out of the effort. So people interested in learning how to write compilers and interpreters often implement Scheme or some variant, especially if they generally like Lisp. 2. The language has existed for a long time. Since it's easy to implement a useful version of it, a lot of people have done it. 3. The nature of Lisp in general and Scheme in particular make it a useful platform for trying out ideas about language implementation, or about extensions to the language. So people interested in those things are often inclined to write or modify a Scheme. As for the list of Schemes you provided, here are brief comments on the ones I'm familiar with: MIT Scheme is large and old and interesting to poke around in. PLT Scheme is now Racket. It's a long-term effort to build a comprehensive IDE and environment for learning how to write software well. It's very good, especially if you like all-encompassing programming environments with lots of libraries. Gambit-C is my favorite Scheme. It's basically R5RS with extensions, with a compiler that produces very fast code that integrates easily with C code. It is not a development environment; it is a compiler and an interpreter. It has everything one needs for serious programming, but not everything one might want (sometimes you have to port or write libraries yourself). Elk is an interpreter intended as an extension and scripting language. It's been around a long time. I haven't looked at it in some years, but aat one time I found the source code very educational. Ikarus is a new Scheme, a native Scheme-to-x86 machine-code compiler. It supports R6Rs and generates very fast code. It serves the useful purpose of demonstrating that a good native-code compiler can also be understandable. Chicken occupies a niche next-door to Gambit. It's another Scheme compiler that uses C as an intermediate language for compilation. Compared to Gambit, the most interesting differences are that (a) Chicken uses a very interesting implementation strategy that is educational for language implenentors, and (b) it has a lot richer set of libraries than Gambit's. Gauche is a well-implemented and -supported Scheme interpreter (actually a compiler with VM), designed as a comfortable interpreter for those sorts of programming tasks that are well served by a comfortable interpreter (scripting, system tools, apps in which rapid prototyping and easy changes are more important than absolute execution speed). It has a rather nice object system. Stalin is an aggressive whole-program optimizing compiler for Scheme. It doesn't have a pleasant interactive programming environment, and isn't intended to. It's intended to push the boundaries of execution speed with programs whose source code is written in Scheme, and it does that very well.Thanks, that's a lot of information. If you don't mind answering a couple of questions, how did you get to be so experienced with all of these and do you actually end up integrating Gambit-C with C much of the time?
かいとうなげー
あれ。Guile がない?
特に、大学でソフトウェアというものを学問、芸術、美学のように教え込まれている学生にとっては……。
知ってると思ってたことも実は表面的な部分だけだった、できると思っていたこともやってみたらうまくできなかった、 難しくないと思ってたことも実際にやってみると難しかった、そんなことがよくあります。残念。
コーディングしている時間がにゃい。
Guile も 2.0かあ。自分が追っかけてた頃は 1.0 にもなってなかったような気が。
GNU Guile 2.0.0 released We are pleased to announce GNU Guile release 2.0.0, the first of a new stable series and the result of almost 3 years of work. It provides many new noteworthy features, most notably the addition of a compiler and virtual machine. (ry) Highlights of changes in 2.0.0 (since the 1.8.x release series): * New compiler infrastructure and VM Guile 2.0 compiles Scheme code to bytecode, which is then interpreted by the VM. This gives a noticeable performance improvement compared to earlier Guile series. Guile 2.0 は Schemeのコードをバイトコードへコンパイルします。コンパイル されたバイトコードは VM によって解釈実行されます。これは目に見えるほどの パフォーマンスの向上をもたらします。 By default source code is compiled automatically as it is encountered, without any manual intervention. The "guile-tools compile" command provides a command-line interface, and there are also Scheme procedures to drive the compiler. ソースコードはデフォルトで自動的に、マニュアル操作なしにコンパイルされます。 Besides Scheme, the compiler comes with front-ends for the ECMAScript and Emacs Lisp languages. Scheme に付随するコンパイラーは ECMAScript や Emacs Lisp へのフロントエンド を持っています #Emacs Lisp?! * New REPL, new debugger A read-eval-print-loop (REPL) is available. Compared to the REPL in earlier releases, it supports "meta-commands" that provide convenient access to interactive programming features. For instance, the ",compile" meta-command compiles the given expression, ",profile" shows an execution profile of the given expression, etc. Any error or uncaught exception leads to a "recursive REPL", which is a REPL augmented with debugging capabilities: it has meta-commands to display a backtrace, inspect the variables on a stack frame, etc. The recursive REPL can be quit to return to the original one. * Support for hygienic macros The `syntax-rules' and `syntax-case' hygienic macro systems are supported natively by Guile, without importing `(ice-9 syncase)', and work across module boundaries. They are a better replacement for `defmacro'. * Unicode support Scheme strings can hold any Unicode character, and ports can read and write Unicode text in various encodings. * Partial R6RS compatibility The `library' and `import' forms of R6RS are supported, and all the R6RS libraries defined in the standard are available. See "R6RS Incompatibilities" in the manual, for details about remaining incompatibilities. * New dynamic foreign function interface The `(system foreign)' module provides a new dynamic foreign function interface (FFI). It allows bindings to C libraries to be written without a single line of C code. * Switch to the Boehm-Demers-Weiser garbage collector Guile now uses the Boehm-Demers-Weiser conservative garbage collector (aka. libgc). It makes interaction with C code easier making, for instance, the use of mark and free SMOB procedures optional in many cases. It also improves performance. * New modules ** `(srfi srfi-18)', more sophisticated multithreading support ** `(srfi srfi-27)', sources of random bits ** `(srfi srfi-38)', External Representation for Data With Shared Structure ** `(srfi srfi-42)', eager comprehensions ** `(srfi srfi-45)', primitives for expressing iterative lazy algorithms ** `(srfi srfi-67)', compare procedures ** `(ice-9 i18n)', internationalization support ** `(ice-9 futures)', fine-grain parallelism ** `(rnrs bytevectors)', the R6RS bytevector API ** `(rnrs io ports)', a subset of the R6RS I/O port API ** `(system xref)', a cross-referencing facility (FIXME undocumented) ** `(ice-9 vlist)', lists with constant-time random access; hash lists ** `(system foreign)', foreign function interface ** `(sxml ...)', tools for XML processing ** `(texinfo ...)', parsing and production of Texinfo documents ** `(sxml match)', a pattern matcher for SXML ** `(srfi srfi-9 gnu)', extensions to the SRFI-9 record library ** `(system vm coverage)', a line-by-line code coverage library ** `(web ...)', modules for URI and HTTP handling ** `(ice-9 poll)', a poll wrapper ** `(system base lalr)', the `lalr-scm' LALR(1) parser generator ** `(statprof)', statistical profiler * New dependencies ** libgc 7.x, http://www.hpl.hp.com/personal/Hans_Boehm/gc/ ** GNU libunistring, http://www.gnu.org/software/libunistring/ ** libffi, http://sourceware.org/libffi/
1.7 あたりでは cygwin でセルフビルドもできなかったんだけど、 その辺は…無理だろうなあ。
Guile 2 released : lisp And the more important information: Guile has a new vectorized logo! (No no, I do'nt say that because I'm the one who did it ;-p).Are they still planing to integrate it with emacs? Being able to write extensions in JavaScript and Lua as well as a better lisp complier would be really nice.Sonic Boom?
待てw>三人目
こっちも v2。
Announce: Niecza v2 - nntp.perl.org Announce: Niecza Perl 6 v2 This is the second announcement of a distinguished Niecza version, and the first to be regularly scheduled. Niecza tag announcements occur on the last Monday of each month. You can obtain a build of Niecza from [1]. This build contains a working compiler as a set of .exe and .dll files suitable for use with Mono or Microsoft .NET. If you wish to follow latest developments, you can obtain the source from [2]; however, you will still need a binary for bootstrapping, so you gain nothing from a "source is better" perspective. Niecza is a Perl 6 compiler project studying questions about the efficient implementability of Perl 6 features. It currently targets the Common Language Runtime; both Mono and Microsoft.NET are known to work. List of changes (変更点リスト) * The most significant change is that Niecza is now written in Perl 6 and compiled using itself. Perl 5 is no longer required to use Niecza (although some supporting tools need it). This makes Niecza a good amount faster on large files, or on small ones if the precompiler is used; the REPL is especially benefitted. Niecza runs as a single CLR process. もっともはっきりとした変更は、Niecza が Perl 6 で記述され、自分自身を 使ってコンパイルされるようになったという点です。Niecza を使うのに Perl 5 は必要なくなりました(ただし、一部のサポート用ツールが使っています)。 * Another very welcome change is that PaweÅ Murias (pmurias) is now a regular committer. * The REPL now keeps the same interpreting context between lines, so lines (after the first) are processed instantly and with our-scoped variables preserved. * A bug which prevented Niecza from working on Microsoft.NET has been found and fixed (Matthew Wilson) * A spectest harness has been added, and Niecza can run more than 200 spectests (Moritz Lenz) * New compiler features: - Metaoperators in all cases - .foo; implicit $_ syntax - if COND -> $r { ... } (PaweÅ Murias) - Method calls can have string names ."$foo" - $/ and $! are supported in parameter lists - $?FOO works again * New setting and runtime facilities: - map, grep, and [] are mostly eager and C# coded - Ranges, including .. and ^ operators - Numeric bit operators (+^, +&, +|, +<, +>) - Boolean bit operators - chr & ord - Portable path manipulation - grep and map now return lvalues - done_testing is now done and .dump is now .perl - JSYNC.pm6 now provides JSON functionality - Action methods and &make are supported - Test.pm6 improvements (PaweÅ Murias) - Initial attribute values can be passed to Any.new
5年前の記事ですがなぜか浮上。
Radio Free Meredith - Programming languages and their relationship styles Programming languages and their relationship styles * Feb. 28th, 2006 at 3:47 PM C: You are a paranoid schizophrenic who spends most of your time confused about which type you should be, convinced that blatantly false things are true because your extreme efficiency leaves no room for sensible error checking. Moreover your terseness encourages people to interact with you badly, providing incomplete and ambiguous instructions for which you nevertheless come up with a legal interpretation, even though most of the time it is completely nonsensical. People come to you because you promise them simplicity, not realising that below the surface you're a rat's nest of issues. In the end you are always abandoned for someone like C++ or Python. Python: Python cares deeply about you and does its best to make your life easier. Python is willing to try new things to make you happy -- "Sure, I can do generators, if that's what you want" -- and really doesn't mind if you're seeing other languages on the side. It insists upon arranging the cupboard into strict rows, but you stop noticing after a while, and eventually you come to prefer your shelves organized this way. Your friends think this is weird until they start dating Python too. Ruby: Your older sister is the most popular cheerleader in school, but she's kind of a slut. You think that maybe if you add more features, the boys will like you just as much. PHP: You've seen what works for Ruby and you think it will work for you too, but you haven't figured out that lipstick doesn't go on your cheeks and you shouldn't brush your hair with a mascara wand. C++: C++ has seen people in love, and thinks it has everything figured out. C++ thinks it loves you, but it errs on the side of being controlling when it thinks it's being concerned and caring. Ada: You are far more flexible than C++, and know how to be strict and forgiving at the same time. However, your tendency to wear the bondage and discipline gear all the time, as opposed to when your lover asks you to bring it out, frightens people off. You need to learn to stop calling people "worm" and "slave" in front of their mothers. Java: You try to be loving, but you were raised by a commune of 60 nervous women who have told you that everything you do is loving, even when it isn't. Your unhelpful behaviors have never been corrected and everything you do is subtly wrong and destructive. JSP: You are Java's younger sister, working in a strip club to pay for your women's studies degree. Perl: You're incredibly enthusiastic and you have five different ways of doing anything that anyone could possibly want to do. As a result, you tend to overwhelm people and you leave a bad impression on people who could otherwise benefit from knowing you. You promise people answers to all their questions, but you're not ready for a real relationship. You like to guess what people want, but tend to jump to conclusions. When other people would say "what, really?", you've already gotten out a ball-peen hammer and a tub of beeswax. Because of this, people find themselves speaking to you using a range of expressions and vocabulary even more limited than what they'd use for someone who didn't speak the language at all. Smalltalk: Smalltalk won't meet you outside Smalltalk's apartment. Smalltalk says that if you really loved it, you wouldn't leave. Smalltalk は Smalltalk's apartment の外ではあなたに会うことはない。 Smalltalk はあなたが本当に Smalltalk を愛しているか、離れないでいるかを問う。 OCaml: You know yourself to be fast, smart, and extremely reliable. However, you look kind of funny and nobody really wants to talk to you. You spend most of your time itting in a public library glaring at people, occasionally yelling "NOBODY HERE APPRECIATES MY GENIUS!" and getting kicked out. Prolog: You are a deaf and blind synthaesthete, who experiences the world entirely through smells, each of which triggers expansive flurries of poetry and music in your mind. Certain problems are trivial for you, but nobody will ever understand the answers you give them, because your numbering system involves colors that cannot be perceived by humans. Prolog can sometimes have a good time with people, but it's hard for a person to stay with someone who only wants them for their ochre vibrato. Lisp: Lisp cares about you, but really loves itself more than it will ever love you. Lisp thinks that it's the world's greatest lover, and it is a lot of fun, but it's completely blind to its own inadequacies. Watch out: it flies into a rage if it finds you've been seeing C on the side. Lisp swears up and down that it can be anything and anyone you want, and in a lot of ways it's right, but in the end, it's still Lisp. Logo: Lisp's adorable 7-year-old niece who likes to play with her toy turtle. On casual conversation, she proves to be disturbingly worldly and well-informed. You resolve not to let your kids play around Lisp's house. Thinking about using Logo in any serious way makes you feel a bit dirty. Visual Basic: You're a fifteen-year-old girl with her very own computer in her room, pinging random strangers on AIM and claiming to be a 23-year-old girl who wants to cyber with them. However, your efforts fail at convincing people, mostly because you aren't very imaginative and most of the things you're promising them are ideas you ripped off from other sources and changed slightly, leaving them less believable. ASP.NET: As above, except you're a fifteen-year-old boy. Objective C: You grew up in a cold and loveless home. Everything you know about love, you learned by listening to Smalltalk and Lisp's sex parties in the apartment next door. Now you have met a sweet young thing named Darwin, and you are eager to please. あなたは冷たく愛のない家庭に育った。 あなたが愛について知っているすべては、あなたが Smalltalk と Lisp との sex parties で聞いて学んだことだ。 Dylan: Sombody sat Lisp down and told it it was too clingy. Now it's bipolar. Twisted: Twisted Python not only loves you, it loves everyone, in 10ms intervals, on demand. But once you learn to take turns, you don't notice the difference. E: E is very clear about its hard limits, and there are a lot of them. It tells you up front what you're not allowed to do, and sometimes you end up forgetting what you can do without pissing it off. lex/yacc: lex and yacc are those twins you have a one-night stand with every couple of years. In the intervening period, you forget all about the neat tricks they can do, and every time you meet up you end up learning them all over again. But they're really rather one-sided, and schizophrenic in the same way C is, so in the end it's good that they're not after you for a long-term relationship. Haskell: Haskell is pretty, but always uses an elaborate range of prophylactic techniques. By the time you're all in place, the person you're with no longer resembles Haskell. If you've had other lovers, Haskell doesn't like many of the things that you may have come to enjoy doing with them. Haskell will pretend never to have heard of these things, and call you a pervert. SML/NJ: You cannot take anything away from a relationship with SML/NJ that you did not bring with you. If you leave anything at SML/NJ's apartment when you break up, SML/NJ will leave it on your doorstep without ringing the bell. Assembler: Assembler has no limits -- none whatsoever -- but you have to make it do what you want. It will not make a move to help you; assembler just lies there. FORTRAN: FORTRAN isn't a real relationship. Telling people you're happy with FORTRAN is like telling people you'll be happy taking care of your cats for the rest of your life and don't really need another person.以下コメントから。 * 123 comments RATFOR: Like Fortran, except you write (and post) fanfics where one of your cats turns into a dashingly uninhibited catboy/catgirl and sweeps you off your feet. Clu: Learned everything it knows about relationships from a manual published in 1972 by a hippie commune, and refuses to learn any more. Friendly, but inflexible. COBOL: COBOL is a sad office accountant that nobody loves. Nobody ever sees COBOL outside of the office. From time to time, somebody wonders whether they could break COBOL out of its shell. When they try to flirt with COBOL, COBOL just stares blankly ahead, as if waiting for the punchline. Scheme: Your parents asked their friend Lisp to dress up as a schoolteacher and introduce you gently to the arts of love. At first, everything is smooth, if a bit idiosyncratic. Before long, though, scheme has asks whether you want to try something really fun, and then out come call/cc and the hygenic macros. Matlab: Matlab stands on a street corner, and does one thing. Matlab does this one thing very well, and very quickly. Some people try to have relationships with Matlab. They think that Matlab has a beautiful soul, and they like that thing that Matlab does. This always ends badly: Matlab has no love for anybody. Matlab is dead inside.
ぐはっ。訳すに訳せない ○| ̄|_
発売日 2011年04月08日
辞書リテラルの評価順の話
こういうことのようです →
dict evaluation order - odz buffer
そうか。バイトコード見てけば良かったんだよな ○| ̄|_
【Perl,PHP】LLバトルロワイヤル15【Ruby,Python】 64 デフォルトの名無しさん [sage] 2011/02/15(火) 19:08:03 ID: Be: Unix環境使うと、Perlはどこにでも顔を出すけどな。 プログラミング言語というより、sed/grep,awkと同列のツールになっちゃってる。 87 デフォルトの名無しさん [sage] 2011/02/16(水) 00:09:36 ID: Be: >>84 awkは今見ても「すげー」って感想しか出てこない 適切に設計されたDSLがどれだけ豊かな世界を作れるのかを 肯定的に実証している 88 デフォルトの名無しさん [sage] 2011/02/16(水) 00:31:32 ID: Be: 生みの親が化け物ぞろいだしな Andy Thomas Why the lucky stiff Ken Thompson 89 デフォルトの名無しさん [sage] 2011/02/16(水) 00:43:11 ID: Be: Ahoか
88 の awk もこれはこれで。
Schneier on Security: The Seven Types of Hackers The Seven Types of Hackers Roger Grimes has an article describing "the seven types of malicious hackers." I generally like taxonomies, and this one is pretty good. He says the seven types are: 1. Cyber criminals 2. Spammers and adware spreaders 3. Advanced persistent threat (APT) agents 4. Corporate spies 5. Hactivists 6. Cyber warriors 7. Rogue hackers Posted on February 15, 2011 at 1:11 PM • 46 Comments (略)
Latest topics > Excelの「AA」とかのカラム名とカラム番号の数値を相互変換する - outsider reflex Excelの「AA」とかのカラム名とカラム番号の数値を相互変換する - Feb 15, 2011 (略) var input = prompt('input number or column name'); if (!input) return; var symbols = 'abcdefghijklmnopqrstuvwxyz'; var result; if (/^[0-9]+$/.test(input)) { input = parseInt(input); result = []; while (input > 0) { result.unshift(symbols.charAt((input - 1) % symbols.length)); input = Math.floor((input - 1) / symbols.length); } result = result.join('').toUpperCase(); } else { result = 0; input = input.toLowerCase().split('').reverse(); for (var i = 0, maxi = input.length; i < maxi; i++) { result += (symbols.indexOf(input[i]) + 1) * Math.pow(symbols.length, i); } } alert(result); (略) © 1999-2011 Piro:outsider reflex, some rights reserved.
これで、
var symbols = 'abcdefghijklmnopqrstuvwxyz';
と
result += (symbols.indexOf(input[i]) + 1) * Math.pow(symbols.length, i);
の部分を
' abcdefghijklmnopqrstuvwxyz'
indexOf(input[i]))
のようにする手法はありでしょうか? 少なくとも先頭に置く埋め草用の文字はもうちょっと考えたほうがいいか。
Rubyでハッシュの中の値からキーを取りだしたい | OKWave ハッシュの中の値からキーを取りだしたいのですが、うまくいきません。 下記のようなソースしか思い浮かばないのですが、 何か良い手はないでしょうか。 ------- if number == ban.values d = ban.keys endANo.1 nora1962 質問の内容がいまいち分かりかねます。 ハッシュのVALUE部分からKEYの値を逆算したいということでしょうか? もう少し、やりたい事を具体的に提示願えませんか。その通りです。普通は逆ですよねーー。 ちょっと無理なソースコードなので、なんとかならないでしょうか。ANo.2 いったん配列に変換してSELECTメソッドを使って絞り込んで、再度ハッシュに変換するとかでしょうか。 Hash[ ban.to_a.select{ |x| x[1]>1} ] とかANo.3 key の値だけほしいなら d = Hash[ ban.to_a.select{ |x| x[1]==number ].keys でヒットするキーの配列が取得できます。あっ、間違えました。そうです。ハッシュから取りたいんです。 ですが、Internal Server Errorになってしまいます。ANo.4 お使いになっているRubyのバージョンは何でしょうか。 オーム社のプログラミングRuby 1.9 ライブラリ編にも例が載っています。 h = { "a" => 100, "b" => 200, "c" => 300 } s = h.select { | k, v | v == 200 } # {"b"=>200} p s.values[0] # 200 になるはずなんですが。 http://ref.xaio.jp/ruby/classes/hash/selectANo.5 マニュアルを読むんですね。 http://doc.okkez.net/static/192/class/Hash.html ハッシュのメソッドを上から順に読んでいくと > key(val) -> object > index(val) -> object > 値 val に対応するキーを返します。対応する要素が存在しない時には nil を返します。 とあるじゃないですか。
Hash#key (Hash#index) とかすっかり忘れてた。 invert して…とか考えてしまった。
2011-02-16 GNU Guile 2.0.0 released. This is the first of the 2.0.x stable series and the result of 3 years of work.
あれ? もうひとつ二つ。英文blogから拾ったネタがあったはずなんだけど…
おめでとうございます。 Twitter / @Kazuhiro Inaba: そういえばご報告ですが、というか、どのタイミングで書 ...
心が動くなあ
これは“モバギ”の再来か:ATOKも“Ctrl+c”も使えるキーボード付きAndroidポケットノート──「LifeTouch NOTE」の実力検証 (1/4) - ITmedia +D PC USER
2011 International CES:勝手に命名した「モバギロイド」に突撃レビュー! (1/2) - ITmedia +D PC USER
blog | Perlgeek.de :: Perl 6 notes from February 2011 Mon, 14 Feb 2011 Perl 6 notes from February 2011 Permanent link Lately real life has prevented me from blogging, so here are just a few random notes from the Perl 6 developers: The Perl bug tracker now has tags testneeded and testcommitted, which can mark tests that need or have tests in the spectest suite. Since the URLs for querying these tags are unwieldy and non-obvious, I've created some aliases: http://rakudo.de/testneeded and http://rakudo.de/testcommitted. Development of the new nqp and rakudo-on-the-new-object-model is progressing nicely. I had some fun porting some PIR code to NQP, and writing some new code. Most interesting to read is the source of the new meta model, much of which is written in a subset of Perl 6 (so quite readable, if you happen to know Perl 6. For example you can see how the method resolution order for multiple inheritance is calculated. There is a parrot branch that adds a generation garbage collector to parrot. Its release is planned for shortly after the 3.1.0 release due tomorrow. Initial benchmarks show that Rakudo is between 25% and 30% faster on that parrot, as measured by a spectest run. I very much look forward to having that in the parrot main line. Writing code for niecza is quite a nice experience. It still has a big startup cost, but then runs much faster than rakudo (at least it feels that way). There are still lots of features missing (for example non-integer number literals), but feature requests are usually implement quite quickly.
Rakudo is between 25% and 30% faster on that parro
もともとの遅さが遅さだからそこから30%速くなったといってもねえ。
reddit でも盛り上がってた。
What if Lisp was invented by the Japanese? : lisp What if Lisp was invented by the Japanese? (lispnyc.org)Mu. This whole discussion is silly, IMHO. Forth was designed from the start as being a stack based language and its notation makes sense given that origin: values are put onto the stack followed by the operation. This is no different from using your HP-11C or other favourite RPN calculator. Lisp's entire paradigm is different: it's fundamental data structure is the list, the only approach to function application that makes sense is through prefix notation. This whole discussion of "programming language syntax is driven by human language word order" is stupid: what the fuck language were Haskell's developers speaking?Haskell? What about Perl and Perl 6, then? The authors vomited ASCII art or something?(+ 3 4 (+ 1 (length (append '(3 4) '(5 6))))) [[[[3,4],[5,6]] append length, 1] +, 3, 4] + [Lisp]s fundamental data structure is the list. Can we stop saying this? Lists are no more fundamental as a data structure in Lisp than they are in any functional-style language. S-expressions and macros are what makes Lisp what it is.what the fuck language were Haskell's developers speaking? Mathematics bar parenthesis? :-)Lisp wasn't invented, it was discovered! :P"If Lisp were invented by the Japanese" except that they invented Forth instead.... What? If Japanese invented Lisp then it would look like Lisp, or else it would not be Lisp. It's like saying if English speaker invented Forth (which is also true in reality) then Forth would be prefixed like Lisp. No, it would not.It would be called Ruby?Learn Lisp quickly I will.
What if Lisp was invented by the Japanese? : programming What if Lisp was invented by the Japanese? (lispnyc.org)Why would a Japanese version of Lisp have the verb at the end just because Japanese does? Lisp has the verb at the beginning, but English does not. Seems like a pretty pointless article to me.It's a more significant error because it confuse lisp operators with verbs, which they aren't. Consider (with-open-file ...) -- is that a verb? No. Lisp operators are really contexts for the content that follows. As such it would map more naturally to the topic establishing particle は. e.g. + は 1 2 -- as for +, [apply] 1 and 2. Which would map back nicely to (+ 1 2).Macros are contexts. Functions are verbs. Macros are actually just verbs that act on syntax-trees rather than runtime data. Same thing, actually. Welcome to Lisp.Here's some Ruby code to generate and shuffle a deck of cards. ( (2..10).to_a + %w{Jack Queen King Ace} ). \ product( %w{Hearts Spades Clubs Diamond} ). \ map { |c| c.join " of " }.sort_by { rand } Just like Japanese verbs, each of those methods operates on what came before it. I also deliberately wrote that to be quite Lispy just to make my point. If you want a Japanese version of Lisp, I think Yukihiro Matsumoto has already written it.Agree about pointlessness. Besides, the coolest thing about a Japanese Lisp would be that it'll be writted vertically in columns, top-to-bottom, right-to-left.You do know that Japanese people also write horizontally, left-to-right, top-to-bottom? (Which can get confusing when you compare that with writing in vertical columns one character high.)Yup (I'm Japanese). I might be completely talking out of my ass here but I believe the left-to-right writing standard came about directly as a result of Western influences, and particularly in the 20th century with typewriters and subsequently word processors -- it's not exactly trivial to repurpose software that assumes English writing formats to right-to-left, let alone top-to-bottom. I do recall my grandparents had some sort of ancient electronic word processor (wah-puro) that printed vertical text. And they still used abacuses (abaci?) in the office (actually they may still do!)
数日前の最高速 grep の話題のときに知った文字列マッチング手法の Commentz-Walter 法なんですが、意外なところで使われていた (見落としていた)模様。
/* kwset.c - search for any of a set of keywords. Copyright (C) 1989, 1998, 2000, 2005, 2007, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* Written August 1989 by Mike Haertel. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ /* The algorithm implemented by these routines bears a startling resemblence to one discovered by Beate Commentz-Walter, although it is not identical. See "A String Matching Algorithm Fast on the Average," Technical Report, IBM-Germany, Scientific Center Heidelberg, Tiergartenstrasse 15, D-6900 Heidelberg, Germany. See also Aho, A.V., and M. Corasick, "Efficient String Matching: An Aid to Bibliographic Search," CACM June 1975, Vol. 18, No. 6, which describes the failure function used below. */
Aho-Corasick かと思ってた。
Renjin is a new JVM-based interpreter for the R language.
雪。ですな。
ちょっと Python のソースを眺めた。
Python/ast.c static expr_ty ast_for_atom(struct compiling *c, const node *n) { /* atom: '(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictmaker|testlist_comp] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False' */ node *ch = CHILD(n, 0); int bytesmode = 0; switch (TYPE(ch)) { case NAME: { (略) } case STRING: { (略) } case NUMBER: { (略) } case ELLIPSIS: /* Ellipsis */ return Ellipsis(LINENO(n), n->n_col_offset, c->c_arena); case LPAR: /* some parenthesized expressions */ ch = CHILD(n, 1); if (TYPE(ch) == RPAR) return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); if (TYPE(ch) == yield_expr) return ast_for_expr(c, ch); /* testlist_comp: test ( comp_for | (',' test)* [','] ) */ if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == comp_for)) return ast_for_genexp(c, ch); return ast_for_testlist(c, ch); case LSQB: /* list (or list comprehension) */ ch = CHILD(n, 1); if (TYPE(ch) == RSQB) return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); REQ(ch, testlist_comp); if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { asdl_seq *elts = seq_for_testlist(c, ch); if (!elts) return NULL; return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); } else return ast_for_listcomp(c, ch); case LBRACE: { /* dictorsetmaker: test ':' test (',' test ':' test)* [','] | * test (gen_for | (',' test)* [',']) */ int i, size; asdl_seq *keys, *values; ch = CHILD(n, 1); if (TYPE(ch) == RBRACE) { /* it's an empty dict */ return Dict(NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { /* it's a simple set */ asdl_seq *elts; size = (NCH(ch) + 1) / 2; /* +1 in case no trailing comma */ elts = asdl_seq_new(size, c->c_arena); if (!elts) return NULL; for (i = 0; i < NCH(ch); i += 2) { expr_ty expression; expression = ast_for_expr(c, CHILD(ch, i)); if (!expression) return NULL; asdl_seq_SET(elts, i / 2, expression); } return Set(elts, LINENO(n), n->n_col_offset, c->c_arena); } else if (TYPE(CHILD(ch, 1)) == comp_for) { /* it's a set comprehension */ return ast_for_setcomp(c, ch); } else if (NCH(ch) > 3 && TYPE(CHILD(ch, 3)) == comp_for) { return ast_for_dictcomp(c, ch); } else { /* it's a dict */ size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */ keys = asdl_seq_new(size, c->c_arena); if (!keys) return NULL; values = asdl_seq_new(size, c->c_arena); if (!values) return NULL; for (i = 0; i < NCH(ch); i += 4) { expr_ty expression; expression = ast_for_expr(c, CHILD(ch, i)); if (!expression) return NULL; asdl_seq_SET(keys, i / 4, expression); expression = ast_for_expr(c, CHILD(ch, i + 2)); if (!expression) return NULL; asdl_seq_SET(values, i / 4, expression); } return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); } } default: PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); return NULL; } }
問題は AST を構築するところかなあ。 ここでは key → value → key → value とやっているようだし。
確かに 834 の指摘通りのような気はするのだけど
正規表現 Part7 833 デフォルトの名無しさん [] 2011/02/13(日) 04:23:23 ID: Be: ●正規表現の使用環境 C ●説明 Apacheのログから一部分を抜き出して検索したい ●対象データ host.ne.jp - - [11/May/2011:12:22:15 +0900] "GET /~akasata/index.xml?gat=tPFnlVCP8aUYq8jjPqA=&BSdebug=AV/w3.3r1.1/ HTTP/1.1" 200 6703 "https://server.ne.jp/" "Mozilla/5.0 (X11; U; Linux i686; ja; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14" (以上1行) ●希望する結果 1件目 host.ne.jp 2件目 /~akasata/index.xml 以上のような検索を実装しようとして、 regerror(regcomp(&preg, "(.+) - [^[] \\[.+\\] \"[^\" ]+ ((/~akasata/[^\"]+)\\?g.+)*([^\"]+) [^\" ]+\".+", REG_EXTENDED|REG_NEWLINE), &preg, errbuf, sizeof(errbuf)); 以下のような正規表現を用いた(Cのエスケープが混じっているため見辛ければすいません)のですが、 後ほど検索対象を調べて一部不要な部分があったため regerror(regcomp(&preg, "(.+) - [^[] \\[.+\\] \"[^\" ]+ ((/~akasata/[^\"]+)\\?g.+) [^\" ]+\".+", REG_EXTENDED|REG_NEWLINE), &preg, errbuf, sizeof(errbuf)); 以下のように正規表現を変更したところ、同じ結果を返すのにもかかわらず 実行速度が4倍以上もかかるようになってしまいました。原因かわかる方教えていただけないでしょうか? 834 デフォルトの名無しさん [sage] 2011/02/13(日) 18:53:26 ID: Be: Cの標準ライブラリには正規表現を扱えるもんがなかったと思うし regcompとかの関数名から察するにregex.h使っていると勝手に推測する んで、これはPOSIX準拠ってことでPOSIX NFAエンジンで動作していると思うけど こいつは途中のオプションによってマッチしたとしても、引き続いて出来る限り 最長のマッチしたものを報告するように処理しまくる 前者と後者のパターンだと全走査する回数が違ってくるから それで時間も変わっいるのでは? 835 デフォルトの名無しさん [sage] 2011/02/13(日) 18:56:50 ID: Be: ああPOSIX準拠ってことで必ずしもPOSIX NFAエンジンって訳でもないんで regex.hの内部動作が何なのかは推測の域はでないってことでご勘弁を
問題の正規表現の部分を切り出して余計なエスケープを取り除いてみると
(.+) - [^[] \[.+\] \"[^\" ]+ ((/~akasata/[^\"]+)\?g.+)*([^\"]+) [^\" ]+\".+ (.+) - [^[] \[.+\] \"[^\" ]+ ((/~akasata/[^\"]+)\?g.+) [^\" ]+\".+
んー。 とりあえずいくつかある .+ はもう少し条件を厳しくすべきじゃないかなあ。 特に先頭の (.+) とか。
解像度は640×480ドットで、7~65インチのスクリーンサイズに対応する。アスペクト比は4:3で、明るさは最大15ルーメン(明るさ調整可能)。投射距離は、0.22~2mとなっている。
ああ、英文記事を開いたタブが増えてゆく…○| ̄|_
三連休何をやっていたのだろう…(笑)
最初は質問の意図が良く掴めなかったけど、興味深い質問だなあ。
Pythonのお勉強 Part41 904 デフォルトの名無しさん [sage] 2011/02/13(日) 04:32:09 ID: Be: 辞書表現の評価順序について、 http://docs.python.org/release/2.7/reference/expressions.html#evalorder のリファレンスでは、 {expr1: expr2, expr3: expr4} となっているのですが、 def f(i): print i return i {f(1):f(2), f(3):f(4)} を実行すると、 2 1 4 3 となります これは、リファレンスの間違いでしょうか、それとも実装のバグでしょうか? 905 デフォルトの名無しさん [sage] 2011/02/13(日) 04:42:18 ID: Be: >>904 いや、それがdict (辞書型)の仕様だから。 何でもかんでもバグにすんな。初心者にありがち。 906 デフォルトの名無しさん [sage] 2011/02/13(日) 04:43:23 ID: Be: >>905 すみませんが、仕様はどちらにありますか 907 デフォルトの名無しさん [sage] 2011/02/13(日) 04:55:09 ID: Be: >>906 これだな。 http://docs.python.org/library/stdtypes.html CPython implementation detail: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary’s history of insertions and deletions. 辞書型のkeyの順序が保証されないなんてことは いちいち当たり前すぎて、それが仕様に書いてあるかなんて考えもしなかったわ。 Pythonは丁寧に作られてるからたまたま書いてあったけど、 言語処理系なんて「実装が仕様」なんてことはままあるからね。 908 デフォルトの名無しさん [sage] 2011/02/13(日) 05:10:28 ID: Be: >>907の親切さに感動した! 909 デフォルトの名無しさん [sage] 2011/02/13(日) 05:22:29 ID: Be: 俺は仕様じゃなくて実装依存だと思っていたが仕様だったのけ? 910 デフォルトの名無しさん [sage] 2011/02/13(日) 05:30:28 ID: Be: >>907 調べていただいてありがとうございます ですが、それはitemsメソッドの仕様であって、 {}表現の評価順序の仕様とは異なります 911 デフォルトの名無しさん [sage] 2011/02/13(日) 05:31:05 ID: Be: というか>>904は辞書のキーと値に副作用を伴う式を指定した場合に どういう順番で評価されるかって話であって >>907はitems()がどういうリストを返すかという話とは関係ないと思う リファレンスの記述ミスっぽい気もするがどうなんだろう 912 911 [sage] 2011/02/13(日) 05:32:01 ID: Be: ああそうね重複したうえに副作用云々はいらなかったね くすん 913 デフォルトの名無しさん [sage] 2011/02/13(日) 05:38:25 ID: Be: >>910 「{}表現」というのはdict型の組み込みコンストラクタなわけ。 で、それの仕様は別のところに書いてあるよ。 書いた順に登録されていって、keyが重複していても問題ない、だったかな。 で、そうやって初期化した後で、取り出さないといけないでしょ。 取り出す段階で、keyの順序は保証されないと907で言ってるわけ。 914 デフォルトの名無しさん [sage] 2011/02/13(日) 05:55:40 ID: Be: >書いた順に登録されていって、keyが重複していても問題ない keyの登録順や、取り出す段階についてではなく、 {key:value, ...}と書いたときに、keyとvalueのどちらが先に評価(計算)されるかが、 >>904のリファレンスに書いてあることです それが、実際に動かした結果と異なっているようだったので質問させていただきました 915 デフォルトの名無しさん [sage] 2011/02/13(日) 06:02:20 ID: Be: http://docs.python.org/reference/expressions.html#dictionary-displays > If a comma-separated sequence of key/datum pairs is given, > they are evaluated from left to right to define the entries of the dictionary: > each key object is used as a key into the dictionary to store the corresponding > datum. This means that you can specify the same key multiple times in the > key/datum list, and the final dictionary’s value for that key will be the last one given. キーとデータのペア単位で左から右に評価されるということかなあ なので、あるペアを注目した際にキーよりデータが先に評価されることもありうると 916 デフォルトの名無しさん [sage] 2011/02/13(日) 06:32:38 ID: Be: >>915 >なので、あるペアを注目した際にキーよりデータが先に評価されることもありうると その評価の順序について説明してあるのが、その文章の 5.14節 http://docs.python.org/reference/expressions.html#evaluation-order (>>904のリンクで示した箇所)なのですが… 919 デフォルトの名無しさん [sage] 2011/02/13(日) 06:54:11 ID: Be: >>916 ああ、すまん。全然読み誤っていた。 できあがったdictの内部の話をしてるんじゃなくて、 {}表現によるdictコンストラクタの評価順序の話をしてたのね。 仕様ドキュメント読んでソースコード読め、で終わりそうだな。 Pythonプログラマとしてヒトコト言わせてもらえば、 そんな重箱の隅をつつくような細かい仕様に依存したコードは書くべきではないし、 ひいては考慮してはダメ。 なぜならそんな細かい仕様をプログラマ誰でも理解してるわけではないし、 プログラムはなるべく平易に書くというPythonのポリシーにも反する。 923 デフォルトの名無しさん [sage] 2011/02/13(日) 07:02:48 ID: Be: >>919 コーディングについてはもっともですが、言語の規約としてどうなのか知りたいと思っています ソースコードは動かした通りになっているはずですが、 提示したリファレンス以外に、正しい仕様書があるのなら教えていただきたいのです 924 デフォルトの名無しさん [sage] 2011/02/13(日) 07:04:55 ID: Be: >>923 だから、仕様ドキュメント読んでソースコード読め。 なんかSIに作らせたみたいな仕様でっかちな システムか何かと勘違いしてないかい? 仕様ありきで言語を作ってるんじゃなくて、 ニーズがあってプログラム書いて、そのあとで仕様としてまとめてるんだよ。 もちろん、PEPの形で使用が提案されることも多々あるわけだけど。 926 デフォルトの名無しさん [sage] 2011/02/13(日) 07:20:59 ID: Be: [Python-Dev] Dictionary evaluation order http://mail.python.org/pipermail/python-dev/2002-November/030461.html 927 デフォルトの名無しさん [sage] 2011/02/13(日) 07:22:43 ID: Be: http://mail.python.org/pipermail/python-dev/2002-November/030458.html http://bugs.python.org/issue448679 http://svn.python.org/view?view=rev&revision=30148 実装のミスっぽ 928 デフォルトの名無しさん [sage] 2011/02/13(日) 07:23:56 ID: Be: >>926 CPython処理系のバグだけれども、もう直せないということですね ありがとうございます 930 デフォルトの名無しさん [sage] 2011/02/13(日) 07:36:00 ID: Be: >>927 なるほど。開発陣もバグと認めてるわけね。 しかし、どのログを見ても修正した形で完結してるようなのに、 未だに直ってないというのはどういう事だろう? 932 デフォルトの名無しさん [sage] 2011/02/13(日) 07:47:15 ID: Be: >>930 一度は直したけど再発したとかかなあ。正直よくわかんない あとJythonの名前が出てきたので試してみた Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54) [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_20 Type "help", "copyright", "credits" or "license" for more information. >>> def foo(n): print n, ... >>> {foo(0): foo(1), foo(2): foo(3), foo(4): foo(5)} 0 1 2 3 4 5 {None: None}
BASIC「を」作ったのはアセンブリ言語だろうけどなあ。
ビル・ゲイツについて - Yahoo!知恵袋 ビル・ゲイツについて ビル・ゲイツが愛用していた言語を教えてください ほとんど使っていた言語です (プログラミング言語)です
しかしなぜそんなことを知りたがるのだろう? (いけないというのではなく)
意外にあなどれないのが聖書。
Larry Wall Interview, by Erik Davis Divine Invention: An interview with Larry Wall by Erik Davis Originally appeared in Feed, Febuary 10, 1999
前世紀の話なのに。
群 (数学) - Wikipedia 空でない集合 G とその上の二項演算 μ: G × G → G の組 (G, μ) が群であるとは、 1. (結合法則)任意の G の元 g, h, k に対して、μ(g, μ(h, k)) = μ(μ(g, h), k) を満たす。 2. (単位元の存在)μ(g, e) = μ(e, g) = g を G のどんな元 g に対しても満たすような元 e が G のなかに存在する(存在すれば一意である)。これを G の単位元という。 3. (逆元の存在)G のどんな元 g に対しても、μ(g, x) = μ(x, g) = e となるような G の 元 x が存在する(存在すれば一意である)。これを g の G における逆元といい、しばしば g?1 で表される。 群よりも広い概念として、1 を満たすものは半群、1 と 2 を満たすものはモノイドという。
元 (数学) - Wikipedia 元(げん)とは、要素(ようそ)とも呼ばれ、複数の「もの」で構成されている集合の中におい て、集合を構成している個々のものを指す。 例えば、x が集合 X を構成する元(要素)である場合には、X∋x(もしくは x∈X)と表記して、 「x は X に含まれる」、「x は X に属する」、「X は x を含む」などの表現で表される。反 対に x が集合 X を構成しない場合には、∋∈ の中央部に縦線もしくは上部に横線を引くこと で否定の記号となる。
英語では element っていうみたいですし、なんでわざわざ「元」とかいう訳語があるんでしょうか? element → 「元」素ってのはありますが。
・本
なんか買うものがあったような気がしたんですが、書店に行ってもぴんとくるものが。
オライリーの新刊はもうちょっと先だし。
で、今日買ったのはこれ。
すでに
が出ていて、そのお仲間というところでしょうか。
これ、このあとも出たりするんでしょうかね。C++ とか。
ざっと目を通して悪くなさそうなので買ってみたのですが、
BigDecimalを使えば「誤差がなくなる」といった感じの説明はどうかと。
紙面の都合などもあるのでしょうけど、「誤差」といってもいろいろな種類が
あるわけで、この本で例示されたような 0.1 を 10回足したのが1にならない的な
「誤差」はそりゃあ一番目にする機会が多いような感じがしますが、
誤差ってそれだけじゃないですよねえ。
・true/false
昨日、C だとたとえば 0 == 0 の式としての値が 1 になる。
BASIC (や、Pascalなど) では -1 だという話がありましたが
Twitter / @きしもと: trueが-1だと(2の補数を仮定)bitwise ... trueが-1だと(2の補数を仮定)bitwise notが論理否定を兼ねる
確かにその通りで、初めてCをやったときに驚いたことのひとつだった記憶が。 あれ、Pascal とどっち先にやったんだっけか。 その前に教えられた FORTRAN 77 にも論理型ってのがありましたが、 それが実際にどういう値なのかは考えたことがありませんでした :)
ふと、なんで C は 1 と 0 になったんだろうかと思ったり (まあ 0 以外は真ですが、比較式の結果がそうなるという辺りで)。
PCの基本操作を教えてください。 | OKWave バイト先でPC操作の担当を任されました。 とは言ってもスキルも人並み以下ですし、早くボードを使える訳でもありません。 しかし、新規店でのお仕事でオーナーや私も含むスタッフさんたちもかなり意気込んでおります。 なので任された以上出来るだけ頑張りたいのです。 そこで、お尋ねしたいことは ・ボードの正しい指の置き方 ・PCに覚えさせたい単語はどうすれば良いのか ・自分のPCから他のPCに文章を渡したい場合はUSBをどのように使えばよいのか ・PCで作成したチラシやハガキを印刷したい場合のやり方 箇条書きになってしまいましたが今はこれをマスターしたいです。 その他にも経営で覚えておくと便利な機能も教えていただけたら嬉しい限りです。 色々知らないことがあって面倒ではありますがお力添えをお願いします!
ボード→キーボード。だよねえ? ハードディスク→ハードと同じようなものか。
スレッドを立てるまでもない質問雑談スレ42 260 仕様書無しさん [sage] 2011/02/12(土) 15:11:31 ID: Be: ブラウザからサーバ上に配置した php.ini に http://testtest.com/php.ini と指定するとダウンロードが始まってしまい 中身が見えてしまうのですがどうすれば防げますか? アクセス権限を 000 にしてもURLを入力すると ブラウザからダウンロードが出来てしまいます。 261 仕様書無しさん [sage] 2011/02/12(土) 15:18:26 ID: Be: エスパーしてみよう 1. webserverをroot権限で動かさない 2. 公開場所(/usr/local/apache2/htdocs配下?それしか知らん)に置かない 3. .htaccess等でphp.iniというファイル名を弾く 262 仕様書無しさん [sage] 2011/02/12(土) 15:52:39 ID: Be: >>261 まさにあなたはエスパーです!! ありがとうございます。 「3.」を使用してアクセス制限する事で対応出来ました。 砂州合す 263 仕様書無しさん [sage] 2011/02/12(土) 16:35:28 ID: Be: 3. はどっちかというと、 「もう運営してて仕様書にもphp.iniのパスもサーバの実行ユーザもばっちり書いてあって動かせない!やべええええ」 ってなったときの対策だぞw 1.か2.にしとけw
Shtetl-Optimized » Blog Archive » Timeline of computer science Timeline of computer science This year, MIT is celebrating its 150th anniversary—and as part of the birthday festivities, I somehow got roped into creating a timeline of “150 major events in computer science history” (i.e., in the world, not MIT). I understand that the timeline will go up on a wall somewhere. My first thought was that singling out the “most important events in CS history” was an exercise in futility, and not a particularly original one either. But then, as I spent weekends reading about Konrad Zuse, the UNIVAC, and the IBM 360, I started really getting into my assigned exercise in futility. (略) 300BC Euclid's Elements describes nontrivial algorithms (for problems such as Greatest Common Divisor) that are still used today (略) 1837 Charles Babbage first describes plans for the Analytical Engine 1842 In her notes on the Analytical Engine, Ada Lovelace writes what's generally considered the first computer program, to calculate Bernoulli numbers 1847 George Boole proposes Boolean Logic (略) 1936 Alan Turing publishes “On computable numbers,” often considered the founding document of computer science. Alonzo Church and Emil Post arrive at similar ideas independently 1936 Working alone in Germany, Konrad Zuse builds the Z1, the first working stored-program computer 1937 In his MIT master's thesis—considered possibly the most influential master's thesis in history—Claude Shannon proposes the application of Boolean algebra to electrical circuit design 1940 Alan Turing builds an improved “Bombe” at Bletchley Park, to break the German Enigma code and help the Allies win WWII 1942 Isaac Asimov introduces his Three Laws of Robotics 1943 Colossus, the world's first programmable electronic computer, begins operation at Bletchley Park 1943 During the Manhattan Project, Richard Feynman and others pioneer large-scale scientific computing, using humans and later mechanical calculators 1943 In their paper “A Logical Calculus Immanent in Nervous Activity,” Warren McCulloch and Walter Pitts propose neural networks and finite automata 1944 The Mark I, designed by Howard Aiken, begins operations at Harvard 1945 In a 100-page “draft report on the EDVAC”, John von Neumann describes the architecture of a stored-program computer (henceforth called “von Neumann architecture”) 1945 Vannevar Bush publishes “As We May Think” in the Atlantic Monthly, a now-famous article that foresees a global information network based on hypertext 1946 At the University of Pennsylvania, J. Presper Eckert and John Mauchly complete the ENIAC 1946 In Los Alamos, Stanislaw Ulam develops the Monte Carlo method to speed up calculations of neutron diffusion in nuclear weapons 1947 At Bell Labs, John Bardeen, Walter Brattain, and William Shockley invent the transistor 1947 Operators of the Mark II computer trace an error to a moth trapped in a relay. The incident, popularized by Grace Murray Hopper, stimulates wider adoption of the terms “bug” and “debugging” 1947 George Dantzig proposes the simplex algorithm for linear programming 1948 In his landmark paper “A Mathematical Theory of Communication,” Claude Shannon first uses the word “bit,” attributing it to John Tukey 1948 Norbert Wiener publishes “Cybernetics: Or Control and Communication in the Animal and the Machine” 1949 The EDSAC, built by Maurice Wilkes, begins operations at Cambridge University 1950 Alan Turing proposes the Turing Test for artificial intelligence; four years later, Turing will commit suicide after being prosecuted for homosexuality 1950 Richard Hamming publishes the Hamming code, one of the first usable error-correcting codes 1950 CSIRAC, in Australia, becomes the first computer to play music 1951 J. Presper Eckert and John Mauchly release UNIVAC I, the first commercial electronic computer 1951 Grace Murray Hopper creates A-O, considered the first compiler 1951 MIT's Whirlwind I computer goes online. Designed by Jay Forrester, Whirlwind features magnetic core memory and vacuum tubes that last 1000 times longer than those previously available 1952 Based on analysis of early returns, a UNIVAC computer borrowed by CBS News predicts that Dwight Eisenhower will defeat Adlai Stevenson in the presidential election 1954 Researchers at Birkbeck College perform the first demonstration of machine translation, with a rudimentary translation of English into French 1955 MIT's Whirlwind I becomes the first computer to display graphics on a video console 1956 Dartmouth hosts the first conference on artificial intelligence, bringing the term AI into use 1956 In a letter to John von Neumann, Kurt Gödel first poses what will later become known as the P versus NP problem 1956 Edsger Dijkstra conceives his shortest-path algorithm, the basis for modern trip-planning software (Dijkstra also may have been the first person to list his profession as “programmer”) 1956 Noam Chomsky proposes the Chomsky Hierarchy, linking the theory of computing to formal languages 1956 MIT Lincoln Laboratories builds the TX-0, the first general-purpose computer to be built with transistors 1956 Reynold Johnson at IBM introduces the hard drive 1957 A team led by John Backus at IBM delivers a compiler for FORTRAN, the first high-level programming language 1958 John McCarthy proposes the LISP family of functional programming languages (略) 1966 The first cash-dispensing ATM is installed in Tokyo 1967 At SRI, Douglas Engelbart and Bill English apply for a patent for the first computer mouse 1968 Donald Knuth publishes Volume 1 of “The Art of Computer Programming” 以下略
いやあ1930年代から1960年代までに結構なことが起きてるのねえ。 しかし、4004 の開発が載ってないのはなぜだ :) そして、最初のATMが1966年に東京に設置されたとは。
Damian Conway に、サインしてもらったなあ> Perl Best Practices せっかくのサイン本なのにちょっとくたびれちゃったけど(^^;
Perl Training Australia - Perl Programming Best Practices 2011 (part 1) Perl Programming Best Practices 2011 (part 1) Introduction In 2005, Dr Damian Conway published the very popular "Perl Best Practices" book which details 256 "best practices" for Perl programming. While some of these "best practices" have been further improved on in the ensuing 5 years, many of them remain excellent practices for your coding. If you have not yet read this book, we strongly recommend that you do so! In this sequence of Perl tips we will cover a wide selection of current best practices, taking into account the ideas and modernisations that Perl has undergone.. Some best practices are obvious use strict; use warnings; If you're not already using strict in all of your scripts, and using warnings in almost all of your scripts, you have a lot to learn, and should probably start with Conway's book. 10 year old features Perl has had scalar filehandles and three-argument open for more than 10 years now: Perl にはスカラーファイルハンドルと三引数 open が十年以上前からあります # Opening a file for reading open(my $in_fh, "<", $input_file) or die "Failed to open: $!"; # Reading from that filehandle while(<$in_fh>) { # do something with $_ } close $in_fh; # Opening a file for writing open(my $out_fh, ">", $output_file) or die "Failed to open: $!"; # Printing to that filehandle print {$fh} "This text will go into my file."; close $out_fh; Three-argument open treats the filename literally, which protects you from a number of potential security issues that are possible with two-argument open. Scalar filehandles - because they are just scalars - can be passed to subroutines, put in arrays, and used as values in hashes. Additionally, when the scalar goes out of scope before you close the file, Perl will automatically close the file for you. None of this is easy with package filehandles. 三引数 open はファイル名を字面通りに扱い、二引数 open を使ったときに存在する 潜在的なセキュリティ issues の数々からあなたを防御します。 スカラーファイルハンドルは、それが単にスカラーであるので、サブルーチンに渡したり 配列に格納したりハッシュの値として使うことが可能です。加えて、ファイルハンドルを 保持するスカラーがファイルをクローズするより前にスコープから外れると、 Perl は自動的にそのファイルをあなたのためにクローズします。 None of this is easy with package filehandles. Coding standards Ideally every organisation you work for, or project you work on, has a pre-established, formalised set of coding standards. While these may not be as current as you'd like, consistency is a good thing. If you don't have a coding standard, then now is a good time to develop one. Conway's book is a great starting place. Upgrade your version Perl 5.6.1 is almost 10 years old now (2001-Apr-08). Perl 5.8.2 is 7 years old (2003-Nov-05). Perl 5.10.0 is 3 years old (2007-Dec-18). Perl 5.8.9 is 2 years old (2008-Dec-14). Perl 5.10.1 is 1.5 years old (2009-Aug-22) Perl 5.12.2 is 4 months old (2010-Sep-06). Upgrade! At the very, very least, use one of the Perl 5.8.x versions, but if you can, upgrade to either 5.10.1 or 5.12.2. Why? Because a whole lot of wonderful, new, awesome and *modern* features have been incorporated into Perl in the last few years. To use the features of your modern version of Perl, just specify your minimum version: use v5.10.1; # get all the things from Perl 5.10.1 Perl 5.12.x By specifying any of the Perl 5.12 versions, strict is automatically turned on by default. Thus this: Perl 5.12 で有効な機能のいずれかを指定することにより、strict が自動的に 有効となります。したがって、 use v5.12.2; is the same as saying: 上記の記述は次のものと同じ意味です use v5.12.2; use strict; This is a great improvement. これは大きな改良です。 New features 新機能 With Perl 5.10.0 we received a host of new features. Some of these are mentioned here: say (略) state (略) given-when The given-when can also be used with foreach: foreach (@input) { when (/ninja/) { $ninjas++; } when (/pirate/) { $pirates++; } when (/robot/) { $robots++; } when (@other) { $other_cool_things++; } when (%interesting) { $interesting++; } default { $boring++; } } New features: smart matching 新機能 スマートマッチング given-when uses smart matching to work. Smart match allows us to compare things to determine if they match, in the most useful way possible: given-when は動作時にスマートマッチングを使用します。 スマートマッチングはマッチするかどうかを決定するために 可能な限りもっとも有用な比較を可能にします: $foo ~~ undef; # is $foo undefined? $foo ~~ @array; # is $foo in @array? $foo ~~ %hash; # is $foo a key in %hash? $foo ~~ $coderef; # does $coderef->($foo) return true? $foo ~~ qr{$re}; # does $foo pattern match $re? $foo ~~ $bar; # does $foo equal $bar? Up next There are many other best practices still to be covered. In our next tip we'll discuss exception handling, and how you can test a wide variety of Perl versions from your home directory. まだ説明されていない best practices が多く残されています。 次回の tip では例外処理について論じ、あなたのホームディレクトリから 多くのバージョンの Perl をテストするのをどのように可能にするかについて述べます。
foreach ループ内で when がああいう風に使えるのは知らなかった。
実はオブジェクトとデータに共通する考えがあります。それは、集合理論です。
だけど、今日になって突然、「このままではいかん。このままだと一生やらない。」と思ったので、
・古文書
バッカス先生が書いたらしい THE HISTORY OF FORTRAN I, II, and III
というものを見つけたので読んだ。残念ながらIJK の謎の解明には繋がりませんでしたがw、
なかなか興味深いものでした。
詳しく紹介したいが PDF ではなあ。
http://faculty.cs.wwu.edu/meehan/Programming_Language_Projects/FORTRAN%20I/pdfsnstuff/backus-historyFortranI.pdf
引用されてる元発言はどこから来たものだろうか。
おもしろいコピペがあったら貼るスレinマ板part23 105 仕様書無しさん [sage] 2011/02/06(日) 17:51:51 ID: Be: 914 :デフォルトの名無しさん:2011/02/06(日) 17:00:59 そんな話は聞いたことないけどしたいならそうすればいいんじゃない? それより、 i * 10 + 9 + ( i == 9 ) は意図したとおりに動かないね。 920 :デフォルトの名無しさん:2011/02/06(日) 17:34:11 問題ないように思える人はもう一度Cの規格票をよく読むんだ^^ 923 :デフォルトの名無しさん:2011/02/06(日) 17:38:32 …というのも不親切なので答えをいうと i == 9の部分はtrueの時1になることを想定しているけど (90-100の階級幅だけ11あるので、ここだけ特別処理にしている) Cの規格上はtrueは0以外の整数であればなんでもいいことになっているので 実装にっては「90-100」のような表示にならない可能性があるってことなのよ^^; ここは printf( "%d-%d %d人\n", i * 10, i == 9 ? 100 : i * 10 + 9, cv[ i ] ); のようにすべきでした。 924 :デフォルトの名無しさん:2011/02/06(日) 17:41:11 って、答えを書いているうちに即レスするんじゃない貴様ら^^ ちなみに、この「trueは0以外の整数」というのは Cではけっこう重要な落とし穴なので初学者は覚えておくといいよ^^ 929 :デフォルトの名無しさん:2011/02/06(日) 17:44:46 あれ?そうだっけ?すまんすまん^^ワラ 935 :デフォルトの名無しさん:2011/02/06(日) 17:49:37 こうして人は成長していくのであった^^; 108 仕様書無しさん [sage] 2011/02/06(日) 19:29:02 ID: Be: >>105 昔は-1はfalseだと思っていたなぁ・・・。 148 仕様書無しさん [sage] 2011/02/09(水) 01:11:54 ID: Be: >>105 あれ? trueが非ゼロってのは異論ないんだけど、 関係演算子、等値演算子、論理的AND演算子、論理的OR演算子は1か0しか返さない仕様じゃないの。 規格書じゃないけど、K&R第2版 A7.9, A7.10, A7.14, A7.15 149 仕様書無しさん [sage] 2011/02/09(水) 01:22:22 ID: Be: 元のスレでも指摘されてる >>105の>>929はそれを受けてのコメント 925 名前:デフォルトの名無しさん[] 投稿日:2011/02/06(日) 17:41:22 >>923 > Cの規格上はtrueは0以外の整数であればなんでもいいことになっているので 嘘つくな。 Cでは、組み込みの演算子によってブール値が産み出されるときは、1か0であることが保証されている。 926 名前:デフォルトの名無しさん[sage] 投稿日:2011/02/06(日) 17:43:12 あーよくある間違いだなw 確かにTRUE(真)の値は規定されていない。 でもね、==演算子を始めとする論理、比較演算子の戻り値は規定されているんだよ。 150 仕様書無しさん [sage] 2011/02/09(水) 01:26:25 ID: Be: ちなむと Pascalなんかの処理系で試すと Trueは-1だったりする。
Pascal もそうだったけか。BASIC がそうだったのは覚えてるんだけどなあ。
よくある質問。
C言語なら俺に聞け(入門編)Part 78 436 デフォルトの名無しさん [] 2011/02/11(金) 13:15:10 ID: Be: C/C++の配列について質問。 JavaやC#ではlengthでそれ自身の長さを取れますが、 C/C++では、配列それ自身のサイズを取得することは不可能なのですか? ある関数の引数として配列を渡す際に、それ自身のサイズの数値も渡さないとダメなのが不便に感じているのですが。 437 デフォルトの名無しさん [sage] 2011/02/11(金) 13:20:11 ID: Be: 配列のサイズはsizeofで取得できるよ 取得できないのは、それが配列じゃないからだよ 438 デフォルトの名無しさん [sage] 2011/02/11(金) 13:25:30 ID: Be: >>436 C++なら template <class T, int N> int func(T (&)[N]) { return N; } って取得できる 439 デフォルトの名無しさん [sage] 2011/02/11(金) 13:26:31 ID: Be: でも引数で配列受け取った側の関数からじゃ分からないよねw Cww 440 デフォルトの名無しさん [sage] 2011/02/11(金) 13:33:44 ID: Be: 文字列なら問題ない 441 デフォルトの名無しさん [sage] 2011/02/11(金) 13:36:46 ID: Be: >>439 配列なんて受け取ってないから 442 デフォルトの名無しさん [sage] 2011/02/11(金) 13:37:41 ID: Be: ターミネーター使えってことだな 443 デフォルトの名無しさん [sage] 2011/02/11(金) 13:49:31 ID: Be: std::vectorやstd::stringならsize()やlength()というメソッド(プロパティ)があるけどな だからC++では生の配列はあまり使わない 不便過ぎる 444 デフォルトの名無しさん [sage] 2011/02/11(金) 13:51:48 ID: Be: 使う人間側が便利ってことは、どっかに余計な処理入ってるってことでもある そこらへんの兼ね合いでCは低レベルってだけの話だろ 445 デフォルトの名無しさん [sage] 2011/02/11(金) 13:57:03 ID: Be: そういう事 C++でも生配列は使うけど、クリティカルな部分やわざわざSTL使うほど 大げさじゃない部分だな 逆に言うと両方使えるというのは強み
plope - Using Debuggers Using Debuggers Some folks don't use debuggers. I've been reading Masterminds of Programming . It's very interesting and engaging. The authors interview a gaggle of language and other systems designers including Guido, James Gosling, Bertrand Russell, Bjarne Stroudstrup, Chuck Moore, and others and ask them general questions about systems design, debugging, concurrency, etc. One of the things that is a bit amazing to me is that almost to a man, when asked how they debug programs, each interviewee responds "by reading the code" or "by inserting print statements." Most interviewees further deny ever using an or needing an interactive debugger. インタビューを受けていた人たちのほとんどは、プログラムをデバッグするのには 「コードを読んだり」、「print文を挿入している」と答え、対話的なデバッガーを 必要ないとしたりその使用を拒否したりした。 #ちょー訳 Obviously the folks interviewed are much more experienced than I am about wrangling code. But really, you never use a debugger? It doesn't seem practical. I'm a big fan of interactive debuggers like Python's pdb. It saves me over and over again when dealing with code I don't understand. Not having it would be terrible. One guess is that folks who don't use debuggers don't often need to debug code they did not themselves design. It's a lot easier to debug code you designed by pure reasoning than it is to debug code you're just walking up to as a library consumer. Another guess is that they just have more brain "stack space" and they can simply hold more code in their heads than people who need to rely on debuggers. ひとつの推論は、デバッガーを使わないという人たちは自分で設計していないコードを デバッグする必要はほとんどないのではないかということ。 もうひとつは、脳内スタックの領域が普通の人より大きくて、 普通の人ならデバッガーに頼らなければならないような量のコードでも 頭の中においておけるのではないかということ。 Created by chrism
(Tiobe index で) R は SAS や MATLAB よりも使われるようになった ということなんですが
Revolutions: R overtakes SAS and Matlab in programming language popularity R overtakes SAS and Matlab in programming language popularity Tiobe Software ranks the popularity of programming languages based on references in search engines. While the methodology might be debated in terms of the absolute rankings it produces, it is quite interesting to see how the rankings fluctuate over time: Tiobe has produced a monthly report of rankings based on this methodology since 2001. In the Tiobe Programming Community Index for February 2011, the top three slots are held by the general-purpose languages Java, C and C++. Domain-specific languages naturally fall farther down the list: in this months report, R is ranked at #25, with Matlab at 29 and SAS at 30. What's interesting is the movement: Matlab is down from #19 a month ago (and #20 a year ago), whereas R is up from #26. But look at SAS, mentioned in the report's summary as having "lost much ground": it's down from #16 a month ago and #14 a year ago. Tiobe Software: TIOBE Programming Community Index for February 2011 http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
まあ Tiobe index だしなあ。あと、SASはともかく MATLAB って 用途がかぶるものだっけ?
gci -Recurse | where { $_.LastWriteTime -ge "2011/2/8" }
パワポの文字数が極端に少なくなりますので「読み上げプレゼン」をいやが上にも回避できるでしょう(やや荒療治かもしれませんが)。
DEC共同創立者ケン・オルセン氏、84歳で死去 - CNET Japan かつてDECの社員であり、表計算ソフトウェア「VisiCalc」の開発者の1人であるDan Bricklin氏は Twitterで、「今では当たり前になっていることも、Olsen氏が成したことだ」と述べている。
ダン・ブルックリンも twitter やってたのね。
どこかの blog (英文ね)についてたコメントで、 もし、ケン・オルセンがパーソナルコンピューターの価値を理解していたら DEC は今も大きな影響力を持って残っていただろうってな感じのものを見かけたけどどうなんだろうか。 それは、DEC という名前ではあっても、中身はまるで違うものになっているような気がする。 IBM がそうであるように。 彼がその晩年にどう考えていたのか知ってみたい気もするけれど。 R.I.P.
BCC 5.5が使われ続けているのはエラーメッセージが日本語だから。 ってのもあるのかなあ。と思ったり (で、VSほど重くない)。
C言語なら俺に聞け(入門編)Part 75 [chaika] 692 デフォルトの名無しさん [sage] 2010/12/30(木) 00:12:12 ID: Be: cygwinのエラー張りたいんだけど ドラッグで範囲選択できない なんか方法ないですか? 693 デフォルトの名無しさん [sage] 2010/12/30(木) 00:15:13 ID: Be: パイプでもつかったら? 694 デフォルトの名無しさん [sage] 2010/12/30(木) 00:17:22 ID: Be: >>692 [編集]-[選択範囲] マウスで範囲選択した後、Enterキーでクリップボードに入るはず 695 デフォルトの名無しさん [sage] 2010/12/30(木) 01:14:20 ID: Be: a.c:28: error: stray ‘\201' in program a.c:28: error: stray ‘@' in program a.c:28: error: stray ‘\201' in program a.c:28: error: stray ‘@' in program a.c:28: error: stray ‘\201' in program a.c:28: error: stray ‘@' in program エラーの一部です @も\201もコードに書いてないはずなんですが どういう意味のエラーですか 696 デフォルトの名無しさん [sage] 2010/12/30(木) 01:55:36 ID: Be: '\201'は8進数で201、つまり16進数で81 '@'は文字コードにして16進数で40 8140といえばSJISの全角空白 697 デフォルトの名無しさん [sage] 2010/12/30(木) 02:02:54 ID: Be: ありがとう 16進数ででるんですね でもシフトジスは関係ないですね 81と40はビンゴです、 698 デフォルトの名無しさん [sage] 2010/12/30(木) 02:08:47 ID: Be: 何を言っているんだか。 699 デフォルトの名無しさん [sage] 2010/12/30(木) 02:14:48 ID: Be: コンパイラのエラーから察すると 0x81 0x40 という並び文字だ この並びで意味あるペアといえば SJIS で全角空白 ゆえに ソースは SJIS で開くと 28行目に 全角空白が 3発入っている箇所があるはずだ インデントの時に全角空白入れてしまった か "が漏れた か 700 デフォルトの名無しさん [sage] 2010/12/30(木) 02:30:52 ID: Be: >>699のみて確認したら全角でした 81,40も#defineで使ってたんですが見当違いのようです。 驚嘆しました 701 デフォルトの名無しさん [sage] 2010/12/30(木) 03:40:53 ID: Be: よくあること。 >16進数ででるんですね これも見当違いであったことに気付いてほしい 702 デフォルトの名無しさん [sage] 2010/12/30(木) 03:42:55 ID: Be: コンパイルエラーを解説する本が出たら売れると思う 705 デフォルトの名無しさん [sage] 2010/12/30(木) 08:20:15 ID: Be: コイツラわざとやってるんだろうか? 706 デフォルトの名無しさん [sage] 2010/12/30(木) 11:40:18 ID: Be: $ gcc a.c /cygdrive/c/Users/mituru/AppData/Local/Temp/cckRIuT4.o:a.c:(.text+0x338): undefi ned reference to `_fpintf' collect2: ld returned 1 exit status なんじゃこりゃあ 解決方法おしえて 707 デフォルトの名無しさん [sage] 2010/12/30(木) 11:42:20 ID: Be: × fpintf ○ fprintf 708 デフォルトの名無しさん [sage] 2010/12/30(木) 12:11:44 ID: Be: 英語も読めないのか…… 709 デフォルトの名無しさん [sage] 2010/12/30(木) 13:26:19 ID: Be: 俺はドイツ人だから英語はちょっと・・・
一つ前へ
2011年2月(上旬)
一つ後へ
2011年2月(下旬)
リンクはご自由にどうぞ
メールの宛先はこちら