关于“取消引用"的术语问题? [英] Terminology question on "dereferencing"?
问题描述
在PHP中,以下代码有效
In PHP, the following code is valid
$a=array(0);$a[0];
但是那个无效:
array(0)[0]
- 与该行为对应的术语是什么? (与取消引用"有关吗?)
- 这种行为背后的动机是什么(除了用户恶意:-P之外)
我正在寻找通用术语,不一定是与PHP相关的术语.
I am looking for the general terminology, not necessarily the terminology associated with PHP.
(其他示例:在MATLAB中,以下有效:
(Other example: in MATLAB, the following is valid:
s = size(M)
s(0)
但这是无效的:
size(M)(0)
在PHP和MATLAB中,添加括号都无济于事,即(array(0))[0]
和(size(M))(0)
均无效)
In both PHP and MATLAB, adding parenthesis does not help, i.e., (array(0))[0]
and (size(M))(0)
are both invalid)
推荐答案
这称为数组取消引用,并将在 PHP 5.4 (目前是在Alpha中)
注意(感谢Gordon):即使在PHP 5.4中,使用array()
1 所要求的也是不可能的-但它是'将对功能起作用.
Note (thanks Gordon) : what you are asking for, with array()
1, is not possible even in PHP 5.4 -- but it'll work for functions.
几个来源:
A couple of sources :
- RFC-函数数组取消引用
- PHP主干中的功能:数组解引用,当不确定是否会有PHP 5.4或PHP 6
- 最后但并非最不重要的是 php.net上的(当前最后)新闻 : PHP 5.4 alpha1已发布
- RFC - Function Array Dereferencing
- Features in PHP trunk: Array dereferencing, when it was unsure whether there would be a PHP 5.4 or a PHP 6
- And, last but not least, the (currently last) news on php.net : PHP 5.4 alpha1 released
引用最新消息:
Quoting that last news :
以下是更改的不完整列表:
-已添加:特质语言 构造
-添加:数组取消引用支持
-添加: DTrace支持
-改进:改进了Zend Engine的内存使用情况并 性能
-移至:ext/sqlite移至pecl(sqlite3支持为 还是内置的)
Here is an incomplete list of changes:
- Added: Traits language construct
- Added: Array dereferencing support
- Added: DTrace support
- Improved: Improved Zend Engine memory usage and performance
- Moved: ext/sqlite moved to pecl (sqlite3 support is still built-in)
1. array()
即使看起来像一个函数,a>也不是一个函数-实际上,这就是PHP所谓的语言构造;那些行为不像函数.
这篇关于关于“取消引用"的术语问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!