PHP

<?php

class t {
    function __construct() {
        $this->a = $a = array('b' => 10);

        print "${a['b']} \n";
        print "{$this->a['b']} \n";
        print "$this->a['b'] \n";

    }
}
new t();
?>

10
10
Array['b']

${a['b']} という書きかたからすると ${this->a['b']} なかんじがするけどそれだとparse errorになる。

$this->a['b'] は囲まないと $this->a で切れて['b']は文字列として展開されるけどエラーにはならない。でも $a['b'] だとエラーになる。

よくわかんないけど直感的じゃない。

package T;

sub new {
    my $class = shift;
    $class = ref $class if ref $class;
    my $self = bless {}, $class;
    $self;
}

package main;

$t = T->new;
@{$t->{a}} = (1,2,3);
print "$t->{a}[2]\n";


3

perlだとつながりそうなものは全部つながるっぽい。

http://blog.8-p.info/正規表現内での変数展開/メタキャラ扱いがヒューリスティックだっていう話書いてあった気がするけど見つけられず。こんなのばっかり。