命名转换函数

wai*_*933 5 language-agnostic naming-conventions

哪种转换命名约定是大多数语言的标准?

convert_from_typea_to_typeb(arg)
Run Code Online (Sandbox Code Playgroud)

或者

convert_to_typeb_from_typea(arg)
Run Code Online (Sandbox Code Playgroud)

或者还有其他标准吗?

Eik*_*iko 0

我猜想在 C(++) 中你会使用强制转换运算符来完成此操作,因此这些名称都不适合。

在 Objective-C 中,我见过类似 NSPointFromCGPoint(...) 的东西,或者你可以简单地在构造函数中给出旧类型。

我唯一很少看到的那些带有convert_x_to_y的函数:-)