在数据流覆盖范围内,返回变量是否使用它? [英] In data flow coverage, does returning a variable use it?

查看:159
本文介绍了在数据流覆盖范围内,返回变量是否使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脑海中有一个小问题.我在Internet上对其进行了研究,但没有人提供确切的答案.我的问题是:

I have a small question in my mind. I researched it on the Internet but no-one is providing the exact answer. My question is:

在数据流覆盖标准中,有一种方法最终返回变量x.在为该方法绘制图形时,该return语句是否被视为使用x?

In data flow coverage criteria, say there is a method which finally returns variable x. When drawing the graph for that method, is that return statement considered to be a use of x?

推荐答案

是的,return语句使用它返回的值.我也找不到权威的参考,也没有用简单的英语说出这样的含义,但是这里有两个参数:

Yes, a return statement uses the value that it returns. I couldn't find an authoritative reference that says so in plain English either, but here are two arguments:

  • return语句将控制权从程序的一个部分传递到另一部分,就像方法调用一样.返回的值类似于功能参数.因此,return是一种用法,就像成为函数参数是一种用法一样.

  • A return statement passes control from one part of a program to another, just like a method call does. The value being returned is analogous to a function parameter. return therefore is a use just like being a function parameter is a use.

在数据流分析中的另一种用途是当值离开程序并对外部世界产生某些影响时(例如通过打印).如果我们要分析的是方法而不是整个程序,则return会导致该值离开我们正在分析的范围.出于相同的原因,它是一种使用,而打印是一种使用.

The other kind of use in data flow analysis is when a value leaves the program and has some effect on the outside world, for example by being printed. If we're analyzing a method, rather than an entire program, return causes the value to leave the scope which we're analyzing. So it's a use for the same reason that printing is a use.

这篇关于在数据流覆盖范围内,返回变量是否使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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