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 // 副本

  • 相关阅读:
    ▶ 0001 No application 'E:wwwgolog' found in your GOPATH
    beego路由
    go sync.WaitGroup
    idea修改filetype
    deepin添加设置快捷键
    mysql数据库被攻击
    linux桌面系统的约定
    deepin把vscode设为默认文本应用
    linux应用管理
    当你在工作中失去动力时该怎么办?
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6046509.html
Copyright © 2011-2022 走看看