Hokkaido.pm#11

7a8922191c1fa60728589a3def4c179f?s=47 akiym
December 28, 2013

 Hokkaido.pm#11

Cocoa module, perl-5.19

7a8922191c1fa60728589a3def4c179f?s=128

akiym

December 28, 2013
Tweet

Transcript

  1. ࠓ೥ॻ͍ͨ 1FSMͷίʔυͷৼΓฦΓ )PLLBJEPQN !BLJZN

  2. NF w !BLJZN w  w TFDDBNQ ZBQDBTJB w 4&$$0/ࡳຈେձ༏উ

  3. DUGLBUTVEPOPSH

  4. $1"/HJUIVC

  5. $1"/ w "OZ&WFOU4,,4FSW w $PDPB/FUXPSL$IBOHF w 3FHFYQ7FSCBM&YQSFTTJPOT

  6. $1"/ w "OZ&WFOU4,,4FSW w $PDPB/FUXPSL$IBOHF w 3FHFYQ7FSCBM&YQSFTTJPOT

  7. None
  8. ϑλΛดͯ͡ˠ։͘ͷ8J'JͷεΠονΛ ར༻ͯ͠ࠂന͞ΕΔ

  9. 

  10. (JUIVC w .BD,FZCPBSE-&%  $PDPB%JDUJPOBSZ4FSWJDFT Q6OB[V$IBO  $PDPB(VJ5FTU "OZ&WFOU-FBQ.PUJPO 

    "NPO8FC%JTQBUDIFS%7  5FYU1JDP5FNQMBUF  888'$7JEFP%PXOMPBE  (BNFT1JDSPTT 5FYU$IJOFTF/VNFSBMT+"  *SPI
  11. લճͷ)PLLBJEPQN Ͱ࿩͠·ͨ͠

  12. None
  13. 

  14. $PDPBNPEVMF

  15. w ͳͥ$PDPBϞδϡʔϧΛॻ͘ͷ͔ʁ w $PDPB"1*Λ৮Γ͍͔ͨΒ w 1FSMͰ.BDΞϓϦ͡Όͳͯ͘ɺ.BDͷػೳʹ ΞΫηε͍͚ͨͩͩ͠͠ɺ୯ମϞδϡʔϧʹ͠ ͍ͯͬͨ΄͏͕ΈΜͳ͕޾ͤ w ͱUZQFTUFS͞Μ͕ݴ͍ͬͯͨ

    BHSFF
  16. $PDPBNPEVMFͷ ࡞Γํ

  17. w ࠷ۙ w 946#Ͱॻ͚ΔΑ͏ʹͳͬͨͷͰ௒ઈศར w ֵ໋ w $PDPB(SPXM΍$PDPB4LZQF͸໘౗ͳ͜ͱΛ ͍ͯ͠Δ w

    YTVCQQ͕ੜ੒͢ΔDΛखͰॻ͘Α͏ͳ͜ͱ
  18. NJOJMOFX w .JOJMMBͰ࡞੒͢Δ w ANJOJMOFXQ94.PEVMFA w CVJMEFS.Z#VJMEFSQNΛ࡞੒ w IUUQTPIIBUFOBCMPHDPNFOUSZ 

  19. CVJMEFS.Z#VJMEFSQN package builder::MyBuilder; use strict; use warnings; use parent qw(Module::Build);

    use File::Copy; ! sub new { my ($self, %args) = @_; $self->SUPER::new( %args, extra_compiler_flags => ['-Wall'], extra_linker_flags => ['-framework', 'Foundation'], ); } GSBNFXPSLͷϦϯΫ
  20. CVJMEFS.Z#VJMEFSQN sub compile_c { my ($self, $file, %args) = @_;

    ! (my $m_file = $file) =~ s/\.c$/.m/; move($file, $m_file) or die $!; ! $self->SUPER::compile_c($m_file, %args); } ! 1;
  21. NJOJMUPNM [build] build_class = "builder::MyBuilder"

  22. w YTʹΰϦΰϦͱॻ͍͍ͯ͘ w NBLF͢ΔͱN͕ੜ੒͞ΕΔ w HJUJHOPSFʹlib/Foo.mͷΑ͏ʹ௥Ճ͓ͯ͘͠

  23. w ී௨ͷ94ͱಉ͡Α͏ʹॻ͚·͢ w $PDPBˠ1FSM 1FSMˠ$PDPBͷσʔλͷม׵ ʹؾΛ͚ͭΕ͹͍͍͚ͩͰ͢ w ͦΕҎ֎͸ͨͩͷ94 w Ͳ͏΍Ε͹͍͍Μͩʜͱ͍͏ͱ͖ʹ͸

    w UZQFTUFS͞Μ΍TPI͞ΜͷSFQPTJUPSZΛ
 ࢀߟʹ͢Δ
  24. σʔλͷม׵ w IUUQXXXTMJEFTIBSFOFUUZQFTUFSIBDLJOHNBDPTYDPDPBBQJGSPN QFSM w IUUQTHJUIVCDPNTPI$PDPB/4%JTUSJCVUFE/PUJpDBUJPO$FOUFS CMPCNBTUFSOT@EJTUSJCVUFE@OPUJpDBUJPO@DFOUFSN • nsnumber_to_sv(), ns_to_sv()

  25. σʔλͷม׵ # e.g. NSString → SVPV ! SV* sv =

    sv_2mortal(newSV(0)); sv_setpv(sv, [str UTF8String]);
  26. Ͱ

  27. .BD,FZCPBSE-&% w ͱ͍͏ϞδϡʔϧΛ࡞Γ·ͨ͠ w IUUQHPPHMFNBDCMPHTQPUKQ NBOJQVMBUJOHLFZCPBSEMFETUISPVHIIUNM w ͜ΕΛͦͷ··࣋ͬͯ͘Δ͜ͱʹ w ͳͷͰɺઆ໌͢Δ͜ͱ͕͋Γ·ͤΜ

  28. HJUIVCDPNBLJZN.BD,FZCPBSE-&%

  29. JTTVF w .JOJMMBͰ%FWFM"TTFSU04తͳ͜ͱΛ͍ͨ͠ w CVJMEFS.Z#VJMEFSQNIBDL • die 'OS unsupported' unless

    ($^O eq 'darwin');
  30. 

  31. QFSM

  32. MBUFTUSFMFBTF QFSM

  33. QFSMEFMUBΛோΊΔ

  34. IBTITMJDFTZOUBY w %hash{…} %array[...] w LFZWBMVF JOEFYWBMVF ͷϦετΛฦ͠·͢ w ͍͚ͯΔ

  35. IBTITMJDFTZOUBY my %h = ( blonk => 2, foo =>

    3, squink => 5, bar => 8, ); my %subset = %h{qw/foo bar/}; # => (foo => 3, bar => 8)
  36. IBTITMJDFTZOUBY my @a = "a".."z"; my @list = %a[3,4,6]; #

    => (3, "d", 4, "e", 6, "g")
  37. QPTUpYEFSFGFSFODJOH w ޙஔσϦϑΝϨϯε w !BˠB!  w ෳࡶͳσʔλߏ଄Λૢ࡞͢Δͱ͖ʹศར w TMJDFͱ૊Έ߹ΘͤΔ͜ͱ͕Ͱ͖Δ

  38. QPTUpYEFSFGFSFODJOH no warnings 'experimental::postderef'; use feature qw/postderef/; ! my $r

    = [1, 2, 3]; my @a = @$r; my @b = $r->@*;
  39. σʔλߏ଄ my $foo = { bar => { baz =>

    { a => 1, b => 2, c => 3, } } }; !
  40. σʔλߏ଄ my $foo = { bar => { baz =>

    { a => 1, b => 2, c => 3, } } }; ! my @ab = @{$foo->{bar}{baz}}{qw/a b/}; # => [1, 2] ஍ࠈͬΆ͍
  41. σʔλߏ଄ my $foo = { bar => { baz =>

    { a => 1, b => 2, c => 3, } } }; ! my @ab = $foo->{bar}{baz}->@{qw/a b/}; # => [1, 2]
  42. :PV5VCF%BUB"1* $VAR1 = { 'fmt' => '36', 'fmt_list' => [

    '36', '18', '5', '43', '17' ], 'resolution' => '320x240', 'suffix' => 'flv', 'title' => 'HE-MAN HEYEAYEA SONG FOR 10 HOURS', 'user' => undef, 'video_id' => 'eh7lp9umG2I', 'video_url' => ..., 'video_url_map' => { '17' => { 'fmt' => '17', 'resolution' => '176x144', 'suffix' => '3gp', 'url' => ... }, '18' => { 'fmt' => '18', 'resolution' => '320x240',
  43. ࠓ·Ͱ # video_url_mapから各フォーマットのデータを # ひっぱってくる ! my @data = @{$data->{video_url_map}}{@{$data->{fmt_list}}};

  44. # video_url_mapから各フォーマットのデータを # ひっぱってくる ! my @data = @{$data->{video_url_map}}{@{$data->{fmt_list}}}; ࠓ·Ͱ

  45. QPTUEFSFG # video_url_mapから各フォーマットのデータを # ひっぱってくる ! my @data = $data->{video_url_map}->@{$data->{fmt_list}->@*};

  46. w QSPUPUZQFBUUSJCVUF w sub foo($$){}ˠsub foo : prototype($$){} w Perl

    5.19.2から $!が decodeされる w http://d.hatena.ne.jp/syohex/ 20131227/1388149250
  47. 1FSM2VJ[

  48. ͜ͷίʔυ͸ಈ͘ʁ # メモリは十分にあるとする # perl-5.18.1 (64bit) ! my @a; $a[2**31]

    = 1; ! # =>
  49. ͜ͷίʔυ͸ಈ͘ʁ # メモリは十分にあるとする # perl-5.18.1 (64bit) ! my @a; $a[2**31]

    = 1; ! # => Modification of non-creatable array value attempted, subscript -2147483648 ಈ͔ͳ͍
  50. QFSMҎ߱ͳΒ my @a; $a[2**31] = 1; ! # On 64-bit

    platforms, the internal array functions now use 64-bit offsets, allowing Perl arrays to hold more than 2**31 elements, if you have the memory available.
  51. EFQSFDBUJPOT w $(*QN   w ΍ͬͱ ɾТɾʆ

  52. w .PEVMF1MVHHBCMF w 0CKFDU"DDFTTPS w 1PE-B5F9 w 5FSN6* w 5FYU4PVOEFY

    SFNPWFENPEVMFT w "SDIJWF&YUSBDU w #-JOU w $1"/1-64 w 'JMF$IFDL5SFF w -PH.FTTBHF
  53. ·ͱΊ w ͪΐͬͱͨ͠$PDPBNPEVMFͷ࡞Γํ w QFSM w IBTITMJDFTZOUBY QPTUpYEFSFGFSFODJOH