什么=> (等于大于)意味着在Fortran中? [英] What does => (equals greater than) mean in Fortran?

查看:655
本文介绍了什么=> (等于大于)意味着在Fortran中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览一些旧的Fortran 90代码,并且遇到了 => 符号:

  var => item 

它看起来像是用于某种分配。



在Google搜索arrow符号Fortran等于大于符号Fortran 时,不会提供相关材料。

$ b $令人惊讶的是,搜索等于箭头符号Fortran会产生一些结果。

=>通常被称为 指针赋值运算符

(虽然它不是< a href =https://stackoverflow.com/a/31887568/3745896>确实是一个操作符,因为它没有返回任何值。)



它是用于将选定的参考名称与目标相关联

 参考=>目标

以上可读为reference target / p>

大多数情况下,这种引用以指针。在这种情况下,您可以说参考指向目标。这是一个有用的方法来记住这个操作符的作用,因为它的文字外观是一个从引用到目标的箭头。

其他用途 <
其他用途包括为诸如模块组件,过程甚至任意表达式等各种项目制作本地别名。有关所有这些用途的完整说明,请参阅此答案



<指针赋值与传统赋值(=)

下面是上述链接中的一个简单示例,说明指针赋值与经典赋值(=< /强>)。基本上,这表明一旦目标已经建立,指针就被视为基本语句的目标。

  pt => X ! pt指向x 

y = pt! y等于x

pt =>你好! pt指向y

pt = 17! y等于17

其他资源:

关于Fortran指针的一般文档


I'm looking through some old Fortran 90 code and have come across the => symbol:

var => item

It looks like it's being used for some sort of assignment.

Searching Google for "arrow symbol Fortran" or "equals greater than symbol Fortran" gives me no related material.

解决方案

Surprisingly, searching "equals arrow symbol Fortran" yields some results.

"=>" is commonly referred to as the pointer assignment operator.
(Though it is not truly an operator as it returns no value.)

It is used to associate a chosen reference name with a target:

reference => target

The above can be read as "reference refers to target"

Most often this reference occurs in the form of a pointer. In this case you could say "reference points to target". This is a helpful way to remember what this operator does as its literal appearance is of an arrow pointing from reference to target.

Further Uses
Additional uses including making local aliases for various items such as module components, procedures, and even arbitrary expressions. For a full explanation of all of these uses see this answer.

Pointer assignment vs. Traditional Assignment (=)
Here's a quick example from the above link that illustrates how pointer assignment differs from classic assignment ("="). Basically this shows that once a target has been established, the pointer is treated as that target for basic statements.

pt => x ! pt points to x

y = pt ! y equals x

pt => y ! pt points to y

pt = 17 ! y equals 17

Other Resources:
General documentation on Fortran pointers

这篇关于什么=&gt; (等于大于)意味着在Fortran中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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