何とタイムリーな記事。まつもとさんが「仕様の継承」と「実装の継承」について語っているので勝手にまとめてみる。 まつもとさんがITProに書いた記事がきっかけになったのか、最近 Mixin に関する話題をよく目にする、気がします。 Perl は多重継承をサポートする一方で、Exporter を使った Mixin も可能です。この辺はmiyagawa さんのメールマガジンのバックナンバーに詳しく書いてあります。 Object-Oriented Programming with Perl Vol.29 - Exporter による Mixin Object-Oriented Programming with Perl Vol.30 - Exporter::Lite Exporter で関数を export しつつ、それを import した側で、関数ではなくインスタンスメソッドとしてそれを利用す
Blog Search when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${entry.path} [in template "__entry.ftlh" at line 3, column 25] - Reached through: #include "__entry.ftlh" [in template "entry.ftlh" at
メモ化(英: memoization)とは、プログラムの高速化のための最適化技法の一種であり、サブルーチン呼び出しの結果を後で再利用するために保持し、そのサブルーチン(関数)の呼び出し毎の再計算を防ぐ手法である。メモ化は構文解析などでも使われる(必ずしも高速化のためだけとは限らない)。キャッシュはより広範な用語であり、メモ化はキャッシュの限定的な形態を指す用語である。 メモ化という用語は1968年にドナルド・ミッキーがラテン語の memorandum(覚えておく)から作った造語である[1]。memorization(記憶、暗記)は同根語であってよく似ているが、メモ化という言葉は情報工学では特別な意味を持つ。 メモ化された関数は、以前の呼び出しの際の結果をそのときの引数と共に記憶しておき、後で同じ引数で呼び出されたとき、計算せずにその格納されている結果を返す。メモ化可能な関数は参照透過性を備
NAME Class::Data::Accessor - Inheritable, overridable class and instance data accessor creation SYNOPSIS package Stuff; use base qw(Class::Data::Accessor); # Set up DataFile as inheritable class data. Stuff->mk_classaccessor('DataFile'); # Declare the location of the data file for this class. Stuff->DataFile('/etc/stuff/data'); # Or, all in one shot: Stuff->mk_classaccessor(DataFile => '/etc/stuff
Ruby界隈ではあたりまえのように使われる特異メソッド*1だが,Perlでは組み込みでのサポートはなく,標準モジュールにも特異メソッドを実現するものはない。Class::MOP/Mooseの匿名クラスが似た用途を持っている*2が,オブジェクトの実装型に制約がある。たとえば,以下のコードは動かない。 #!perl -w use strict; use IO::File (); use Moose (); my $anonclass = Moose::Meta::Class->create_anon_class( superclasses => [qw(IO::File)], methods => { hello => sub{ my $self = shift; $self->print("Hello, world!\n"); }, } ); my $io = $anonclass->new
NAME Class::Contract - Design-by-Contract OO in Perl. VERSION This document describes version 1.10 of Class::Contract, released February 9, 2001. SYNOPSIS package ClassName use Class::Contract; contract { inherits 'BaseClass'; invar { ... }; attr 'data1'; attr 'data2' => HASH; class attr 'shared' => SCALAR; ctor 'new'; method 'methodname'; pre { ... }; failmsg 'Error message'; post { ... }; failms
名前¶ perltoot - トムによるPerlオブジェクト指向チュートリアル 概要¶ Object-oriented programming is a big seller these days. Some managers would rather have objects than sliced bread. Why is that? What's so special about an object? Just what is an object anyway? オブジェクト指向プログラミングは、昨今の、ビッグセラーです。 マネージャーには、薄切りパン(訳註:良い発明のこと)よりもむしろオブジェクトを持ちたがる人もいます。 どうしてでしょうか? オブジェクトの、何がそんなに特別なんでしょうか? そもそも、オブジェクトとは一体なんでしょうか? An object is nothing
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く