String str = "This is a string." puts str # => This is a string. str = "This is another string." puts str # => This is another string. str = 65535 # => 例外発生
attr_型付accessor({:foo => String}) とかすると def foo @foo end def foo=(value) if value.instance_of?(String) raise(TypeError) end @foo = value end みたいなコードになるような感じ?(なんか違う気もする…)
便乗質問 ruby 1.6.3 (2001-03-19) [i386-cygwin]で a = `dir`.to_a ってやるとcommand not found: dirってエラーが出て a = `cmd.exe /c dir /b`.to_a ってやるとうまくいくんだけど。前者の方法では呼べないの?
@gaTable.collect! do |tb| tb = [] ld = @data.dup 0.upto(@data.size-1) do |lp| n = rand(ld.size) tb.push(ld[n]) ld.delete_at(n) end p tb tb ##<=要素にしたいものを最後に返す end
class Module def procedure(func) module_eval %{ alias _func_#{func} #{func} def #{func}(*args); _func_#{func}(*args); nil; end } end end def procedure(func) class << self; self; end.procedure(func) end
############
def set_pass @pass = get_pass_from_dokka end procedure :set_pass
> But when you > distribute the same sections as part of a whole which is a work based > on the Library, the distribution of the whole must be on the terms of > this License, whose permissions for other licensees extend to the > entire whole, and thus to each and every part regardless of who wrote > it.
> Thus, it is not the intent of this section to claim rights or contest > your rights to work written entirely by you; rather, the intent is to > exercise the right to control the distribution of derivative or > collective works based on the Library. > > In addition, mere aggregation of another work not based on the Library > with the Library (or with a work based on the Library) on a volume of > a storage or distribution medium does not bring the other work under > the scope of this License.
116行目 > A "work based on the > Library" means either the Library or any derivative work under > copyright law: that is to say, a work containing the Library or a > portion of it, either verbatim or with modifications and/or translated > straightforwardly into another language. > 「ライブラリに基づく作品」とは、ライブラリそのものや著作権法に基づく派生物のことを意味する。 > すなわち、ライブラリやその一部を含んでいる作品のことである。ここでいうライブラリとは、 > 変更されていないもの、変更されたもの、他の言語に直訳されたもの、さらには、変更しながら他の > 言語に訳されたもののことを言う。
149行目 > 2. You may modify your copy or copies of the Library or any portion > of it, thus forming a work based on the Library, and copy and > distribute such modifications or work under the terms of Section 1 > above, provided that you also meet all of these conditions: > <中略> > c) You must cause the whole of the work to be licensed at no > charge to all third parties under the terms of this License. > 2. 下記の条件を全て満たす限り、ライブラリまたはその一部を変更して、 > 「ライブラリに基づく作品」を作り、そのような変更物や作品を上記セクション1に > 基づいて複製し配布できる。 > > c) 作品の全体を、このライセンスの条項のもとで、無償で全ての第三者に提供しなければならない。
>>514 > regex.cが「work based on the Library」で、それ以外のRubyの > コードは「work that uses the Library」です。
仮にregex.cがライブラリだとすると、第5節を読む限り確かにあなたの言うことは 正しい気がします。 ですが、だからと言って、Rubyが「work that uses the Library」とはいえないと思います。 なぜなら、regex.cを含んでいるからです。 Rubyは>>508に書かれている定義によると「work based on the Library」です。
バイナリはどうかということを考えると、いちいち引用はしませんが、LGPLには「work that uses the Library」とLibraryをコンパイルして静的に結合すると、「work based on the Library」ができると明示してあります。 したがって、Rubyのバイナリはいずれにしても「work based on the Library」であり LGPLまたはGPLでライセンスしない限りLGPL違反だと思います。
次にソース配布はどうかということですが、私はさっきも書いたようにregex.cが Rubyに含まれる限り「work based on the Library」であり、それ故にLGPL違反だと 言わざるを得ません。 もしも、regex.cがRubyに含まれないと言えるのならば、違反ではなくなるはずですが、 少なくとも、作者がregex.cがRubyに含まれると言ってしまっている以上は、Ruby にregex.cが含まれないとするのは今のところ間違ってるのではないかと思います。
ちなみに、議論となってる「LGPLにおけるライブラリ」ですが、
> A "library" means a collection of software functions and/or data > prepared so as to be conveniently linked with application programs > (which use some of those functions and data) to form executables.
> a) Accompany the work with the complete corresponding > machine-readable source code for the Library including whatever > changes were used in the work (which must be distributed under > Sections 1 and 2 above);
とありますが、「(which must be distributed under Sections 1 and 2 above)」 が何を修飾しているかが問題です。 この「(which must be distributed under Sections 1 and 2 above)」を 先ほどのHPでは見落としているのではないかと思います。 そのHPからリンクが貼ってある日本語訳ではなぜかchangesを修飾してるようですが、 これは誤訳でしょう。 私は「the work」を修飾してるものだと思い込んでいましたが、「source code」を 修飾してるとも考えられますね。前者ならやはりRubyはLGPL違反。後者ならRubyは バイナリなら違反をなくすことが出来ると思います。私には両方の解釈がありえる としか思えないです。誰か英語力のある方の見解を聞きたいところです。
ところで、LGPLの新しいバージョンのセクション6の b) はかなり緩いですね。 このb)はかなり使えると思います。 それに加えて、私の考えが正しいならばの話ですが、新しいバージョンのLGPLで ソースコードも灰色にすることが出来ると思います。 LGPLは、配る人が新バージョンでライセンスすることも出来るはずなので、 まつもと氏が新バージョンを選択すれば解決に一歩近づくのではないで しょうか?
>>580 「(which must be distributed under Sections 1 and 2 above)」は (ライブラリの)source codeだと思います。そうでないと、その後の 「and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code,(以下略)」 の意味がとれなくなりませんか?
>>601 >「and, if the work is an executable linked > with the Library, with the complete machine-readable "work that > uses the Library", as object code and/or source code,(以下略)」 > の意味がとれなくなりませんか?
>>580 > とありますが、「(which must be distributed under Sections 1 and 2 above)」 > が何を修飾しているかが問題です。
どちらを修飾しても意味は変わらないと思います。 なぜなら、Sections 1 and 2 では、 「"the Library" (or with a work based on the Library)」 のみについて制限しているためです。 たとえ上の関係節が、 "the work" = "(portions of) the Library" + "the work that uses the Library" の全体を修飾しているとしても、実際に関係するのは前者の方だけで、 "the work that uses the Library" の方は与り知らぬことになります。
つまり、「変更点を含む"the Library"」をLGPLで配布し、 "the work that uses the Library" の 少なくともソースを適切なライセンスで提供すれば、 それを結合して作ったバイナリ全体も好きなライセンスにすることができる、 と読むべきでしょう。
ただし、Rubyがこれに違反しているかどうかは別問題で、 Sections 1 and 2 に沿っているかどうかによるでしょう。 私は、regex以外は "the work that uses the Library" だと思う。
>>609 "the work" = "the work based on the Library" = Section 2の対象
611 名前: 609 投稿日: 2001/07/12(木) 09:14
>>610 この等式が成り立つとは考えられない。 ライセンスの文面には "work" が違う意味で出てくるでしょ。 なのに単に "the work" とだけ出てきたら、 その直前に出てきた"work"、つまり6節の冒頭の "a work containing portions of the Library" を指すはず。
>>609 「the work」は「Library」を含むわけですから、全体として「work based on the Library」になるはずです。 確かに、regex以外の部分は「the work that uses the Library」のような気が します(しかし、私にはそうだと言い切れません)。 しかし、セクション2や前書きなどに書かれていることをみると、ライブラリ以外の 部分を独立した離れた作品とみなせなければ、全体がLGPLに従わなければ ならないと書いてあります。 そして、Rubyはみなせないように見えます。理由は以前書いた通りです。
そして、ライブラリを利用するプログラムについても、第5節で、 「Such a work(注:"work that uses the Library"のこと), in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.」 とあります。つまり「outside the scope」だと。 さらにこの後に、 「 However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library)」 とありますが、これはリンクして実行形式を作った場合のことです。 よってソース配布について制限を加えるものではありません。
第2節にも、 Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. とありますし。
>>618 その部分は「in isolation」や「(because it contains portions of the Library)」 の部分が重要です。 つまり、独立した作品なら「outside the scope」であり、ライブラリを含んだ場合 はLGPLによってカバーされるということだと思います。 セクション1と2に違反しなければ良いというのはその通りなんですが、セクション2に は497で私が引用した部分があります。
> But when you > distribute the same sections as part of a whole which is a work based > on the Library, the distribution of the whole must be on the terms of > this License, whose permissions for other licensees extend to the > entire whole, and thus to each and every part regardless of who wrote > it.