Subrutina: diferència entre les revisions

Contingut suprimit Contingut afegit
Cap resum de modificació
Robot estandarditza i catalanitza referències, catalanitza dates i fa altres canvis menors
Línia 2:
En [[computació]], una '''subrutina''' o '''subprograma''', com a idea general, es presenta com un [[subalgorisme]] que forma part de l'[[algorisme]] principal, el qual permet resoldre una tasca específica. Alguns [[llenguatges de programació]], com [[Visual Basic]], [[.NET]] o [[Fortran]], utilitzen el nom "funció" per referir-se a subrutines que retornen un valor.
 
En llenguatges programació diferents una subrutina pot ser anomenada '''procediment''', una '''funció''', una '''rutina''', un '''[[Mètode (programació)|mètode]]''', o un '''subprograma'''. A vegades s'utilitza el terme genèric '''unitat exigible'''.<ref>{{Cite ref-web|autor= U.S. Election Assistance Commission
|titletítol= Definitions of Words with Special Meanings
|author= U.S. Election Assistance Commission
|workobra= [[Voluntary Voting System Guidelines]]
|title= Definitions of Words with Special Meanings
|data=
|work= [[Voluntary Voting System Guidelines]]
|dateany= 2007
|year= 2007
|url= http://www.eac.gov/vvsg/glossary.aspx
|accessdateconsulta= 2013-01-14
|authorlinkenllaçautor= Election Assistance Commission}}</ref>
 
Una subrutina en ser cridada dins d'un [[programa (computació)|programa]] fa que el codi principal es detingui i es dirigeixi a executar el codi de la subrutina, en canvi quan es parla d'una macro, el compilador pren el codi de la macro i l'implanta al lloc on va ser escrita la macro, augmentant així el codi font i per tant l'objecte.
 
[[Maurice Wilkes]], [[David Wheeler (computer scientist)|David Wheeler]], i [[Stanley Gill]] se'ls atribueix la invenció d'aquest concepte, que van denominar-lo com una ''subrutina tancada'',<ref>{{Citeref-publicació|cognom1= journalWheeler |nom1= D. J.
| last1 = Wheeler | first1 = D. J.
| authorlink1 = David Wheeler (computer scientist)
| chapter capítol= The use of sub-routines in programmes
| doi = 10.1145/609784.609816
| title títol= Proceedings of the 1952 ACM national meeting (Pittsburgh) on - ACM '52
| pages pàgines= 235
| year any= 1952
| pmid =
| pmc =
}}</ref><ref>{{citeref-llibre|cognom1= bookWilkes
|last1nom1= WilkesM. V.
|last2cognom2= Wheeler |first2nom2= D. J. |last3cognom3= Gill |first3nom3=S.
|first1= M. V.
|titletítol= Preparation of Programs for an Electronic Digital Computer
|last2= Wheeler |first2= D. J. |last3= Gill |first3=S.
|publishereditorial= Addison-Wesley
|title= Preparation of Programs for an Electronic Digital Computer
|yearany= 1951
|publisher= Addison-Wesley
}}</ref> en contrast de la ''subrutina oberta'' o [[macro]].<ref>{{cite ref-web|lastcognom=Dainith|firstnom=John|titletítol="open subroutine." A Dictionary of Computing. 2004..|url=http://www.encyclopedia.com/doc/1O11-opensubroutine.html|workobra=Encyclopedia.com|accessdateconsulta=January 14, gener 2013}}</ref>
|year= 1951
}}</ref> en contrast de la ''subrutina oberta'' o [[macro]].<ref>{{cite web|last=Dainith|first=John|title="open subroutine." A Dictionary of Computing. 2004..|url=http://www.encyclopedia.com/doc/1O11-opensubroutine.html|work=Encyclopedia.com|accessdate=January 14, 2013}}</ref>
 
== Elements de la declaració d'una subrutina ==