翻訳と辞書
Words near each other
・ AutoUncle
・ Autour d'une cabine
・ Autour de la Lune
・ Autour de Lucie
・ Autour de Lucie (album)
・ Autovampirism
・ Autovent
・ Autovia
・ Autovia B-24
・ Autovia C-12
・ Autovia C-13
・ Autovia C-14
・ Autovia C-35
・ Autovia C-60
・ Autovia C-65
Autovivification
・ Autovon
・ Autovía
・ Autovía A-1
・ Autovía A-10
・ Autovía A-11
・ Autovía A-12
・ Autovía A-138
・ Autovía A-15
・ Autovía A-19
・ Autovía A-2
・ Autovía A-21
・ Autovía A-22
・ Autovía A-23
・ Autovía A-231


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Autovivification : ウィキペディア英語版
Autovivification

In the Perl programming language, autovivification is the automatic creation of new arrays and hashes as required every time an undefined value is dereferenced. Perl autovivification allows a programmer to refer to a structured variable, and arbitrary sub-elements of that structured variable, without expressly declaring the existence of the variable and its complete structure beforehand.
In contrast, other programming languages either: 1) require a programmer to expressly declare an entire variable structure before using or referring to any part of it; or 2) require a programmer to declare a part of a variable structure before referring to any part of it; or 3) create an assignment to a part of a variable before referring, assigning to or composing an expression that refers to any part of it.
Perl autovivication can be contrasted against languages such as Python, PHP, Ruby, and many of the C style languages, where dereferencing null or undefined values is not generally permitted.〔For example, Python raises an TypeError if None.__getitem__ is called. Dereferencing a null pointer in C results in undefined behavior; many C implementations choose to raise a segmentation fault.〕 It can be compared to the HTML standard's "named access on the window object"〔http://www.whatwg.org/specs/web-apps/current-work/#named-access-on-the-window-object〕 which results in corresponding globally scoped variables being automatically accessible to browser-based JavaScript.
==Hashes==
It is important to remember that autovivification happens when an undefined value is dereferenced. An assignment is not necessary. The debugger session below illustrates autovivification of a hash just from examining it:

DB<1> x \%h
0 HASH(0x2f1a248)
empty hash
DB<2> x $h
0 undef
DB<3> x \%h
0 HASH(0x2f1a248)
1 => HASH(0x2f1a260)
2 => HASH(0x29a3c68)
3 => HASH(0x2dc3038)
empty hash
DB<4>

The debugger session below illustrates autovivification of a hash from assigning to an inner hash:

DB<1> $h=1
DB<2> x \%h
0 HASH(0x83c71ac)
'A' => HASH(0x837d50c)
'B' => HASH(0x83c71e8)
'C' => HASH(0x83c7218)
'D' => 1
DB<3>

Hashes several layers deep were created automatically without any declarations. Autovivification can prevent excessive typing. If Perl did not support autovivification, the structure above would have to be created as follows:

DB<1> %h = (A => )
DB<2> x \%h
0 HASH(0x83caba4)
'A' => HASH(0x83cfc28)
'B' => HASH(0x83cab74)
'C' => HASH(0x83b6110)
'D' => 1
DB<3>


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Autovivification」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.