<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>Mtok-blog</title>
	<atom:link href="http://www.matzmtok.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.matzmtok.com/blog</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 27 Oct 2011 16:47:32 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/" />
		<item>
		<title>数字から始まるclass属性値をセレクタに利用する</title>
		<link>http://www.matzmtok.com/blog/?p=658</link>
		<comments>http://www.matzmtok.com/blog/?p=658#comments</comments>
		<pubDate>Sat, 15 Oct 2011 14:55:15 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=658</guid>
		<description><![CDATA[cssは、class属性の値が数字になっているものはセレクタとして使用できないと思ってたら、バックスラッシュエスケープを使えばセレクタとして扱うことができる。　知りませんでした、これ。

&#60;p class=&#34;1999&#34;&#62;1999年は・・・&#60;/p&#62;


p.\31\39\39\39 {
  font-weight: bold;
}

]]></description>
			<content:encoded><![CDATA[<p>cssは、class属性の値が数字になっているものはセレクタとして使用できないと思ってたら、バックスラッシュエスケープを使えばセレクタとして扱うことができる。　知りませんでした、これ。</p>
<pre>
&lt;p class=&quot;1999&quot;&gt;1999年は・・・&lt;/p&gt;
</pre>
<pre>
p.\31\39\39\39 {
  font-weight: bold;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=658</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=658" />
	</item>
		<item>
		<title>フロー制御</title>
		<link>http://www.matzmtok.com/blog/?p=640</link>
		<comments>http://www.matzmtok.com/blog/?p=640#comments</comments>
		<pubDate>Thu, 23 Dec 2010 13:04:41 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[F#/Ocaml]]></category>
		<category><![CDATA[Learning F#]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=640</guid>
		<description><![CDATA[if
シンプルな分岐制御、分岐条件に１つのBooleanをとる。キーワードthenは必須で分岐条件の終わりを示し、続いてtrueだった場合に実行されるコードが続く。
let x = 12
if x = 12 then
    System.Console.WriteLine("x is 12")
ほかの多くの言語にあるような暗黙の型変換は行われず、F#では0や非ゼロをBooleanのtrueやfalseとして扱ってはくれないので、プログラマは=演算子(等号)や演算子(非等号)をつかって明示的にBooleanを求める必要がある。
if else 式
let x =12
if [...]]]></description>
			<content:encoded><![CDATA[<h2>if</h2>
<p>シンプルな分岐制御、分岐条件に１つのBooleanをとる。キーワードthenは必須で分岐条件の終わりを示し、続いてtrueだった場合に実行されるコードが続く。</p>
<pre>let x = 12
if x = 12 then
    System.Console.WriteLine("x is 12")</pre>
<p>ほかの多くの言語にあるような暗黙の型変換は行われず、F#では0や非ゼロをBooleanのtrueやfalseとして扱ってはくれないので、プログラマは=演算子(等号)や<>演算子(非等号)をつかって明示的にBooleanを求める必要がある。</p>
<p>if else 式</p>
<pre>let x =12
if x = 12 then
    System.Console.WriteLine("x is 12")
else
    System.Console.WriteLine("x is not 12")
</pre>
<p>if elif else 式</p>
<pre>let x = 12
if x = 12 then
    System.Console.WriteLine(" x is 12")
elif x = 20
    System.Console.WriteLine("x is 20")
else
    System.Console.WriteLine("other")</pre>
<p>また、関数言語では、ifも&#8221;statement&#8221;(文)ではなく&#8221;expression&#8221;(式)なので値を返す。</p>
<pre>
let x = 12
let msg = if x = 12 then
    "x is 12"
else
    "x is not 12"
System.Console.WriteLine(msg)</pre>
<p>ただし、ifから戻る値の型は一つだけなので、if節else節から戻る値の型が異なると、コンパイルエラーになる。</p>
<pre>let x = 12
let msg = if x = 12 then
    "x is 12"  //戻り値はint型
else
    System.Console.WriteLine("x is not 12") //戻り値がunit型になるのでコンパイルエラー　</pre>
<h2>ループ while/do</h2>
<pre>while ( System.DateTime.Now.Minute &lt;&gt; 0) do
    System.Console.WriteLine(&quot;0分ではありません&quot;)
</pre>
<p>while/doは&#8221;statement&#8221;(文)なので、戻り値はない。　なので関数言語ではあまりwhile/doは使われない。</p>
<h2>ループ for </h2>
<pre>for i = 1 to System.DateTime.Now.Hour do
    System.Console.WriteLine("foobar")
</pre>
<p>toの代わりに、downtoというキーワードを用いれば、デクリメントになる。</p>
<pre>for i = 10 downto 1 do
    System.Console.WriteLine("i = {0}", i)
</pre>
<p>単純なforの場合、式ではなく文なので何の値も返さない。</p>
<h2>例外</h2>
<p>F#での例外処理は、try..withとtyr&#8230;finallyという構文で例外を処理する。C#にあるtry&#8230;with&#8230;finallyという構文はサポートしない。</p>
<h3>try&#8230;with</h3>
<pre>let result =
    try
        let req = System.Net.WebRequest.Create("Not a legitimate URL");
        let resp = req.GetResponse()
        let stream = resp.GetResponseStream()
        let reader = new System.IO.StreamReader(stream)
        let html = reader.ReadToEnd()
        html
    with
        | :? System.UriFormatException -> "You gave a bad URL"
        | :? System.Net.WebException as webEx -> "Some other exception: " + webEx.Message
        | ex -> "We got an exception: " + ex.Message
results
</pre>
<p>キーワードtryとwithの間がガードブロックで、with以降に例外をキャッチするブロックがそれぞれ続く。<br />
ifの時と同様にtry..withも式なのでtryブロックからの戻り値とwithブロックの例外処理による戻り値の型に互換性がないとエラーになる。</p>
<p>例外をキャッチを行う節はそれぞれ&#8221;|&#8221;で区切られ、以下のような構文になる。例外は構文内のパターンによってフィルタリングされる。</p>
<pre>
 | パターン-> 式
</pre>
<p>例外のフィルターパターンにはいくつかの記述の仕方がある。<br />
特定の.NET例外をキャッチしたい場合</p>
<pre>
| :? .NET例外の型　-> 式
例
 | :? System.UriFormatException -> "You gave a bad URL"
</pre>
<p>特定の.NET例外をキャッチして、さらに式ないで参照したい場合はasで識別子を付ける。.NET例外というのは.NET側で定義されている例外という意味。</p>
<pre>
| :? .NET例外の型 as 識別子　-> 式
例
| :? System.Net.WebException as webEx -> "Some other exception: " + webEx.Message</pre>
<p>F#で定義されたF#例外をキャッチしたい場合</p>
<pre>
| 例外の名前(引数) -> 式 //引数にスローされた例外の引数の値がバインディングされる。

//例
//exception Error1 of string と例外 Error1を定義されているとする

| Error(str) -> Sytem.Console.WriteLine(str)
</pre>
<p>単純に任意の例外をキャッチする場合</p>
<pre>
単純に識別子を記述するだけ、例外はその識別子をつかって参照する。
| 識別子 -> 式
例
| ex -> ex.hoge
</pre>
<p>任意の例外にマッチし特定の条件が成立する場合</p>
<pre>
| 識別子 when 条件

例
 | ex when val = 0 -> System.Console.WriteLine("val is 1")
</pre>
<h3>try&#8230;finally</h3>
<p>try&#8230;finallyではtryブロック内で例外が起ろうが起こるまいが、finallyブロックを実行する</p>
<pre>
let result = try
    (12 / 0)
finally
    System.Console.WriteLine("In finally block")
</pre>
<p>tryブロック内で例外発生しなかったときは、tryブロック内の最終的な値が戻り値として返される。tryブロック内で例外が発生した時は戻り値はなく、finallyブロック内の結果は戻り値に影響しない。発生した例外は上位のスタックフレームに送られ、例外ハンドラを探すが、ハンドラが見つからない場合、プログラム終了することになる。</p>
<h3>例外のスロー</h3>
<p>例外はキーワードraiseによってスローする</p>
<pre>
try
    raise (new System.Exception("I don't wana!"))
finally
    System.Console.WriteLine("In finally block")
</pre>
<h3>例外の定義</h3>
<p>F#には2通りの例外の定義の方法があり、<br />
１つは、C#やVisualBasicのように例外クラスを定義する方法<br />
もう1つは、exceptionキーワードを使って例外を定義する方法がある。</p>
<pre>
//exception 例外タイプ　of 引数タイプ
exception MyException of string
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=640</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=640" />
	</item>
		<item>
		<title>F#のプリミティブ型</title>
		<link>http://www.matzmtok.com/blog/?p=621</link>
		<comments>http://www.matzmtok.com/blog/?p=621#comments</comments>
		<pubDate>Wed, 22 Dec 2010 14:46:51 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[F#/Ocaml]]></category>
		<category><![CDATA[Learning F#]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=621</guid>
		<description><![CDATA[Boolean
ほかの言語と同じようにtrue/falseのいずれかの値を持つ。
整数型
F#では8ビット～64ビット、符号付き/符号なしなど幅広いタイプの整数型を持つ。


型
説明
リテラル


Byte
8ビット符号なし整数
3uy, 0xFuy


Sbyte
8ビット符号あり整数
3y, 0xFy


int16
16ビット符号あり整数
3s, 0xFs


uint16
16ビット符号なし整数
3us, 0xFus


int, int32
32ビット符 [...]]]></description>
			<content:encoded><![CDATA[<h2>Boolean</h2>
<p>ほかの言語と同じようにtrue/falseのいずれかの値を持つ。</p>
<h2>整数型</h2>
<p>F#では8ビット～64ビット、符号付き/符号なしなど幅広いタイプの整数型を持つ。</p>
<table>
<tr>
<th>型</th>
<th>説明</th>
<th>リテラル</th>
</tr>
<tr>
<td>Byte</td>
<td>8ビット符号なし整数</td>
<td>3uy, 0xFuy</td>
</tr>
<tr>
<td>Sbyte</td>
<td>8ビット符号あり整数</td>
<td>3y, 0xFy</td>
</tr>
<tr>
<td>int16</td>
<td>16ビット符号あり整数</td>
<td>3s, 0xFs</td>
</tr>
<tr>
<td>uint16</td>
<td>16ビット符号なし整数</td>
<td>3us, 0xFus</td>
</tr>
<tr>
<td>int, int32</td>
<td>32ビット符号あり整数</td>
<td>3, 0xF</td>
</tr>
<tr>
<td>uint32</td>
<td>32ビット符号なし整数</td>
<td>3u, 0xFu</td>
</tr>
<tr>
<td>int64</td>
<td>64ビット符号あり整数</td>
<td>3L, 0xFL</td>
</tr>
<tr>
<td>uint64</td>
<td>64ビット符号なし整数</td>
<td>3UL, 0xFUL</td>
</tr>
<tr>
<td>nativeint</td>
<td>実行環境依存の符号あり整数型</td>
<td>3n, 0xB8000n</td>
</tr>
<tr>
<td>unativeint</td>
<td>実行環境依存の符号なし整数</td>
<td>3un, 0xB8000</td>
</tr>
<tr>
<td>bigint</td>
<td>任意の大きさを持つ整数型</td>
<td>3I</td>
</tr>
</table>
<h2>ビット演算</h2>
<table>
<tr>
<th>演算子</th>
<th>説明</th>
<th>例</th>
</tr>
<tr>
<td>&#038;&#038;&</td>
<td>AND</td>
<td>0b1101 &#038;&#038;&#038; 0b1110 -> 0b1100</td>
</tr>
<tr>
<td>|||</td>
<td>OR</td>
<td>0b1101 ||| 0b1110 -> 0b1111</td>
</tr>
<tr>
<td>^^^</td>
<td>XOR</td>
<td>0b1101 ^^^ 0b1110 -> 0b0011</td>
</tr>
<tr>
<td>~~~</td>
<td>NOT</td>
<td>~~~ 0b11110000uy -> 0b00001111uy</td>
</tr>
<tr>
<td>&lt;&lt;&lt;</td>
<td>左シフト</td>
<td>0b0110 <<< 1 -> 0b1100</td>
</tr>
<tr>
<td>&gt;&gt;&gt;</td>
<td>右シフト</td>
<td>0b0110 >>> 1 -> 0b0011</td>
</tr>
</table>
<h2>浮動小数点型</h2>
<table>
<tr>
<th>型</th>
<th>説明</th>
<th>リテラル</th>
</tr>
<tr>
<td>single, float32</td>
<td>32ビット浮動小数点</td>
<td>3.2f, 1.3e4f</td>
</tr>
<tr>
<td>double,float</td>
<td>64ビット浮動小数点</td>
<td>3.2, 1.3e4</td>
</tr>
<tr>
<td>decimal</td>
<td>128ビット浮動小数点</td>
<td>300.5M, 1.9M</td>
</tr>
<tr>
<td>bignum</td>
<td>任意の長さの数値</td>
<td>19N, 1.9N</td>
</tr>
</table>
<h2>数値型の変換</h2>
<p>F#では、ほかの多くの言語が行ってくれるような数値型間での暗黙の型変換というものが行われない。<br />
たとえば、int型とfloat型の計算は、int型が自動的にfloat型に変換されて計算がおこなわれるがF#では、明示的にキャストして計算を行う必要がある。</p>
<pre>
let i =4 //int型
let f = 4.0 // float32型

//let result = i + f   // コンパイルエラーとなる

let result = (float32 i) + f // float32 へ明示的にキャストする必要がある
</pre>
<h2>文字型と文字列型</h2>
<table>
<tr>
<th>型</th>
<th>説明</th>
<th>リテラル</th>
</tr>
<tr>
<td>string</td>
<td></td>
<td>&#8220;hello,world&#8221;</td>
</tr>
<tr>
<td>byte[]</td>
<td></td>
<td>&#8220;abcdefg&#8221;b</td>
</tr>
<tr>
<td>char</td>
<td></td>
<td>&#8216;a&#8217;</td>
</tr>
</table>
<p>string型のリテラルは&#8221;some string&#8221;というようにダブルクォートで文字列をかこみ、エスケープ処理も行われるが、文字列の前に@をつけた場合その文字列はエスケープされずにそのまま評価される。</p>
<pre>
let str1= "C:\\Prg\\FSharp\\Examples" //エスケープされる
let str2 = @"C:\Prg\FSharp\Examples" //エスケープされない
</pre>
<p>また、マルチラインストリングリテラルといって、C#などと違い、ダブルクォート内で改行してもＯＫ</p>
<pre>
let str3 = "Hello,
world of f sharp" //\nと書く代わりに改行をそのまま行ってもＯＫ
</pre>
<h2>Unit</h2>
<p>Unit型は、特別な型で、型のないことを表す型のようなもの。<br />
voidやnullを組み合わせたような感じ<br />
値を返さないような関数の戻り値として使用されたりする。</p>
<h2>単位</h2>
<p>F#には、プリミティブ型に加えて、単位に関する注釈を追加できる。単位を定義するにはコンパイラが分かるようにMeasureアノテーションを記述する。</p>
<pre>
[&lt;measure&gt;] type usd  //USドル　を表すusdという単位を定義
[&lt;measure&gt;] type euro  //ユーロを表すeuroという単位を定義
</pre>
<p>関数の定義にも単位をしていすることができる。</p>
<pre>
let usdRoyaltyCheck = 1500000.00&lt;usd&gt;   //単位が&lt;usd&gt;のfloat型を定義
let usdToEuro (dollars : float&lt;usd&gt;) =
    dollars * 1.5&lt;euro/usd&gt;   // 単位が &lt;euro/usd&gt; のfloat型の値1.5 という意味。
</pre>
<p>もし引数の単位が異なるとType mismatchのコンパイルエラーが発生する。</p>
<h2>リテラル</h2>
<p>Listeral アノテーションをつけて名前と値のバインディングを定義すると、それは定数として扱われる。おもにC#とF#を相互利用する場合や、match式なので使用される。</p>
<pre>
[&lt;literal&gt;]
let str = &quot;Hello, world&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=621</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=621" />
	</item>
		<item>
		<title>F# 基本的な構文</title>
		<link>http://www.matzmtok.com/blog/?p=606</link>
		<comments>http://www.matzmtok.com/blog/?p=606#comments</comments>
		<pubDate>Tue, 14 Dec 2010 08:25:11 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[F#/Ocaml]]></category>
		<category><![CDATA[Learning F#]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=606</guid>
		<description><![CDATA[コメント
複数行コメント
[f#](* これはF#の
複数行コメントです。 *)
[/f#]
行コメント
[f#]// これは一行コメント[/f#]
ドキュメンテーションコメント
///とスラッシュを三つ続ける、C#のようなドキュメンテーションコメントにも対応している
コメント内で推奨されているタグについてはこちらを参照
[f#]//例
///
This is a cool functio [...]]]></description>
			<content:encoded><![CDATA[<h2>コメント</h2>
<p>複数行コメント</p>
<p>[f#](* これはF#の<br />
複数行コメントです。 *)<br />
[/f#]</p>
<p>行コメント<br />
[f#]// これは一行コメント[/f#]</p>
<p>ドキュメンテーションコメント<br />
///とスラッシュを三つ続ける、C#のようなドキュメンテーションコメントにも対応している<br />
コメント内で推奨されているタグについては<a href="http://msdn.microsoft.com/ja-jp/library/dd233217.aspx" rel="nofollow">こちらを参照</a><br />
[f#]//例<br />
///<br />
<summary>This is a cool function</summary>
<p>/// <remarks>Use it wisely</remarks>[/f#]</p>
<h2>識別子</h2>
<p>F#の識別子は、C++やC#のようにキャラクタ＋数字＋アンダースコアを使用することができる。ユニコード対応なので日本語でもＯＫ。ただし、最初の一文字はキャラクタがアンダースコアである必要がある。</p>
<p>[f#]<br />
let a = &#8220;foo&#8221; //OK<br />
let _b = &#8220;bar&#8221; //OK<br />
let 1c = &#8220;boo&#8221; // Error<br />
[/f#]</p>
<p>以下のF#の予約語も識別子として使用できない<br />
[f#]<br />
abstract and as asr assert atomic base begin break checked class component<br />
const constraint constructor continue default delegate do done downcast<br />
downto eager elif else end event exception extern external false finally<br />
fixed for fun function functor global if in include inherit inline<br />
interface internal land lazy let lor lsl lsr lxor match member method mixin<br />
mod module mutable namespace new null object of open or override parallel<br />
private process protected public pure rec return sealed sig static struct<br />
tailcall then to trait true try type upcast use val virtual void volatile<br />
when while with yield<br />
[/f#]</p>
<h2>プリプロセッサディレクティブ・コンパイラディレクティブ</h2>
<p>#if#elseや#lightなどのように#で始まるプリプロセッサディレクティブやコンパイラディレクティブを記述することで、条件コンパイルや、簡易構文の有効無効などの設定を行う事が出来る。</p>
<p><a href="http://msdn.microsoft.com/ja-jp/library/dd233195.aspx" rel="nofollow">MSDN コンパイラディレクティブ</a></p>
<h2>簡易構文</h2>
<p>F#では、簡易構文といって、有効にするとin/begin/endなどのキーワードを省略してコードを記述することができる。<br />
簡易構文では空白によるインテントで構成要素の先頭と末尾を示す。<br />
#lightコンパイラディレクティブによって簡易構文の有効/無効を指定できる（デフォルトで有効）</p>
<p><a href="http://msdn.microsoft.com/ja-jp/library/dd233199.aspx">msdn 詳細構文</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=606</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=606" />
	</item>
		<item>
		<title>NativeProcessを使う</title>
		<link>http://www.matzmtok.com/blog/?p=595</link>
		<comments>http://www.matzmtok.com/blog/?p=595#comments</comments>
		<pubDate>Mon, 13 Dec 2010 02:35:17 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[air]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=595</guid>
		<description><![CDATA[NativeProcessを使う上での注意点
NativeProcessを試そうと思ったら、いくつか躓いたのでメモ。
アプリケーション記述ファイルのネームスペースをAIR2.0以降のものにしておく
AIRがNativeProcessをサポートしたのは、2.0以降なのでアプリケーション記述ファイルのネームスペースがそれ以前のものだと、flash.desktop.NativeProcessが定義されていないとされて実行時にエラーになります。（コンパイルはできる）
Fl [...]]]></description>
			<content:encoded><![CDATA[<h2>NativeProcessを使う上での注意点</h2>
<p>NativeProcessを試そうと思ったら、いくつか躓いたのでメモ。</p>
<h3>アプリケーション記述ファイルのネームスペースをAIR2.0以降のものにしておく</h3>
<p>AIRがNativeProcessをサポートしたのは、2.0以降なのでアプリケーション記述ファイルのネームスペースがそれ以前のものだと、flash.desktop.NativeProcessが定義されていないとされて実行時にエラーになります。（コンパイルはできる）</p>
<p>Flash Builderを使っている人は大丈夫だと思うが、FlashDevelopのAIRプロジェクトで書き出されるアプリケーション記述ファイルのネームスペースは1.5のままなので、書き換えるのを忘れると　アレ？　ってことになる。(この時点ではFlashdevelop 3.3.2)</p>
<p>FlashDevelopのプロジェクト内のapplication.xmlの</p>
<pre>
&lt;application xmlns=&quot;http://ns.adobe.com/air/application/1.5&quot;&gt;
   ....
&lt;/application&gt;
</pre>
<p>を以下のように書き換える。</p>
<pre>
&lt;application xmlns=&quot;http://ns.adobe.com/air/application/2.0&quot;&gt;
   ....
&lt;/application&gt;
</pre>
<h3>NativeProcessは拡張デスクトップでのみ利用できる</h3>
<p>NativeProcessは拡張でクストップでのみ利用できる。拡張でクストップというのは、ネイティブインストーラーによってインストールされたアプリケーションに適用されるデバイスプロファイル。つまり、拡張デスクトップの機能を利用するなら、アプリケーションをwindowsならexe、macならDMG、LinuxならRPM、bin、debなどのそれぞれのＯＳでお馴染みのインストーラーによってインストールする必要がある。</p>
<p>ネイティブインストーラを作るには以下を参考に。<br />
<a href="http://help.adobe.com/ja_JP/air/build/WS789ea67d3e73a8b22388411123785d839c-8000.html">デスクトップネイティブインストーラーのパッケージ化</a></p>
<p>デバイスプロファイルについては以下を参考に。<br />
<a href="http://help.adobe.com/ja_JP/air/build/WS144092a96ffef7cc16ddeea2126bb46b82f-8000.html">Adobe AIR デバイスプロファイル</a></p>
<h3>拡張デスクトップのデバイスプロファイルでデバッグするには</h3>
<p>いちいち、ネイティブインストーラーを作ってインストールしてテストするのはかなり面倒なので<br />
adlコマンドに-profileオプションでextendedDesktopを指定してやるか、<br />
アプリケーション記述ファイルのsupportedProfiles要素にextendedDesktopを記述して、デバイスプロファイルを拡張デスクトップのみに制限してやるとNativeProcessを利用できるようになる。</p>
<pre>
//例
adl -profile extendedDesktop application.xml bin
</pre>
<pre>
&lt;application xmlns=&quot;http://ns.adobe.com/air/application/2.0&quot;&gt;
   ....
    &lt;supportedProfiles&gt;extendedDesktop&lt;/supportedProfiles&gt;
    ....
&lt;/application&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=595</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=595" />
	</item>
		<item>
		<title>e4x: XMLの要素を検索・フィルタリングする方法</title>
		<link>http://www.matzmtok.com/blog/?p=583</link>
		<comments>http://www.matzmtok.com/blog/?p=583#comments</comments>
		<pubDate>Sun, 06 Jun 2010 04:18:29 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[e4x]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=583</guid>
		<description><![CDATA[E4Xは非常に強力なのでXMLから値を検索したり、特定の値を持つ要素をとり除くたりといった処理が簡単にできます。
[actionscript]
package
{
	import flash.display.Sprite;
	/**
	 * &#8230;
	 * @author Motoki Matsumoto
	 */
	public class E4XFiltering extends Sprite
	{
		private va [...]]]></description>
			<content:encoded><![CDATA[<p>E4Xは非常に強力なのでXMLから値を検索したり、特定の値を持つ要素をとり除くたりといった処理が簡単にできます。</p>
<p>[actionscript]<br />
package<br />
{<br />
	import flash.display.Sprite;<br />
	/**<br />
	 * &#8230;<br />
	 * @author Motoki Matsumoto<br />
	 */<br />
	public class E4XFiltering extends Sprite<br />
	{<br />
		private var _xml:XML =<br />
		<books xmlns = "http://book/namespace/" xmlns:p = "http://parson/namespace/" ><br />
			<book name="PHPで作る携帯サイトデベロッパーズガイド" price ="3150"><br />
				<author></p>
<p:parson p:name="滝下 真玄" uri="http://blog.ecworks.jp/" />
				</author><br />
			</book><br />
			<book name="PHP×携帯サイト 実践アプリケーション集" price="2940"><br />
				<author>株式会社マイネット・ジャパン</author><br />
				<author></p>
<p:parson p:name="平島 浩一郎" />
				</author><br />
				<author></p>
<p:parson p:name="伊藤 祐策" />
				</author><br />
				<author></p>
<p:parson p:name="中元 正也" />
				</author><br />
			</book><br />
			<book name="PHP×携帯サイト デベロッパーズバイブル" price="2940"><br />
				<author></p>
<p:parson p:name="荒木 稔" uri="http://memokami.com/" />
				</author><br />
			</book><br />
			<book name="Adobe Flex 3 &#038; AIRではじめるアプリケーション開発" price="4410"><br />
				<author></p>
<p:parson p:name="公門 和也" />
				</author><br />
				<author></p>
<p:parson p:name="大谷 晋平" />
				</author><br />
				<author></p>
<p:parson p:name="堀越 悠久史" />
				</author><br />
			</book><br />
		</books><br />
		public function E4XFiltering()<br />
		{<br />
			//<br />
			var book:Namespace = new Namespace(&#8216;http://book/namespace/&#8217;);<br />
			var parson:Namespace = new Namespace(&#8216;http://parson/namespace/&#8217;);<br />
			trace(_xml.book::book);</p>
<p>			//authorが複数いる本を探す。<br />
			trace(_xml.book::book.(book::author.length() > 1));</p>
<p>			//本のタイトルにFlexを含む本を探す<br />
			trace(_xml.book::book.( /flex/i.test(@name) ));</p>
<p>			//価格が2900円カラ3500円の本を探す<br />
			trace(_xml.book::book.( @price > 2900 &#038;&#038; @price < 3500 ));</p>
<p>			//著者の名前をリストアップ<br />
			trace(_xml..parson::parson.@parson::name);</p>
<p>			//uriをもつ著者のみをリストアップ<br />
			trace( _xml..parson::parson.( hasOwnProperty( new QName( parson, &#8216;@uri&#8217;) ) ) );<br />
		}<br />
	}<br />
}<br />
[/actionscript]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=583</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=583" />
	</item>
		<item>
		<title>AS3オブジェクトからそのクラスの参照を取得する</title>
		<link>http://www.matzmtok.com/blog/?p=577</link>
		<comments>http://www.matzmtok.com/blog/?p=577#comments</comments>
		<pubDate>Sat, 05 Jun 2010 14:57:28 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[as3]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=577</guid>
		<description><![CDATA[
もしオブジェクトからそのクラスの参照が必要な場合、関数flash.utils.getQualifiedClassNameでクラス名を取得、
flash.utils.getDefinitionByNameにクラス名を渡して、クラスへの参照を得る。

[actionscript]
package
{
	import flash.display.Sprite;
	import flash.utils.getQualifiedClassName;
	import flash.utils.getDefinitionByName;
	/**
	 * &#8230;
	 * @au [...]]]></description>
			<content:encoded><![CDATA[<p>
もしオブジェクトからそのクラスの参照が必要な場合、関数flash.utils.getQualifiedClassNameでクラス名を取得、<br />
flash.utils.getDefinitionByNameにクラス名を渡して、クラスへの参照を得る。
</p>
<p>[actionscript]<br />
package<br />
{<br />
	import flash.display.Sprite;<br />
	import flash.utils.getQualifiedClassName;<br />
	import flash.utils.getDefinitionByName;<br />
	/**<br />
	 * &#8230;<br />
	 * @author Motoki Matsumoto<br />
	 */<br />
	public class GetClassRef extends Sprite<br />
	{<br />
		public static const TEST_MESSAGE:String = &#8220;foobar&#8221;;<br />
		public function GetClassRef()<br />
		{<br />
			super();<br />
			var s:Sprite = new Sprite();<br />
			var cls:Class = getClass(s);<br />
		}</p>
<p>		private function  getClass( obj:* ):Class<br />
		{<br />
			return getDefinitionByName( getQualifiedClassName(obj)) as Class;<br />
		}<br />
	}<br />
}<br />
[/actionscript]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=577</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=577" />
	</item>
		<item>
		<title>PHP：メンバメソッドをスタティックメソッドと間違えてハマるの巻。</title>
		<link>http://www.matzmtok.com/blog/?p=569</link>
		<comments>http://www.matzmtok.com/blog/?p=569#comments</comments>
		<pubDate>Fri, 04 Jun 2010 06:36:45 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=569</guid>
		<description><![CDATA[
メンバメソッドをスタティックメソッドと間違えて実行していたおかげでハマった。
PHPは、他のクラスで定義されているメソッドでもNoticeやWarningなしで実行できたりする。


以下の例だと、クラスBClassに定義されてるメソッドtestFuncを
クラスAClassの中からスタティックメソッドとして実行している。
もちろん、$thisのスコープはAClassのインスタンスとなる。
んで、運悪く、AClassにもBClassにも同じ名前のメソッド
sayHelloなんてものがあると、気づかずに処理が進んでしまったりするわけだ。


バリバリＰＨＰやってる人には常識なのかな？
他のクラ [...]]]></description>
			<content:encoded><![CDATA[<p>
メンバメソッドをスタティックメソッドと間違えて実行していたおかげでハマった。<br />
PHPは、他のクラスで定義されているメソッドでもNoticeやWarningなしで実行できたりする。
</p>
<p>
以下の例だと、クラスBClassに定義されてるメソッドtestFuncを<br />
クラスAClassの中からスタティックメソッドとして実行している。<br />
もちろん、$thisのスコープはAClassのインスタンスとなる。<br />
んで、運悪く、AClassにもBClassにも同じ名前のメソッド<br />
sayHelloなんてものがあると、気づかずに処理が進んでしまったりするわけだ。
</p>
<p>
バリバリＰＨＰやってる人には常識なのかな？<br />
他のクラスのメソッドをコール出来るって時点でかなり違和感。
</p>
<pre>
&lt;?php
//filename: exp001.php
class AClass{
	public function test(){
		BClass::testFunc();
	}
	public function sayHello(){
		echo &quot;Hello, World. I&#039;m a AClass.&quot;;
	}
}
class BClass{
	public function testFunc(){
		echo &quot;-------inside BClass::testFunc-----\n&quot;;
		$this-&gt;sayHello();	echo &quot;\n&quot;;
		echo &quot;------------------------------------\n&quot;;
	}
	public function sayHello(){
		echo &quot;Hello, World. I&#039;m a BClass.&quot;;
	}
}

$test = new AClass();
$test-&gt;test(); 		echo &quot;\n&quot;;

BClass::sayHello(); echo &quot;\n&quot;;
</pre>
<pre>
>php exp001.php
-------inside BClass::testFunc-----
Hello, World. I'm a AClass.
------------------------------------

Hello, World. I'm a BClass.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=569</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=569" />
	</item>
		<item>
		<title>PHP基礎 関数で参照を返す場合の注意</title>
		<link>http://www.matzmtok.com/blog/?p=567</link>
		<comments>http://www.matzmtok.com/blog/?p=567#comments</comments>
		<pubDate>Thu, 27 May 2010 04:26:23 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=567</guid>
		<description><![CDATA[
参照はあくまで変数に対してのみ作られるので、
関数で参照を返すような場合に、returnに変数を渡さないとWarningやNoticeの原因になります。
たとえば、リテラルや式を直接returnの引数に渡すとかするケース。


// 引数に文字リテラルを渡しているので警告が発生。
funciton &#038;returnRef(){
    return "Hello world";
}

//何も返さない場合は、
//return を引数なしで実行して強制的にNULLを返すようにする。
function &#038;returnEmpty(){
  [...]]]></description>
			<content:encoded><![CDATA[<p>
参照はあくまで変数に対してのみ作られるので、<br />
関数で参照を返すような場合に、returnに変数を渡さないとWarningやNoticeの原因になります。<br />
たとえば、リテラルや式を直接returnの引数に渡すとかするケース。
</p>
<pre>
// 引数に文字リテラルを渡しているので警告が発生。
funciton &#038;returnRef(){
    return "Hello world";
}

//何も返さない場合は、
//return を引数なしで実行して強制的にNULLを返すようにする。
function &#038;returnEmpty(){
    echo 'Some process';
    return ; //NULLが返る。
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=567</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=567" />
	</item>
		<item>
		<title>PHPでのUnicodeと正規表現</title>
		<link>http://www.matzmtok.com/blog/?p=557</link>
		<comments>http://www.matzmtok.com/blog/?p=557#comments</comments>
		<pubDate>Tue, 25 May 2010 09:18:28 +0000</pubDate>
		<dc:creator>motoki</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Unicode]]></category>
		<category><![CDATA[文字コード]]></category>
		<category><![CDATA[正規表現]]></category>

		<guid isPermaLink="false">http://www.matzmtok.com/blog/?p=557</guid>
		<description><![CDATA[PHP4.4.0およびPHP5.1.0以降では、UTF-8モードのときに文字タイプにマッチするエスケープシーケンスが３つ追加されています。
このエスケープシーケンスによってUnicodeの文字カテゴリーや文字コード値をつかって文字集合マッチングパターンに指定する事ができます。
指定した文字プロパティとマッチする　\p{xx}
Unicodeにはキャラクタカテゴリーといって、文字の種類によってカテゴリーごとに分類がされています。
$、€、¥はなどの通貨記号はSymbol Currencyカテゴリーに、+や-などの数学に使う記号はMathemati [...]]]></description>
			<content:encoded><![CDATA[<p>PHP4.4.0およびPHP5.1.0以降では、UTF-8モードのときに文字タイプにマッチするエスケープシーケンスが３つ追加されています。<br />
このエスケープシーケンスによってUnicodeの文字カテゴリーや文字コード値をつかって文字集合マッチングパターンに指定する事ができます。</p>
<h2>指定した文字プロパティとマッチする　\p{xx}</h2>
<p>Unicodeにはキャラクタカテゴリーといって、文字の種類によってカテゴリーごとに分類がされています。<br />
$、€、¥はなどの通貨記号はSymbol Currencyカテゴリーに、+や-などの数学に使う記号はMathematical Symbolと言った具合にカテゴリーが割り当てられています。</p>
<p>たとえば、通貨記号にマッチさせたい場合は、<br />
通貨記号が属すカテゴリーSymbol Currencyの文字プロパティ(Sc)をマッチングパターンに指定してやります。</p>
<p>
<pre>
    //例
    preg_match(/\p{Sc}/u, $str);
</pre>
</p>
<p>さらに、\pの後に一文字だけ記述すると、その文字で始まるすべての文字プロパティを指定することもできます。<br />
たとえば、アルファベットを表す文字プロパティLは、Lｌ, Lm, Lo, Lt, Luといった他の文字プロパティをすべて含みます。</p>
<h2>指定した文字プロパティを持たない　\P{xx}</h2>
<p>\p{XX]の否定を\P{XX}と表す。　<br />
例えば大文字のアルファベットLu を含まない文字とマッチは\P{Lu}と表し、これは\p{^Lu}同じ意味になります。</p>
<h2>拡張Unicodeシーケンス（結合文字）とマッチする \X</h2>
<p>\Xは 拡張Unicodeシーケンスを構成するUnicode文字にマッチします。<br />
これは、正規表現 ?>\P{M}\p{M} と等価で、記号を含まない文字\P{M}とそれに続く、０個以上の記号を含む文字\p{M}のアトミックなグループにマッチします。<br />
具体的な例をあげると、「が」を結合文字として表すと「か」(U+304B)＋「゛」(U+3099)というという２つの文字から作られる結合文字としてあらわす事が出来ます。このような結合文字に対して\Xはマッチします。<br />
もちろん、結合済みの「が」(U+304C)も存在します。</p>
<p>http://www.php.net/manual/ja/regexp.reference.unicode.php</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matzmtok.com/blog/?feed=rss2&#038;p=557</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.matzmtok.com/blog/?p=557" />
	</item>
	</channel>
</rss>

