Patterson function: Difference between revisions
en>ClausiusMcKnight m Patterson was a visiting researcher, and not visiting a researcher... |
en>Addbot m Bot: Migrating 5 interwiki links, now provided by Wikidata on d:q905709 (Report Errors) |
||
Line 1: | Line 1: | ||
'''Jensen's Device''' is a computer programming technique that exploits [[call by name]]. It was devised by [[Denmark|Danish]] computer scientist [[Jørn Jensen]], who worked with [[Peter Naur]] at [[Regnecentralen]]. They worked on the GIER Algol compiler, one of the earliest correct implementations of [[ALGOL 60]].<ref name="Gieralgol">[http://awards.acm.org/citation.cfm?id=1024454&srt=all&aw=140&ao=AMTURING Peter Naur's 2005 Turing Award citation] mentions his work with Jensen on GIER Algol</ref> ALGOL 60 used call by name. | |||
==Description== | |||
Jensen's device exploits [[call by name]] and side-effects. Call by name is an argument passing convention that delays the evaluation of an argument until it is actually used in the procedure (a consequence of the copy rule for procedures). Algol introduced call by name. | |||
A classic example of Jensen's device is a procedure that computes the sum of a series, <math>\Sigma_{k=l}^u a_k</math>:<ref>{{Citation |last=MacLennan |first=Bruce J. |title=Principles of Programming Languages: Design, Evaluation, and Implementation |edition=Second |year=1987 |publisher=Holt, Rinehart & Winston |isbn=0-03-005163-0 |doi= }}, pp 141–142</ref><ref>{{Citation |last=Dijkstra |first=E. W. |authorlink=Edsger W. Dijkstra |title=Defense of ALGOL 60 (Letter to the Editor) |journal=Communications of the ACM |volume=4 |issue=11 |pages=502–503 |date=November 1961 |doi= }}</ref><ref>{{Citation |last=Knuth |first=D. E. |authorlink=Donald Knuth |title=The Remaining Troublespots in ALGOL 60 |journal=Communications of the ACM |volume=10 |issue=10 |pages=611–617 |date=October 1967 |doi= }}</ref> | |||
<!-- ALGOL 60 source --> | |||
'''real procedure''' Sum(k, l, u, ak) | |||
'''value''' l, u; | |||
'''integer''' k, l, u; | |||
'''real''' ak; | |||
'''comment''' k and ak are passed by name; | |||
'''begin''' | |||
'''real''' s; | |||
s := 0; | |||
'''for''' k := l '''step''' 1 '''until''' u '''do''' | |||
s := s + ak; | |||
Sum := s | |||
'''end'''; | |||
In the procedure, the index variable <code>k</code> and summation term <code>ak</code> are passed by name. Call by name enables the procedure to change the value of the index variable during execution of the <code>for</code> loop. Call by name also causes the <code>ak</code> argument to be reevaluated during each iteration of the loop. Typically, <code>ak</code> will depend upon the changing (side-effected) <code>k</code>. | |||
For example, code to compute the first 100 terms of a real array <code>V[]</code> would be: | |||
Sum(i, 1, 100, V[i]). | |||
During the execution of <code>Sum</code>, the actual argument <code>i</code> will increment during each step of the <code>for</code> loop, and each of the procedure's evaluations of <code>ak</code> will use the current value of <code>i</code> to access the successive array elements <code>V[i]</code>. | |||
Jensen's device is general. A double summation can be done as: | |||
Sum(i, l, m, Sum(j, l, n, A[i,j])) | |||
The <code>Sum</code> function can be employed for arbitrary functions merely by employing the appropriate expressions. If a sum of integers were desired the expression would be just <code>Sum(i,1,100,i);</code>, if a sum of squares of integers, then <code>Sum(i,1,100,i*i);</code>, and so on.<ref><code>Sum</code> requires a <code>real</code> argument for the term, so type conversion is assumed.</ref> A slight variation would be suitable for initiating a numerical integration of an expression by a method very similar to that of <code>Sum</code>. | |||
The evaluation of <code>ak</code> is implemented with a [[Thunk (functional programming)|thunk]], which is essentially a subroutine with an environment. The thunk is a [[Closure (computer science)|closure]] with no arguments. Each time a procedure needs the value of its formal argument, it simply calls the thunk. The thunk evaluates the actual argument in the scope of the calling code (not the scope of the procedure). | |||
In the absence of this pass-by-name facility, it would be necessary to define functions embodying those expressions to be passed according to the protocols of the computer language, or to create a compendium function along with some arrangement to select the desired expression for each usage. | |||
===GPS=== | |||
Another example is GPS(General Problem Solver), described in D. E. Knuth and J. N. Merner's ''ALGOL 60 confidential''.<ref>Donald E. Knuth and Jack N. Merner. 1961. ALGOL 60 confidential. Commun. ACM 4, 6 (June 1961), 268-272. DOI=10.1145/366573.366599 http://doi.acm.org/10.1145/366573.366599</ref> | |||
<!-- ALGOL 60 source --> | |||
'''real''' '''procedure''' GPS(I, N, Z, V); | |||
'''real''' I, N, Z, V; | |||
'''begin''' '''for''' I := 1 '''step''' 1 '''until''' N '''do''' Z := V; | |||
GPS := 1 | |||
'''end''' | |||
==Criticism== | |||
Jensen's device relies on call by name, but call by name is subtle and has some problems. Consequently, call by name is not available in most languages. Knuth comments that ALGOL 60 cannot express an <code>increment(n)</code> procedure that increases its argument by one; the call <code>increment(A[i])</code> does not do the expected action if <code>i</code> is a functional that changes with each access.<ref>{{Harvnb|Knuth|1967|p=613}}. For example, <code>increment(A[increment(j)])</code> will increment <code>j</code> twice.</ref> Knuth says, "The use of 'macro' definition facilities to extend language, instead of relying solely on procedures for this purpose, results in a more satisfactory running program." | |||
Others point out that a call by name procedure that swaps its argument can have subtle problems.<ref>{{Harvnb|MacLennan|1987}}</ref> An obvious swapping procedure is: | |||
procedure swap(a, b) | |||
'''integer a, b; | |||
'''begin''' | |||
'''integer temp;''' | |||
temp := a; | |||
a := b; | |||
b := temp; | |||
'''end;''' | |||
The procedure does the right thing for many arguments, but the invocation of <code>swap(i,A[i])</code> is problematic. Using the Copy Rule leads to the assignments: | |||
temp := i; | |||
i := A[i]; | |||
A[i] := temp; | |||
The problem is the second assignment changes <code>i</code>, so the <code>A[i]</code> in the third assignment probably will not be the same array element as at the start. If on the other hand the procedure were to be coded the other way around (with ''b'' being saved to ''temp'' instead of ''a'') then the desired action would result, unless it were invoked as <code>swap(A[i],i)</code> | |||
==See also== | |||
* [[Call stack]] – stack frame, static link, and display (closure including environment link) | |||
* [[Funarg problem]] – closures can be complicated | |||
* [[Man or boy test]] – environment test | |||
==References== | |||
{{reflist|30em}} | |||
==External links== | |||
* https://www.cs.indiana.edu/l/www/pub/techreports/TR186.pdf | |||
[[Category:Articles with example ALGOL 60 code]] | |||
[[Category:Programming language design]] |
Latest revision as of 12:57, 27 February 2013
Jensen's Device is a computer programming technique that exploits call by name. It was devised by Danish computer scientist Jørn Jensen, who worked with Peter Naur at Regnecentralen. They worked on the GIER Algol compiler, one of the earliest correct implementations of ALGOL 60.[1] ALGOL 60 used call by name.
Description
Jensen's device exploits call by name and side-effects. Call by name is an argument passing convention that delays the evaluation of an argument until it is actually used in the procedure (a consequence of the copy rule for procedures). Algol introduced call by name.
A classic example of Jensen's device is a procedure that computes the sum of a series, :[2][3][4]
real procedure Sum(k, l, u, ak) value l, u; integer k, l, u; real ak; comment k and ak are passed by name; begin real s; s := 0; for k := l step 1 until u do s := s + ak; Sum := s end;
In the procedure, the index variable k
and summation term ak
are passed by name. Call by name enables the procedure to change the value of the index variable during execution of the for
loop. Call by name also causes the ak
argument to be reevaluated during each iteration of the loop. Typically, ak
will depend upon the changing (side-effected) k
.
For example, code to compute the first 100 terms of a real array V[]
would be:
Sum(i, 1, 100, V[i]).
During the execution of Sum
, the actual argument i
will increment during each step of the for
loop, and each of the procedure's evaluations of ak
will use the current value of i
to access the successive array elements V[i]
.
Jensen's device is general. A double summation can be done as:
Sum(i, l, m, Sum(j, l, n, A[i,j]))
The Sum
function can be employed for arbitrary functions merely by employing the appropriate expressions. If a sum of integers were desired the expression would be just Sum(i,1,100,i);
, if a sum of squares of integers, then Sum(i,1,100,i*i);
, and so on.[5] A slight variation would be suitable for initiating a numerical integration of an expression by a method very similar to that of Sum
.
The evaluation of ak
is implemented with a thunk, which is essentially a subroutine with an environment. The thunk is a closure with no arguments. Each time a procedure needs the value of its formal argument, it simply calls the thunk. The thunk evaluates the actual argument in the scope of the calling code (not the scope of the procedure).
In the absence of this pass-by-name facility, it would be necessary to define functions embodying those expressions to be passed according to the protocols of the computer language, or to create a compendium function along with some arrangement to select the desired expression for each usage.
GPS
Another example is GPS(General Problem Solver), described in D. E. Knuth and J. N. Merner's ALGOL 60 confidential.[6]
real procedure GPS(I, N, Z, V); real I, N, Z, V; begin for I := 1 step 1 until N do Z := V; GPS := 1 end
Criticism
Jensen's device relies on call by name, but call by name is subtle and has some problems. Consequently, call by name is not available in most languages. Knuth comments that ALGOL 60 cannot express an increment(n)
procedure that increases its argument by one; the call increment(A[i])
does not do the expected action if i
is a functional that changes with each access.[7] Knuth says, "The use of 'macro' definition facilities to extend language, instead of relying solely on procedures for this purpose, results in a more satisfactory running program."
Others point out that a call by name procedure that swaps its argument can have subtle problems.[8] An obvious swapping procedure is:
procedure swap(a, b) integer a, b; begin integer temp; temp := a; a := b; b := temp; end;
The procedure does the right thing for many arguments, but the invocation of swap(i,A[i])
is problematic. Using the Copy Rule leads to the assignments:
temp := i; i := A[i]; A[i] := temp;
The problem is the second assignment changes i
, so the A[i]
in the third assignment probably will not be the same array element as at the start. If on the other hand the procedure were to be coded the other way around (with b being saved to temp instead of a) then the desired action would result, unless it were invoked as swap(A[i],i)
See also
- Call stack – stack frame, static link, and display (closure including environment link)
- Funarg problem – closures can be complicated
- Man or boy test – environment test
References
43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.
External links
- ↑ Peter Naur's 2005 Turing Award citation mentions his work with Jensen on GIER Algol
- ↑ Many property agents need to declare for the PIC grant in Singapore. However, not all of them know find out how to do the correct process for getting this PIC scheme from the IRAS. There are a number of steps that you need to do before your software can be approved.
Naturally, you will have to pay a safety deposit and that is usually one month rent for annually of the settlement. That is the place your good religion deposit will likely be taken into account and will kind part or all of your security deposit. Anticipate to have a proportionate amount deducted out of your deposit if something is discovered to be damaged if you move out. It's best to you'll want to test the inventory drawn up by the owner, which can detail all objects in the property and their condition. If you happen to fail to notice any harm not already mentioned within the inventory before transferring in, you danger having to pay for it yourself.
In case you are in search of an actual estate or Singapore property agent on-line, you simply should belief your intuition. It's because you do not know which agent is nice and which agent will not be. Carry out research on several brokers by looking out the internet. As soon as if you end up positive that a selected agent is dependable and reliable, you can choose to utilize his partnerise in finding you a home in Singapore. Most of the time, a property agent is taken into account to be good if he or she locations the contact data on his website. This may mean that the agent does not mind you calling them and asking them any questions relating to new properties in singapore in Singapore. After chatting with them you too can see them in their office after taking an appointment.
Have handed an trade examination i.e Widespread Examination for House Brokers (CEHA) or Actual Property Agency (REA) examination, or equal; Exclusive brokers are extra keen to share listing information thus making certain the widest doable coverage inside the real estate community via Multiple Listings and Networking. Accepting a severe provide is simpler since your agent is totally conscious of all advertising activity related with your property. This reduces your having to check with a number of agents for some other offers. Price control is easily achieved. Paint work in good restore-discuss with your Property Marketing consultant if main works are still to be done. Softening in residential property prices proceed, led by 2.8 per cent decline within the index for Remainder of Central Region
Once you place down the one per cent choice price to carry down a non-public property, it's important to accept its situation as it is whenever you move in – faulty air-con, choked rest room and all. Get round this by asking your agent to incorporate a ultimate inspection clause within the possibility-to-buy letter. HDB flat patrons routinely take pleasure in this security net. "There's a ultimate inspection of the property two days before the completion of all HDB transactions. If the air-con is defective, you can request the seller to repair it," says Kelvin.
15.6.1 As the agent is an intermediary, generally, as soon as the principal and third party are introduced right into a contractual relationship, the agent drops out of the image, subject to any problems with remuneration or indemnification that he could have against the principal, and extra exceptionally, against the third occasion. Generally, agents are entitled to be indemnified for all liabilities reasonably incurred within the execution of the brokers´ authority.
To achieve the very best outcomes, you must be always updated on market situations, including past transaction information and reliable projections. You could review and examine comparable homes that are currently available in the market, especially these which have been sold or not bought up to now six months. You'll be able to see a pattern of such report by clicking here It's essential to defend yourself in opposition to unscrupulous patrons. They are often very skilled in using highly unethical and manipulative techniques to try and lure you into a lure. That you must also protect your self, your loved ones, and personal belongings as you'll be serving many strangers in your home. Sign a listing itemizing of all of the objects provided by the proprietor, together with their situation. HSR Prime Recruiter 2010, pp 141–142 - ↑ Many property agents need to declare for the PIC grant in Singapore. However, not all of them know find out how to do the correct process for getting this PIC scheme from the IRAS. There are a number of steps that you need to do before your software can be approved.
Naturally, you will have to pay a safety deposit and that is usually one month rent for annually of the settlement. That is the place your good religion deposit will likely be taken into account and will kind part or all of your security deposit. Anticipate to have a proportionate amount deducted out of your deposit if something is discovered to be damaged if you move out. It's best to you'll want to test the inventory drawn up by the owner, which can detail all objects in the property and their condition. If you happen to fail to notice any harm not already mentioned within the inventory before transferring in, you danger having to pay for it yourself.
In case you are in search of an actual estate or Singapore property agent on-line, you simply should belief your intuition. It's because you do not know which agent is nice and which agent will not be. Carry out research on several brokers by looking out the internet. As soon as if you end up positive that a selected agent is dependable and reliable, you can choose to utilize his partnerise in finding you a home in Singapore. Most of the time, a property agent is taken into account to be good if he or she locations the contact data on his website. This may mean that the agent does not mind you calling them and asking them any questions relating to new properties in singapore in Singapore. After chatting with them you too can see them in their office after taking an appointment.
Have handed an trade examination i.e Widespread Examination for House Brokers (CEHA) or Actual Property Agency (REA) examination, or equal; Exclusive brokers are extra keen to share listing information thus making certain the widest doable coverage inside the real estate community via Multiple Listings and Networking. Accepting a severe provide is simpler since your agent is totally conscious of all advertising activity related with your property. This reduces your having to check with a number of agents for some other offers. Price control is easily achieved. Paint work in good restore-discuss with your Property Marketing consultant if main works are still to be done. Softening in residential property prices proceed, led by 2.8 per cent decline within the index for Remainder of Central Region
Once you place down the one per cent choice price to carry down a non-public property, it's important to accept its situation as it is whenever you move in – faulty air-con, choked rest room and all. Get round this by asking your agent to incorporate a ultimate inspection clause within the possibility-to-buy letter. HDB flat patrons routinely take pleasure in this security net. "There's a ultimate inspection of the property two days before the completion of all HDB transactions. If the air-con is defective, you can request the seller to repair it," says Kelvin.
15.6.1 As the agent is an intermediary, generally, as soon as the principal and third party are introduced right into a contractual relationship, the agent drops out of the image, subject to any problems with remuneration or indemnification that he could have against the principal, and extra exceptionally, against the third occasion. Generally, agents are entitled to be indemnified for all liabilities reasonably incurred within the execution of the brokers´ authority.
To achieve the very best outcomes, you must be always updated on market situations, including past transaction information and reliable projections. You could review and examine comparable homes that are currently available in the market, especially these which have been sold or not bought up to now six months. You'll be able to see a pattern of such report by clicking here It's essential to defend yourself in opposition to unscrupulous patrons. They are often very skilled in using highly unethical and manipulative techniques to try and lure you into a lure. That you must also protect your self, your loved ones, and personal belongings as you'll be serving many strangers in your home. Sign a listing itemizing of all of the objects provided by the proprietor, together with their situation. HSR Prime Recruiter 2010 - ↑ Many property agents need to declare for the PIC grant in Singapore. However, not all of them know find out how to do the correct process for getting this PIC scheme from the IRAS. There are a number of steps that you need to do before your software can be approved.
Naturally, you will have to pay a safety deposit and that is usually one month rent for annually of the settlement. That is the place your good religion deposit will likely be taken into account and will kind part or all of your security deposit. Anticipate to have a proportionate amount deducted out of your deposit if something is discovered to be damaged if you move out. It's best to you'll want to test the inventory drawn up by the owner, which can detail all objects in the property and their condition. If you happen to fail to notice any harm not already mentioned within the inventory before transferring in, you danger having to pay for it yourself.
In case you are in search of an actual estate or Singapore property agent on-line, you simply should belief your intuition. It's because you do not know which agent is nice and which agent will not be. Carry out research on several brokers by looking out the internet. As soon as if you end up positive that a selected agent is dependable and reliable, you can choose to utilize his partnerise in finding you a home in Singapore. Most of the time, a property agent is taken into account to be good if he or she locations the contact data on his website. This may mean that the agent does not mind you calling them and asking them any questions relating to new properties in singapore in Singapore. After chatting with them you too can see them in their office after taking an appointment.
Have handed an trade examination i.e Widespread Examination for House Brokers (CEHA) or Actual Property Agency (REA) examination, or equal; Exclusive brokers are extra keen to share listing information thus making certain the widest doable coverage inside the real estate community via Multiple Listings and Networking. Accepting a severe provide is simpler since your agent is totally conscious of all advertising activity related with your property. This reduces your having to check with a number of agents for some other offers. Price control is easily achieved. Paint work in good restore-discuss with your Property Marketing consultant if main works are still to be done. Softening in residential property prices proceed, led by 2.8 per cent decline within the index for Remainder of Central Region
Once you place down the one per cent choice price to carry down a non-public property, it's important to accept its situation as it is whenever you move in – faulty air-con, choked rest room and all. Get round this by asking your agent to incorporate a ultimate inspection clause within the possibility-to-buy letter. HDB flat patrons routinely take pleasure in this security net. "There's a ultimate inspection of the property two days before the completion of all HDB transactions. If the air-con is defective, you can request the seller to repair it," says Kelvin.
15.6.1 As the agent is an intermediary, generally, as soon as the principal and third party are introduced right into a contractual relationship, the agent drops out of the image, subject to any problems with remuneration or indemnification that he could have against the principal, and extra exceptionally, against the third occasion. Generally, agents are entitled to be indemnified for all liabilities reasonably incurred within the execution of the brokers´ authority.
To achieve the very best outcomes, you must be always updated on market situations, including past transaction information and reliable projections. You could review and examine comparable homes that are currently available in the market, especially these which have been sold or not bought up to now six months. You'll be able to see a pattern of such report by clicking here It's essential to defend yourself in opposition to unscrupulous patrons. They are often very skilled in using highly unethical and manipulative techniques to try and lure you into a lure. That you must also protect your self, your loved ones, and personal belongings as you'll be serving many strangers in your home. Sign a listing itemizing of all of the objects provided by the proprietor, together with their situation. HSR Prime Recruiter 2010 - ↑
Sum
requires areal
argument for the term, so type conversion is assumed. - ↑ Donald E. Knuth and Jack N. Merner. 1961. ALGOL 60 confidential. Commun. ACM 4, 6 (June 1961), 268-272. DOI=10.1145/366573.366599 http://doi.acm.org/10.1145/366573.366599
- ↑ Template:Harvnb. For example,
increment(A[increment(j)])
will incrementj
twice. - ↑ Template:Harvnb