关于“取消引用"的术语问题? [英] Terminology question on "dereferencing"?

查看:103
本文介绍了关于“取消引用"的术语问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中,以下代码有效

In PHP, the following code is valid

$a=array(0);$a[0];

但是那个无效:

array(0)[0]

  1. 与该行为对应的术语是什么? (与取消引用"有关吗?)
  2. 这种行为背后的动机是什么(除了用户恶意:-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 - 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() 也不是一个函数-实际上,这就是PHP所谓的语言构造;那些行为不像函数.

这篇关于关于“取消引用"的术语问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