ときどきの雑記帖″

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

一つ前へ 2014年8月(中旬)
一つ後へ 2014年9月(上旬)

ホームへ

2014年08月31日

■_

TNG パトレイバー第4章観てきた。

機動警察パトレイバー 1/48 98式AV イングラム
機動警察パトレイバー 1/48 98式AV イングラム

■_

2014年08月30日

■_

久しぶりの shibuya.lisp、なにも YAPC::Asia にぶつけんでも… とはいえ今年の8月~9月の週末は色々あるからなあ(先週の土曜はLL Diverがあったし)。 Shibuya.lispテクニカル・トーク#8 : ATND

書影がついたのでぺたり ナポレオン ~覇道進撃~ (7) (ヤングキングコミックス)
ナポレオン ~覇道進撃~ (7) (ヤングキングコミックス)

ルイ=ニコラ・ダヴー ルイ=ニコラ・ダヴー - Wikipedia 軍事面で「不敗のダヴー」と呼ばれるほど優秀であったほか、 これはハセガー作品発祥じゃないかなあw>「不敗のダヴー」(という渾名)

Louis-Nicolas Davout - Wikipedia, the free encyclopedia

Nickname(s)
The Iron Marshal,
The Beast
Louis Nicolas Davout — Wikipédia

Surnom
« Le Maréchal de fer »
« La Bête »

■_

■_

GNU grep の変更も一段落したっぽいのですが grep.git - grep fix integer-width bugs in undossify_input etc. なんてのが目についたのでチェック


* src/dosbuf.c (undossify_input): Return size_t, not int.
* src/grep.c (fillbuf): Work portably even if safe_read returns a
value greater than SSIZE_MAX, e.g., if there's an I/O error.
---
diff --git a/src/dosbuf.c b/src/dosbuf.c
index 9ac2d13..3b4052a 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -90,15 +90,15 @@ guess_type (char *buf, size_t buflen)
 }
 
 /* Convert external DOS file representation to internal.
-   Return the count of characters left in the buffer.
+   Return the count of bytes left in the buffer.
    Build table to map character positions when reporting byte counts.  */
-static int
+static size_t
 undossify_input (char *buf, size_t buflen)
 {
   if (! O_BINARY)
     return buflen;
 
-  int chars_left = 0;
+  size_t bytes_left = 0;
 
   if (totalcc == 0)
     {
@@ -126,7 +126,7 @@ undossify_input (char *buf, size_t buflen)
           if (*buf != '\r')
             {
               *destp++ = *buf++;
-              chars_left++;
+              bytes_left++;
             }
           else
             {
@@ -176,7 +176,7 @@ undossify_input (char *buf, size_t buflen)
             }
         }
 
-      return chars_left;
+      return bytes_left;
     }
 
   return buflen;
diff --git a/src/grep.c b/src/grep.c
index 5e6c5c6..6b930dc 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -397,7 +397,7 @@ static int grepdesc (int, int);
 
 static void dos_binary (void);
 static void dos_unix_byte_offsets (void);
-static int undossify_input (char *, size_t);
+static size_t undossify_input (char *, size_t);
 
 static int
 is_device_mode (mode_t m)
