�����ȥ�ɤ�����Ȥ����顢�ⶶ����˰�ɼ��
Matz�ˤä�(2007-02-05)�ⶶ(Maki)����ˤ��:=���ڥ졼���ؤ�ȿ�аո����פäƤ�����⤺�äȤ��äȿ�����û����
��:=�פ�ɤ������Ȥ��˻Ȥ��Ф�������������Τ��񤷤������ä˽鿴�Ԥˡ�
�ޤ���Ruby�Υ��������ѿ��Υ������פ����˵����Ĥ�����[���Ѽ���:Larry Wall]�Ϥ�äѤ�ȤƤ�Ԥ��ͤ��Ȼפ��ޤ�
��ˤȤäƤ⡢Ruby�Υ������ץ롼��ϰ��ְ��´�������Ȥ����Ǥ��ơ�
�㤨�С��ʲ��Υ����ɤϡ�
foo = 1 loop do puts foo foo = 2 puts foo break end puts foo
1,2,2�Ƚ��Ϥ��ޤ������ʲ���Perl Code��1,2,1�Ǥ���
$\="\n"; # so print does puts our $foo = 1; { print $foo; my $foo = 2; print $foo; } print $foo;
JavaScript�Ϥޤ��ü�Ǥ��ơ�var������줿�ѿ���lexical scope����¦����ϸ����ޤ���
// double-click to execute var foo = 1; (function(){ alert(foo); // undefined var foo = 2; alert(foo); // 2 })(); alert(foo); // 1
��äƸ�̩�ˤ�function local�Ȥ����ޤ���
�ä�Ruby���ᤷ�ޤ�����������ʤ�ޤ������ΤǤ�����Perl��$scalar
,@array
,%hash
,&subroutine
,*typeglob
�ȷ��ΰ㤤�ò¼¨¤ï¿½ï¿½Î¤Ë»È¤Ã¤Æ¤ï¿½ï¿½ëµï¿½ï¿½(Perl���sigil)����local
,$global
,@instance
,@class
�ȥ������פΰ㤤�˻Ȥ��Ƥ���Ȥ������̿��餦�Ȥ����Ǥ�����äȤ�Perl 6�Ǥϡ�twigil�Ȥ��äơ�$*ARGS
, &?BLOCK
, �Ȥ������ˡ������ܤε�����ü��ѿ�����̤���褦�ˤʤäƤ���ΤǤ���ä�RubyŪ�ˤʤäƤ��ޤ���������Ǥ�$.instance
�Τ褦�ˡ����Ӥ�ľ��Ū�ˤ狼�ëµï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ò¤·¤Æ¤ï¿½ï¿½Þ¤ï¿½ï¿½ï¿½ï¿½Þ¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ó¤±¤ï¿½æ¤¨ï¿½ï¿½ï¿½ï¿½ï¿½Ê¤Î¤Ç¤ï¿½ï¿½ï¿½ï¿½ï¿½
�ǡ�:=
�Ǥ���Matz�ƤǤ�
foo = 1 loop do puts foo foo := 2 puts foo break end puts foo
�Ȥ����1,2,1�Ƚ��Ϥ���롢���ʤ��:=
�����������ѿ��ϡ�Perl��my�ѿ���Ʊ�������ˤʤ롢�Ȥ������Ȥ����ꤷ�Ƥ���ΤǤ��礦��?���ä�ή�줫�餹��Ȥɤ��⤽�Τ褦�ʤΤǤ������ʲ����������Ȥ����ä�ʤ�ޤ���
���졢���¤ò¤µ¤ï¿½Ë¿ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½Ë¤Ê¤ï¿½È»×¤ï¿½ï¿½Þ¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½×¤òµ¹ï¿½ï¿½ï¿½Ú¤ï¿½ï¿½Ø¤ï¿½ï¿½ï¿½Î¤Ç¤â¤¹ï¿½Ç¤Ë°ï¿½ï¿½Â´ï¿½ï¿½ç¤ï¿½ï¿½ï¿½Î¤Ë¡ï¿½ï¿½ï¿½ï¿½Ù¤Ï±é»»ï¿½Ò¤È¤Ê¤ï¿½ï¿½...Perl����my��ѥ���ʤ�JavaScript����var��ѥ���ʤꤷ������ RSL (Ruby as Second Language) �Υ桼�����ˤ䤵�����Ȼפ��ޤ���
����ˡ�Perl 6��:=
��binding operator�Ȥ��ƻȤ��Ƥ��뤳�Ȥ⤢��ޤ����פ��ѿ�����̾����黻�Ҥǡ��㤨�аʲ��Υ����ɤ�1,2�Ƚ��Ϥ��ޤ���
my $a = 1; my $b := $a; say $b; $a = 2; say $b;
�ޤ��������ä���Pascal�Ǥ�:=
�������Ǥ������̤θ�������黻�Ҥ��̤ΰ�̣�����äƤ⤤���Ǥ��������饹����˴餬���ä��äƷݽѤ���ȯ���Ƥ��뤫�餤���ΤǤ���(�ʤ�Τ��ä���)��the principle of least surprise����Ԥ��ȡ�too surprising�ʤΤǤϤʤ��Ǥ��礦����
....�ԤƤ衢
|foo| = 1
�Ȥ����ΤϤ������Ǥ��礦?����������гμ¤�block local��iterator variable�Ȥ�����������ޤ�����foo := 1
����Rubyish�˸����ޤ���|foo|
�Ȥ����Τϰ���ruby�餷��construct�Ǥ������������ȥ�������������Ȥ����ո��⤢��ޤ�����
|foo, bar, baz| = 1, 2, 3
�Ȥ��Ф���ⵤ�ˤʤ�ʤ��Ǥ��礦��
Dan the Broken Ruby Speaker
foo <- 1
local({
cat(foo,"\n")
foo <- 2
cat(foo,"\n")
})
cat(foo,"\n")
�ʤ� 121
foo <-1
repeat{
cat(foo,"\n")
foo <- 2
cat(foo,"\n")
break
}
cat(foo,"\n")
�ʤ� 122
local��function��̵̾�Ķ�����ޤ�
�֥��å���Υ������פϵ������衣
�ΤΥ��󥿥ץ꥿��̾��?��":="�λij������äơ�
":=" <- function (x, value)
{
assign(deparse(substitute(x)), value, envir = parent.env(environment()))
}
hoge := runif(100) * 1000
������Ȥ���
Ǥ�դα黻�Ҥ������ %�Ƕ����
> "%(^_^)%"<-function(x,value){x+value}
> 1 %(^_^)% 2
[1] 3
���Ȳ��Ǥ⤢��...