• passing parameters by value is inefficient when the parameters represent large blocks of data


    Computer Science An Overview _J. Glenn Brookshear _11th Edition_C

    Note that passing parameters by value protects the data in the calling unit from being mistakenly altered by a poorly designed procedure. For example, if the calling unit passed an employee’s name to a procedure, it might not want the procedure to change that name.

    Unfortunately, passing parameters by value is inefficient when the parameters represent large blocks of data. A more efficient technique is to give the procedure direct access to the actual parameters by telling it the addresses of the actual parameters in the calling program unit. In this case we say that the parameters are passed by reference. Note that passing parameters by reference allows the procedure to modify the data residing in the calling environment. Such an approach would be desirable in the case of a procedure for sorting a list.

    The task of transferring data between actual and formal parameters is handled in a variety of ways by different programming languages. In some languages a duplicate of the data represented by the actual parameters is produced and given to the procedure. Using this approach, any alterations to the data made by the procedure are reflected only in the duplicate—the data in the calling program unit are never changed. We often say that such parameters are passed by value.

    a duplicate of the data // 副本

  • 相关阅读:
    express配置流程(windows)
    web性能优化
    解决“向终端显示内容产生时间延迟”
    node.js全局配置
    BootStrap基本模板
    移动Web开发小结
    理解一下vue的mvvm模式
    前端面试题
    使用layui遇到的一些问题及解决方案
    Vue之使用ajax获取json数据,并用v-for循环显示在表格中
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6046509.html
Copyright © 2020-2023  润新知