zoukankan      html  css  js  c++  java
  • 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 // 副本

  • 相关阅读:
    React 生命周期
    React 总结
    系统后台设置
    数据库的事务日志已满,起因为"LOG_BACKUP"。
    webpack 打包器
    地图API
    ES6 与 React
    前端流行的技术
    Javascript 函数声明、函数表达式与匿名函数自执行表达式
    Javascript 解读与思想
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6046509.html
Copyright © 2011-2022 走看看