@@ -583,7 +583,7 @@ reset (int fd, struct stat const *st)
 static int
 fillbuf (size_t save, struct stat const *st)
 {
-  ssize_t fillsize;
+  size_t fillsize;
   int cc = 1;
   char *readbuf;
   size_t readsize;
@@ -645,7 +645,7 @@ fillbuf (size_t save, struct stat const *st)
   readsize -= readsize % pagesize;
 
   fillsize = safe_read (bufdesc, readbuf, readsize);
-  if (fillsize < 0)
+  if (fillsize == SAFE_READ_ERROR)
     fillsize = cc = 0;
   bufoffset += fillsize;
   fillsize = undossify_input (readbuf, fillsize);

ふうむ。

2014年08月29日

■_

YAPC 行ってきた以下略

■_

■_

1/1000 の成功率で成功するまでの試行回数を求めたいと思った。で、R。

> f <- function() { cnt<-1;while(1==1){v<-runif(1); if(v<0.001) return(cnt); cnt=cnt+1;}}
> f()
[1] 117
> f()
[1] 231
> f()
[1] 539
> f()
[1] 139
> f()
[1] 1307
> f()
[1] 5056
> f()
[1] 106
> f()
[1] 794
> f()
[1] 70
> f()
[1] 1003
> f()
[1] 246
> f()
[1] 1683
> f()
[1] 1416
> f()
[1] 444
> rep(1,10)
 [1] 1 1 1 1 1 1 1 1 1 1
> rep(1,10)->xx
> sapply(xx,f)
 [1] 1091 1913 1005 1519  889 2072 1591  743 1365   28
> sapply(xx,f)
 [1]  338  802  104  215  733   60 1011  229  104  649
> ll<-rep(1,1000)
> sapply(ll,f)
   [1]  389  458  350   16  757 2260  868 1566 1181  580 1720 1872  323
  [14] 3706   36  754 1046 1940 1150 1240 1558 2412 1676  655  723  684
(略)
 [976]  274 1796  412 1052 1793  671  265   44 1258  444 1621   47  699
 [989]  699  278 1875 1702  585   29  928 1070  339  954  755  558
> sapply(ll,f)->data
> max(data)
[1] 5537
> min(data)
[1] 1
> mean(data)
[1] 974.847

などとあーでもないこーでもないとやってしまったが、 実は組み込みのもの一つで済んでしまうという

> rgeom(100000, 0.001)->dd
> 
> max(dd)
[1] 14180
> summary(dd)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    0.0   289.0   694.0   999.9  1385.0 14180.0 

で、プロットしてみた。

> plot(1:100000,dd,type="h",lwd=1)

さすがに要素数が大きすぎるので先頭の1000個だけで。

  > plot(1:1000,dd[1:1000],type="h",lwd=1)

最大値けっこうでかくなるんだなあ。

2014年08月28日

■_

「ご意見募集」→「ファイルサーバーに置いてるExecl のファイルに書いていってね」→ 「○○さん(意見募集した人)が編集中なので読み取り専用でオープンします」 → どうしろとw

■_

■_

この辺から Embedded in Academia : Proposal for a Friendly Dialect of C : programming Proposal for a Friendly Dialect of C | Hacker News

Embedded in Academia : Proposal for a Friendly Dialect of C

ざっくり略

Here are some features we propose for friendly C:

    The value of a pointer to an object whose lifetime has ended remains the same as it was when the object was alive.

    Signed integer overflow results in two’s complement wrapping behavior at the bitwidth of the promoted type.

    Shift by negative or shift-past-bitwidth produces an unspecified result.

    Reading from an invalid pointer either traps or produces an unspecified value. In particular, all but the
    most arcane hardware platforms can produce a trap when dereferencing a null pointer, and the compiler should
    preserve this behavior.

    Division-related overflows either produce an unspecified result or else a machine-specific trap occurs.

    If possible, we want math- and memory-related traps to be treated as externally visible side-effects that
    must not be reordered with respect to other externally visible side-effects (much less be assumed to be
    impossible), but we recognize this may result in significant runtime overhead in some cases.

    The result of any signed left-shift is the same as if the left-hand shift argument was cast to unsigned,
    the shift performed, and the result cast back to the signed type.

    A read from uninitialized storage returns an unspecified value.

    It is permissible to compute out-of-bounds pointer values including performing pointer arithmetic on the
    null pointer. This works as if the pointers had been cast to uintptr_t. However, the translation from
    pointer math to integer math is not completely straightforward since incrementing a pointer by one is
    equivalent to incrementing the integer-typed variable by the size of the pointed-to type.

    The strict aliasing rules simply do not exist: the representations of integers, floating-point values and
    pointers can be accessed with different types.

    A data race results in unspecified behavior. Informally, we expect that the result of a data race is the same
    as in C99: threads are compiled independently and then data races have a result that is dictated by the
    details of the underlying scheduler and memory system. Sequentially consistent behavior may not be assumed
    when data races occur.

    memcpy() is implemented by memmove(). Additionally, both functions are no-ops when asked to copy zero bytes,
    regardless of the validity of their pointer arguments.

    The compiler is granted no additional optimization power when it is able to infer that a pointer is invalid.
    In other words, the compiler is obligated to assume that any pointer might be valid at any time, and to
    generate code accordingly. The compiler retains the ability to optimize away pointer dereferences that it
    can prove are redundant or otherwise useless.

    When a non-void function returns without returning a value, an unspecified result is returned to the caller. 

© 2014 John Regehr

2014年08月27日

■_

小説フランス革命。最終刊も発売してすぐに買ったのだけどなぜかなかなか読み進められず 未だに読み終わってない(今は1/3くらい)。

■_

2014年08月26日

■_

↑のような「ほど」の使い方が気になる今日この頃

■_

2014年08月25日

■_

出たばかりの文庫版皇国の守護者6巻の巻末を見て、 新書版6巻の発売時期を思い出して軽く目眩が。

■_

wyvernのつづき(波が去ってからネチネチ追いかける)

reddit か HN で話題になってないかなー と思って探したら HN にあった。

The Wyvern Programming Language | Hacker News


Compile-time HTML parsing, &c.? Absolutely. This sort of thing is part of why I came to Rust; while it
doesn’t make these sorts of things as easy as it looks like Wyvern does, it does make them readily possible
(the pragmatic side of me also selected it as it’s ). I will be featuring some of the ideas of these sorts of
things in my talk at Strange Loop next month (https://thestrangeloop.com/sessions/fast-secure-safe-the-web...),
and a brief look at this suggests that I’ll be mentioning Wyvern.

If that is something that you are interested in then you should definitely take a look at Nimrod (if you
haven't already; http://nimrod-lang.org). Nimrod's compile-time features are what makes it great, you can
essentially run most Nimrod code at compile-time (ffi is limited but you can use staticRead if you wanna read
your HTML templates). From a quick look at Wyvern it actually looks surprisingly similar to Nimrod, so much so
that i wonder if Wyvern was perhaps a little bit inspired by it. I'm having a hard time figuring out what
differentiates Wyvern from Nimrod in fact.

で、GIZMODE(英)よりも前の日付でこういうものも。 Wyvern system allows multiple programming languages within one computer program

つまりは例によってまた珍妙な翻訳記事に脊髄反射(のようなもの)をした御仁が多かったと。

■_

2014年08月24日

■_

「ブレークポイント」けっこう面白い

■_

未来では全てのプログラミング言語が1つになる? : ギズモード・ジャパン はてなブックマーク - 未来では全てのプログラミング言語が1つになる? : ギズモード・ジャパン

例によってこういうものは原文に当たるべき。ということで The NSA Is Funding a Project to Roll All Programming Languages Into One

The NSA Is Funding a Project to Roll All Programming Languages Into One

The "polyglot" programming language is called Wyvern—the name comes from a a mythical dragon-like
reature with two legs instead of four—and is designed to help unify the way apps and websites are created. The
researchers explain:
未来では全てのプログラミング言語が1つになる? : ギズモード・ジャパン

伝説上のドラゴンの名前を取って、その名も「Wyvern」(ワイバーン)と名付けられたこのプロラミング言語は、アプリケー
ションやウェブサイト作りにおいて複数の言語が入り乱れている状況を改善するべく、開発が進められているんだとか。

えーと「伝説上のドラゴン」ってどこから来たの? ワイバーン - Wikipedia それはそれとして、原文の mythical dragon-like reature の最後の単語は creature の間違いかなあ。

順番が前後するけど

未来では全てのプログラミング言語が1つになる? : ギズモード・ジャパン

HTML5やJavaScript、PHPにCSS、XMLなどなど…挙げだせばキリが無いプログラミング言語。分野ごとに違ったものがスタ
ンダードをとっている為、プログラマーは複数の言語を学ばなければならないケースが多いです。そんな問題を解決する
ため、アメリカ国家安全保障局(NSA)がカーネギーメロン大学に出資して、1つの統一言語を作るプロジェクトを進めてい
るんだそう。

これの原文はこう

The NSA Is Funding a Project to Roll All Programming Languages Into One

Why bother having to learn HTML5, JavaScript, PHP, CSS and XML, when you could just learn one? Well, that's
exactly what an NSA-funded project at Carnegie Mellon University seeks to achieve.

The "polyglot" programming language is called Wyvern (略

翻訳文の「統一言語」って「polyglot programming language」のことなのかなあ。 なんか意味が違っちゃうような気がするんだけど polyglot → 統一

The New NSA-Funded Code Rolls All Programming Languages Into One | Motherboard

■_

2014年08月23日

■_

LL Diver 行ってきた。以上。

いやもう、いろんなところできちんとした記事があがるんでそっちまかせでいいかなーと。 Gura はちょっと興味を引かれた Guraプログラミング言語の紹介 #lldiver - by shigemk2

■_

2014年08月22日

■_

日本初の Swift本、どんなもんだろか(以下略)

お、なんか面白そうな本が。

んで、数理論理学の近刊にこんなのが 数理論理学 合理的エージェントへの応用に向けて|コロナ社 著者のひとりが新出さんだー

■_

■_

2014年08月21日

■_

社員食堂の業者が変わったのだけれども(ry

いろいろあるねえ。 1万件を超えるイベントを主催して、学んだ教訓 | Doorkeeper

東横線が多摩川渡るところでニコタマ(二子玉川)で建設中の高いビルが見えるんだよねー。 ビルそのものより建設用クレーンの方に興味があるんだけどw 楽天、2015年8月をめどに二子玉川に移転--新築オフィスへ - CNET Japan

■_

■_

先月今月辺りの発売のオライリー本なんかはイベント会場で買おうかと思ったが、 早速今週の土曜に LL なんちゃらがあった。


一つ前へ 2014年8月(中旬)
一つ後へ 2014年9月(上旬)

ホームへ


リンクはご自由にどうぞ

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