ColdFusion 对象是按引用传递还是按值传递?

发布于 2024-07-06 19:57:29 字数 95 浏览 9 评论 0原文

ColdFusion 对象(即通过 cfobject 调用的 CFC)通常是按引用传递还是按值传递(复制到内存中)? 是否可以强制 ColdFusion 以任一方式传递对象?

Are ColdFusion objects (i.e. CFCs invoked via cfobject) normally passed by reference or by value (copied in memory)? And is it possible to force ColdFusion to pass an object in either manner?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

明天过后 2024-07-13 19:57:29

ColdFusion 对象通过引用传递。 确实没有一种方法可以按值传递对象,但您可以使用duplicate() 函数创建一个副本。

ColdFusion objects are passed by reference. There's not really a way to pass an object by value, but you can create a copy using the duplicate() function.

恋竹姑娘 2024-07-13 19:57:29

Well, keep in mind that using duplicate() doesn't work in MX 7 for copying certain things, like CFCs and COM, CORBA, and Java objects. You can copy a CFC in CF 8, though.

顾冷 2024-07-13 19:57:29

结构和 CFC 等复杂对象是通过引用传递的,但如果将数组传递给 UDF,则它是通过值传递的。 这使得不可能编写像内置数组函数那样改变数组的用户定义函数。 如果确实需要通过引用传递数组,可以将其包装在结构体中,然后它将通过引用传递。

Complex objects such as structs and CFCs are passed by reference, but if you pass an array to a UDF it is passed by value. This makes it impossible to write a user defined function that mutates an array like the built-in array functions do. If you really need to pass an array by reference, you can wrap it in a struct, and then it will be passed by reference.

凉月流沐 2024-07-13 19:57:29

FWIW,数组也在 Railo CFML 引擎中通过引用传递,正如许多开发人员认为的那样。 Railo 3.1 预计还将提供管理设置,允许您选择默认行为,以实现与 Adob​​e CF 的可选兼容性。

FWIW, arrays are also passed by reference in the Railo CFML engine, as many developers believe they should. Railo 3.1 is also expected to offer an administrative setting to allow you to choose the default behavior, for optional compatibility with Adobe CF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文