我应该使用 Internals::SvREADONLY 在 Perl 中创建只读变量吗? [英] Should I use Internals::SvREADONLY for creating readonly variables in Perl?

查看:86
本文介绍了我应该使用 Internals::SvREADONLY 在 Perl 中创建只读变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看 Const::Fast 源 我注意到它在内部使用了内置函数 Internals::SvREADONLY.在我的 Perl 脚本中直接使用该函数是否安全?它似乎存在于 Perl 5.8 的核心中.

Looking into the Const::Fast source I noticed that it used the built-in function Internals::SvREADONLY internally. Is it safe to use that function directly in my Perl script? It seems to be present in core from Perl 5.8.

my $PI = 4 * atan2 1, 1;
Internals::SvREADONLY($PI => 1);
$PI = 2.718;   # Modification of a read-only value attempted at ..

推荐答案

C:\>perldoc Internals
No documentation found for "Internals".

没有

更具体地说,包被命名为内部"是有原因的.它不适合在核心之外使用.如有更改,恕不另行通知.

More specifically, the package is named "Internals" for a reason. It is not intended for use outside the core. It could change without notice.

这篇关于我应该使用 Internals::SvREADONLY 在 Perl 中创建只读变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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