タグ

closureに関するh6nのブックマーク (10)

  • [JavaScript] 猿でもわかるクロージャ超入門 まとめ - DQNEO起業日記

    クロージャとは クロージャは、言葉で説明するのが大変難しい概念です。 あなたは、自転車の乗り方を、口だけで説明できるでしょうか? あなたは、螺旋(らせん)の形を、言葉だけで説明できるでしょうか? ずばり、できないでしょう。 しかし、自転車に乗ることはできますし、針金で螺旋の形を作ることはできるでしょう。 「クロージャ」もこれと同じです。 だから、Wikipediaのこんな解説を見ても落ち込まないでください。 クロージャ (クロージャー、Closure) は、プログラミング言語において引数以外の変数を実行時の環境ではなく、自身が定義された環境(静的スコープ)において解決する関数のことである。 理解できないですよね? 私もそうでした。 クロージャを既に知っている人にしか、この文章は理解できないでしょう。 クロージャを作るのは難しくない しかし、説明するのは難しくても、作るのは意外と簡単。それが

    [JavaScript] 猿でもわかるクロージャ超入門 まとめ - DQNEO起業日記
  • 静的スコープ - Wikipedia

    静的スコープ(せいてきスコープ、英: static scope)とは、プログラミング言語におけるスコープの一種。字句のみから決定できるため、字句スコープまたはレキシカルスコープ (lexical scope) ともいう[1]。 概要[編集] まず、一般的なローカル変数のスコープについて考える。 ブロックなどの構造を持つプログラミング言語では、あるブロックの内側のローカル変数は、そのブロックの外側からは「見えない」というものが多い。ただし、以前のJavaScript (ECMAScript) のように、サポートされるのは関数内ローカルのみで、ブロックローカルというスコープは無いものもある[2]。 疑似コードによる例を挙げる。 A { var x; } B { var x; // A内のxとは別物 var f; C { var y; // Cの内側からしか見えない y = rand(); f

  • 10. i クロージャとオブジェクト | Schemeへの道

    関数体の定義とそれを評価するための環境を合わせてクロージャと呼ぶ. クロージャの概念を用いれば,オブジェクト指向プログラミングの基要素であるオブジェクトを作成することができる. オブジェクトとは,簡単に言えば,メンバ変数(フィールド)といわれるデータとそれを操作するためのメンバ関数(メソッド)をまとめた部品のようなものである. 各フィールドのスコープはオブジェクト内に局所化され,それらにアクセスするためには必ずメソッドを用いることになる. つまりオブジェクト内部のデータは予め指定された方法でのみ操作され,プログラムの他の部分から予期せぬ形で影響を受けることがない. こうすることによって,オブジェクトの内部構造がブラックボックス化され,オブジェクトを,ある機能を提供するプログラムの抽象的な部品として,その詳細な実現方法に左右されることなく利用することができるようになる. ここでは環境モデ

  • クロージャとは コンピュータの人気・最新記事を集めました - はてな

    例 以下のようなコードを考える(文法はJavaScript) function makeCounter () { var count = 0; return f; function f () { return count++; } } var count = 10; var counter = makeCounter(); document.writeln(counter()); document.writeln(counter()); document.writeln(counter()); document.writeln(counter());クロージャである(静的スコープ)とき、出力はこのようになる。 0 1 2 3クロージャでない(動的スコープ)とき、出力はこのようになる。 10 11 12 13

    クロージャとは コンピュータの人気・最新記事を集めました - はてな
    h6n
    h6n 2012/04/05
  • "my'' and "local'' of Perl

    Perl における局所変数 ``my'' と ``local'' の違い Perl4 までは、サブルーチンの中だけで使うような、いわゆる「局所変数」は、 ``local'' で宣言していましたが、 Perl5 では、新たに ``my'' というものが使えるようになりました。 それでは、 ``local'' と ``my'' の違いは何なのかというのが、ここでの話題です。 目次 ``my'' って何や? Perl5 では ``my'' を使おう 局所変数とは? ``my'' と ``local'' の使い方 静的スコープと動的スコープ ``local'' にできて ``my'' にできないこと ``my'' って何や? 日のみなさんは、中学校で英語を習った時、 「あいまいみーまいん」だとか唱えてたと思いますが、 Perl の ``my'' は、その ``my'' です。 つまり、変数を `

  • CoffeeScript/Google Closure Demo

  • GitHub - bolinfest/coffee-script: Unfancy JavaScript

    = { } } { { { } } } }{ { { }{ } } _____ __ __ ( }{ }{ { ) / ____| / _|/ _| .- { { } { }} -. | | ___ | |_| |_ ___ ___ ( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \ |`-..________ ..-'| | |___| (_) | | | || __/ __/ | | \_____\___/|_| |_| \___|\___| | ;--. | (__ \ _____ _ _ | | ) ) / ____| (_) | | | |/ / | (___ ___ _ __ _ _ __ | |_ | ( / \___ \ / __| '__| | '_ \| __| | |/ ____) | (__| | | | |_) | |_ | |

    GitHub - bolinfest/coffee-script: Unfancy JavaScript
  • CoffeeScript/Google Closure Features

    The JavaScript generated by CoffeeScript works perfectly fine, but it is not written in a way that can reap the full benefits of the Closure Compiler. The demo illustrates how an optional Closure Mode yields JavaScript that can be compiled effectively using the Advanced mode of the Closure Compiler. Supporting Closure Mode requires some small amendments to the CoffeeScript grammar, as discussed in

  • Closure Inspector Guide - Closure Compiler - Google Code

    Documentation Closure Compiler Service UI Getting Started Closure Compiler Service API Getting Started Tutorials Communicating with the API Compressing Files with the API API Reference Closure Compiler Application Getting Started Closure Inspector Guide Closure Inspector is an extension to Firebug, the Firefox debugger extension. Closure Inspector adds three powerful features to Firebug: source ma

  • What's a Closure?

    Ever wondered what closures where and how they worked? You can learn about this advanced computer science concept right now through interactive lessons in JavaScript. Let's get started! Here is an example of some JavaScript code. Doesn't it look pretty? var f = function (x) { return x + 1; } Don't worry, we're not just going to sit around and look at pretty code. We're going to be writing code! Va

  • 1