gpt4 book ai didi

j - 在J中,后缀 "__"有什么作用?

转载 作者:行者123 更新时间:2023-12-04 10:11:50 25 4
gpt4 key购买 nike

我在 J 中维护一个大型代码库,一些罕见的函数和变量以 __ 结尾(两个下划线)。

通常,__用于引用语言环境中的某些内容。

barObj =: conew 'Bar'
Foo__barObj

但是,我有这个:
Foo__

声明为:
Foo__=: 3 : 0

这是静态函数的另一种语法吗?所有地区都可以访问吗?

编辑:

据我所知,这不是本地的。这样声明的变量:
FooVar__ =.

可以被另一个函数引用,尽管 =.让它看起来很本地化。以同样的方式,任何“进入语言环境”声明总是“全局到语言环境”( Foo__Bar =.Foo__Bar =: 是相同的)。

最佳答案

以双下划线结尾是一种在基本语言环境中引用名称的旧技术。以下是来自 the relevant part of the Locale lab 的详细信息:

A locative with no locale name between the bracketing _ characters is treated as if it had the name base.

abc__ is the same as abc_base_

Treating __ as _base_ is for compatibility with earlier versions, and in general you should use _base_ .

关于j - 在J中,后缀 "__"有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6833217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com