YAPC::EU 2012 第三天
作者:gugod 發佈於: ,更新於:總算是比較涼爽一點了,前兩天的悶熱感,跟台灣的夏天沒兩樣。
這一天主要聽了 Perl6 相關的主題,像是新做的 p6doc 系統,可以直接用與程式中相同的 語法,查訊各內建的類別、方法、函式,算符:
- p6doc %% # 算符
- p6doc &any # 函式
- p6doc Any # 類別
- p6doc Str.flip # 類別方法
這真是十分的方便,比 perldoc 更加方便。目前 p6doc 程式已完成的同時,其文件內容也接繼補齊,並且可以成為許多 Perl6 實做的共用文件。已經有 Web 介面可以查: http://doc.perl6.org 。源碼在 github:perl6/doc
另一方面,由 Stevan Little 主導的 p5-MOP 實做也漸趨完整,與 Moose 十分神似,但 更加簡潔。
mst 的閉幕主講則再次回到「程式語言的興衰成敗」這個主題,曾經風華絕代的 Perl+CGI 組合,曾在 php + mod_php 改朝,又於 Ruby on Rails 換代。每個語言會輪流都有過熱潮, 但真正的價值,是在潮流過後留下來的東西,而不是在流行時所產生的那些垃圾產物。現在 還在說 Perl 程式碼難讀的人,多半只是沒有趕上時代,身在社群的各位一笑置之便行。或 著,展示一下用 Moose / Dancer 寫的程式,讓對方感受到當代 Perl 與 CGI 時代的巨大差 異。無可否認地,目前的 Perl 社群仍在穩定成長長,這便是這個語言與社群強建的證明。
這一天的其他筆記:
- YAPC EU 2012 Day 3
- YAPC EU 2013 will be in Kiev
- Stevan Little - perl5 mop.
- Classes, Methods, Attributes, Intances
- Sufficient MOP with: *{$pkg . '::foo'} = \&bar;
- Class are first-class object, not just a string.
- requires 5.14.2 for it's keyword-injection API.
- single inheritance
- resort to Roles if multiple-inheritance sort of thing is desired.
- with rw accessors (lvalue accessors)
- $self is magic inside a 'method' body block
- positional parameter
- 'has' keyword takes an variable name with sigils
- has $balance ( is => 'ro' ) = 0;
- 'role' keyword:
- classes are no longer packages.
- Exception classes, Fun, Try, etc etc...
- doy. Dependency injection with Bread::Board
- basically you'll always run into the timing that you wish one of your module can be replaced by another for, say, testing purpose.
- Dependency Injection ~= "the inverse of garbage collection" (collection of garbages ? :)
- Like Spoon::Hub, gather a collection of objects (aka "services") (not necessarrily singletons thoguh)
- services can depends on other services
- sort of like malloc, for named objects ?
- duckduckgo
- "Deep spice" -- zci (aka spice) based on the 1st page of search result. (good idea)
- made money out of amazon affiliate program. cool.
- duck duck goose
- Patrick, perl6 doc
- http://www.pmichaud.com/2012/pres/
- p6doc -- written in perl6 and P6Pod
- pretty new (2 month old), fresh blood requried
- Maros command line app
- MooseX::Getopt
- MooseX::App
- Perl6 regex
- The operator:
rx/.../
- Apply:
~~ ~~,
m//
ands///
are still therematch
,comb
,subst
areRx
methods- New operators:
ms//
andss///
:
m:s
//
s:s///
/xms
modifiers are default/e
modifiers are no more. just use{}
in the replacement.:P5 :Perl5
-- modifiers to make Rx perl5-compatible..
still mach any char\N
not a newline^
begin of string . $ end of string^^
begin of line . $$ end of line|
longest match wins||
first match wins[]
non-capturing group<[ ]>
char classes- \s = \h | \v horizontal space, vertical space.
\d ** 5
quantifier (not \d{5}, {} always means code interpolation)\d ** 2..5
(range object)\d ** 2..* % ','
(% is "quantifier modifer") "matches 1,2,3,4"$/
last matched$/<...> $<...>
named captures$()
all the positional captures@() = $0,$1,$2,..
all the positional captures
- The operator:
- mst ending keynote
- we, as a group, are levelled up.
- we have higher expectations
- "Nice problem to have..."
- Sustainable steady inexorable improvement.