{"id":476419,"date":"2023-08-09T07:29:55","date_gmt":"2023-08-09T07:29:55","guid":{"rendered":""},"modified":"2023-09-05T11:12:43","modified_gmt":"2023-09-05T11:12:43","slug":"continuation-passing-style-cps","status":"publish","type":"wiki","link":"https:\/\/oneproxy.pro\/tr\/wiki\/continuation-passing-style-cps\/","title":{"rendered":"Devaml\u0131 ge\u00e7me stili (CPS)"},"content":{"rendered":"<p>Devam-ge\u00e7i\u015f stili (CPS), bilgisayar programlamada kontrol\u00fcn a\u00e7\u0131k\u00e7a bir i\u015flev parametresi arac\u0131l\u0131\u011f\u0131yla iletilmesini i\u00e7eren kontrol ak\u0131\u015f\u0131n\u0131 y\u00f6netme y\u00f6ntemidir.<\/p>\n<h2>Devaml\u0131 Ge\u00e7i\u015f Tarz\u0131n\u0131n Evrimi (CPS)<\/h2>\n<p>Devaml\u0131l\u0131k-ge\u00e7i\u015f stilinin k\u00f6kenleri teorik bilgisayar biliminin geli\u015fimine kadar uzanabilir ve s\u00fcreklilik kavram\u0131n\u0131n k\u00f6kleri lambda hesab\u0131na dayan\u0131r. \u201cDevam-ge\u00e7i\u015f tarz\u0131\u201dn\u0131n bir tabir olarak ilk kez a\u00e7\u0131k\u00e7a belirtilmesi ve uygulamadaki kullan\u0131m\u0131 1960&#039;l\u0131 y\u0131llarda bilgisayar bilimcisi Christopher Strachey taraf\u0131ndan ortaya at\u0131lm\u0131\u015ft\u0131r. Bu d\u00f6nemde kendisi ve meslekta\u015flar\u0131, programlama dillerinin anlamlar\u0131n\u0131 tan\u0131mlamaya y\u00f6nelik bir \u00e7er\u00e7eve olan anlamsal anlambilimi ara\u015ft\u0131r\u0131yorlard\u0131.<\/p>\n<h2>A\u00e7\u0131lan Devam-Ge\u00e7i\u015f Stili (CPS)<\/h2>\n<p>Devam-ge\u00e7i\u015f stili (CPS), devamlar\u0131n a\u00e7\u0131k kullan\u0131m\u0131n\u0131 i\u00e7eren bir program d\u00fczenleme bi\u00e7imidir. Devam, \u00e7a\u011fr\u0131 y\u0131\u011f\u0131n\u0131 ve de\u011fi\u015fken de\u011ferleri de dahil olmak \u00fczere, bir bilgisayar program\u0131n\u0131n belirli bir andaki durumunun temsilidir.<\/p>\n<p>CPS&#039;de her fonksiyon, program\u0131n devam\u0131n\u0131 temsil eden, genellikle &quot;cont&quot; veya &quot;k&quot; olarak adland\u0131r\u0131lan ekstra bir arg\u00fcman al\u0131r; fonksiyon hesaplamas\u0131n\u0131 tamamlad\u0131ktan sonra ne olmas\u0131 gerekti\u011fini belirtir. Fonksiyon sonucunu hesaplad\u0131\u011f\u0131nda, bu sonucu her zamanki gibi d\u00f6nd\u00fcrmek yerine, devam\u0131na ileterek &quot;d\u00f6nd\u00fcr\u00fcr&quot;.<\/p>\n<p>Konsept, kontrol ak\u0131\u015f\u0131n\u0131 a\u00e7\u0131k hale getirmenin bir yolu olarak g\u00f6r\u00fclebilir: bitti\u011finde kontrol\u00fc dolayl\u0131 olarak \u00e7a\u011f\u0131rana aktarmak yerine, bir CPS i\u015flevi devam\u0131 \u00e7a\u011f\u0131rarak kontrol\u00fc ge\u00e7irir.<\/p>\n<h2>Devaml\u0131l\u0131k-Ge\u00e7i\u015f Tarz\u0131n\u0131n Yap\u0131s\u0131 (CPS)<\/h2>\n<p>Geleneksel i\u015flev \u00e7a\u011f\u0131rma kural\u0131nda, bir i\u015flev \u00e7a\u011fr\u0131ld\u0131\u011f\u0131nda, bu i\u015flev y\u00fcr\u00fct\u00fcl\u00fcr ve kontrol\u00fc bir d\u00f6n\u00fc\u015f de\u011feriyle \u00e7a\u011f\u0131rana geri verir. Ancak devam-ge\u00e7i\u015f stilinde kontrol, genellikle &quot;devam&quot; olarak adland\u0131r\u0131lan bir fonksiyon parametresi arac\u0131l\u0131\u011f\u0131yla a\u00e7\u0131k bir \u015fekilde iletilir.<\/p>\n<p>Devam, hesaplaman\u0131n geri kalan\u0131n\u0131 temsil eder. Yani bir fonksiyon bir devaml\u0131l\u0131k ald\u0131\u011f\u0131nda baz\u0131 i\u015flemleri yapar ve ard\u0131ndan sonucu al\u0131nan devaml\u0131l\u0131\u011fa iletir. Dolay\u0131s\u0131yla devam-ge\u00e7i\u015f tarz\u0131nda geri d\u00f6n\u00fc\u015f hi\u00e7bir zaman \u00f6rt\u00fcl\u00fc olarak ger\u00e7ekle\u015ftirilmez.<\/p>\n<p>Sahte bir dilde tipik bir CPS i\u015flevi \u015f\u00f6yle g\u00f6r\u00fcnebilir:<\/p>\n<pre><div class=\"bg-black rounded-md mb-4\"><div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><span>css<\/span><button class=\"flex ml-auto gap-2\"><svg stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" viewbox=\"0 0 24 24\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"h-4 w-4\" height=\"1em\" width=\"1em\" ><path d=\"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2\"><\/path><rect x=\"8\" y=\"2\" width=\"8\" height=\"4\" rx=\"1\" ry=\"1\"><\/rect><\/svg>Kodu kopyala<\/button><\/div><div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-css\" data-no-translation=\"\">function add(<span class=\"hljs-selector-tag\">a<\/span>, <span class=\"hljs-selector-tag\">b<\/span>, continuation) {\n    result = <span class=\"hljs-selector-tag\">a<\/span> + <span class=\"hljs-selector-tag\">b<\/span>;\n    continuation(result);\n}\n<\/code><\/div><\/div><\/pre>\n<p>Bu \u201cekleme\u201d fonksiyonu bir toplama i\u015flemi ger\u00e7ekle\u015ftirir ve ard\u0131ndan sonucu devam\u0131na iletir.<\/p>\n<h2>Devaml\u0131 Ge\u00e7i\u015f Stilinin (CPS) Temel \u00d6zellikleri<\/h2>\n<ol>\n<li>\n<p><strong>A\u00e7\u0131k Kontrol Ak\u0131\u015f\u0131<\/strong>: CPS&#039;de kontrol ak\u0131\u015f\u0131 a\u00e7\u0131kt\u0131r. Gizli y\u0131\u011f\u0131n izi yoktur ve y\u00fcr\u00fctme s\u0131ras\u0131n\u0131 kodda a\u00e7\u0131k\u00e7a g\u00f6rebilirsiniz.<\/p>\n<\/li>\n<li>\n<p><strong>Esneklik<\/strong>: CPS, hesaplamay\u0131 kontrol ak\u0131\u015f\u0131ndan ay\u0131rd\u0131\u011f\u0131ndan, kontrol ak\u0131\u015f\u0131n\u0131 y\u00f6netmek i\u00e7in daha fazla esneklik sa\u011flar.<\/p>\n<\/li>\n<li>\n<p><strong>Engellenmeyen \u0130\u015flemler<\/strong>: CPS, engellemeyen veya e\u015fzamans\u0131z i\u015flemlerin y\u00f6netilmesinde \u00e7ok faydal\u0131d\u0131r. Geri arama cehennemini \u00f6nlemek ve engellemeyen kodda karma\u015f\u0131k kontrol ak\u0131\u015f\u0131 senaryolar\u0131n\u0131 y\u00f6netmek i\u00e7in kullan\u0131labilir.<\/p>\n<\/li>\n<li>\n<p><strong>Kuyruk \u00c7a\u011fr\u0131s\u0131 Optimizasyonu<\/strong>: Kuyruk \u00e7a\u011fr\u0131s\u0131 optimizasyonunu destekleyen diller, t\u00fcm \u00e7a\u011fr\u0131lar\u0131 kuyruk \u00e7a\u011fr\u0131lar\u0131na d\u00f6n\u00fc\u015ft\u00fcrd\u00fc\u011f\u00fc i\u00e7in CPS&#039;den yararlanabilir ve bu da bellek kullan\u0131m\u0131 a\u00e7\u0131s\u0131ndan daha verimli olabilir.<\/p>\n<\/li>\n<\/ol>\n<h2>Devaml\u0131 Ge\u00e7i\u015f Stili T\u00fcrleri (CPS)<\/h2>\n<p>Esas olarak iki t\u00fcr devam vard\u0131r; <strong>do\u011frudan stil<\/strong> Ve <strong>devam-ge\u00e7me tarz\u0131<\/strong>. A\u015fa\u011f\u0131da ikisi aras\u0131nda bir kar\u015f\u0131la\u015ft\u0131rma var:<\/p>\n<table>\n<thead>\n<tr>\n<th>Stil<\/th>\n<th>Tan\u0131m<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Do\u011frudan Stil<\/td>\n<td>Do\u011frudan stilde, bir i\u015flev y\u00fcr\u00fct\u00fclmesini tamamlar ve kontrol\u00fc \u00e7a\u011f\u0131ran i\u015fleve geri verir. D\u00f6n\u00fc\u015f de\u011feri genellikle bir hesaplama sonucudur.<\/td>\n<\/tr>\n<tr>\n<td>Devam-Ge\u00e7i\u015f Stili<\/td>\n<td>CPS&#039;de fonksiyon ekstra bir arg\u00fcman olan devam\u0131 al\u0131r ve sonucu bu devama iletir. Kontrol ak\u0131\u015f\u0131 a\u00e7\u0131kt\u0131r.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Kullan\u0131m, Sorunlar ve \u00c7\u00f6z\u00fcmler<\/h2>\n<p>CPS, kullan\u0131m\u0131n\u0131 \u00e7o\u011funlukla i\u015flevsel programlama dillerinde ve e\u015fzamans\u0131z i\u015flemleri y\u00f6netmede bulur.<\/p>\n<ol>\n<li>\n<p><strong>E\u015fzamans\u0131z JavaScript<\/strong>: JavaScript, \u00f6zellikle Node.js&#039;de, e\u015fzamans\u0131z, engellemesiz i\u015flemleri y\u00f6netmek i\u00e7in CPS&#039;yi kullan\u0131r. JavaScript&#039;teki geri aramalar CPS \u00f6rnekleridir.<\/p>\n<\/li>\n<li>\n<p><strong>Fonksiyonel Programlama<\/strong>: Scheme ve Haskell gibi diller, d\u00f6ng\u00fcler ve istisna i\u015fleme gibi kontrol yap\u0131lar\u0131n\u0131 y\u00f6netmek i\u00e7in CPS&#039;yi kullan\u0131r.<\/p>\n<\/li>\n<\/ol>\n<p>Ancak CPS baz\u0131 sorunlara yol a\u00e7abilir:<\/p>\n<ul>\n<li><strong>Okunabilirlik<\/strong>: CPS bazen geri arama cehennemi nedeniyle okunmas\u0131 ve anla\u015f\u0131lmas\u0131 zor kodlara yol a\u00e7abilir, \u00f6zellikle de \u00e7ok say\u0131da i\u00e7 i\u00e7e geri arama varsa.<\/li>\n<li><strong>Yeterlik<\/strong>: CPS d\u00f6n\u00fc\u015f\u00fcm\u00fc, ekstra parametreler ve i\u015flev \u00e7a\u011fr\u0131lar\u0131 nedeniyle potansiyel olarak kodun boyutunu art\u0131rabilir.<\/li>\n<\/ul>\n<p>Bu sorunlar\u0131n \u00e7\u00f6z\u00fcmleri \u015funlard\u0131r:<\/p>\n<ul>\n<li>Kullanmak <strong>Vaatler<\/strong> veya <strong>e\u015fzamans\u0131z\/beklemede<\/strong> Geri arama cehennemini \u00f6nlemek ve okunabilirli\u011fi art\u0131rmak i\u00e7in JavaScript&#039;te.<\/li>\n<li>Kuyruk \u00e7a\u011fr\u0131s\u0131 optimizasyonunu destekleyen programlama dillerinin kullan\u0131lmas\u0131 verimlilik kayg\u0131lar\u0131n\u0131 azaltabilir.<\/li>\n<\/ul>\n<h2>Kar\u015f\u0131la\u015ft\u0131rmalar<\/h2>\n<p>\u0130\u015fte CPS&#039;nin di\u011fer programlama paradigmalar\u0131yla kar\u015f\u0131la\u015ft\u0131rmas\u0131:<\/p>\n<table>\n<thead>\n<tr>\n<th>Programlama Paradigmas\u0131<\/th>\n<th>Kontrol ak\u0131\u015f\u0131<\/th>\n<th>Kullan\u0131m \u00d6rne\u011fi<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Devaml\u0131 Ge\u00e7i\u015f Stili (CPS)<\/td>\n<td>Devaml\u0131, a\u00e7\u0131k.<\/td>\n<td>Engellemeyen\/asenkron i\u015flemler, kuyruk \u00e7a\u011fr\u0131s\u0131 optimizasyonu.<\/td>\n<\/tr>\n<tr>\n<td>Do\u011frudan Stil<\/td>\n<td>\u00d6rt\u00fcl\u00fc, i\u015flev arayana geri d\u00f6ner.<\/td>\n<td>Senkron\/engelleme i\u015flemleri.<\/td>\n<\/tr>\n<tr>\n<td>E\u015fyordamlar<\/td>\n<td>\u0130\u015flevlerin y\u00fcr\u00fctmeyi duraklatmas\u0131na ve devam ettirmesine izin vererek i\u015fbirli\u011fi i\u00e7inde \u00e7oklu g\u00f6rev ger\u00e7ekle\u015ftirin.<\/td>\n<td>Karma\u015f\u0131k kontrol ak\u0131\u015f\u0131, i\u015fbirli\u011fine dayal\u0131 \u00e7oklu g\u00f6rev.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Gelecek perspektifleri<\/h2>\n<p>CPS, \u00f6zellikle JavaScript&#039;te e\u015fzamans\u0131z kodun yap\u0131land\u0131r\u0131lmas\u0131nda \u00f6nemli bir rol oynamaya devam ediyor. S\u00f6zdizimsel olarak Promises&#039;\u0131n yerine ge\u00e7en async\/await&#039;in kullan\u0131ma sunulmas\u0131, geleneksel CPS&#039;ye g\u00f6re daha iyi bir s\u00f6zdizimi sa\u011flayan ve geri arama cehenneminden ka\u00e7\u0131nan bir geli\u015fme olarak g\u00f6r\u00fclebilir.<\/p>\n<p>Web ve sunucu uygulamalar\u0131 daha karma\u015f\u0131k hale geldik\u00e7e ve e\u015fzamanl\u0131l\u0131k daha \u00f6nemli hale geldik\u00e7e, CPS ve di\u011fer e\u015fzamans\u0131z programlama paradigmalar\u0131n\u0131n daha da \u00f6nemli hale gelmesi muhtemeldir. Bu paradigmalar\u0131 daha iyi desteklemek i\u00e7in programlama dillerini ve \u00e7al\u0131\u015fma zaman\u0131 sistemlerini iyile\u015ftirmeye y\u00f6nelik ara\u015ft\u0131rmalar devam etmektedir.<\/p>\n<h2>Proxy Sunucular\u0131 ve CPS<\/h2>\n<p>Proxy sunucular\u0131, di\u011fer sunuculardan kaynak arayan istemcilerden gelen istekler i\u00e7in arac\u0131 g\u00f6revi g\u00f6r\u00fcr. E\u015fzamanl\u0131 istemci isteklerini i\u015flerken, bir proxy sunucusu, bu istekleri engellemeden y\u00f6netmek i\u00e7in CPS veya benzer e\u015fzamans\u0131z programlama paradigmalar\u0131n\u0131 kullanabilir, b\u00f6ylece verimi ve performans\u0131 art\u0131rabilir.<\/p>\n<h2>\u0130lgili Ba\u011flant\u0131lar<\/h2>\n<ol>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Continuation-passing_style\" target=\"_new\" rel=\"noopener nofollow\">Vikipedi&#039;de devam-ge\u00e7me stili<\/a><\/li>\n<li><a href=\"https:\/\/www.cs.utah.edu\/plt\/publications\/icfp07-fyff.pdf\" target=\"_new\" rel=\"noopener nofollow\">Devam Ettirme Sanat\u0131<\/a><\/li>\n<li><a href=\"https:\/\/www.microsoft.com\/en-us\/research\/publication\/a-history-of-haskell-being-lazy-with-class\/\" target=\"_new\" rel=\"noopener nofollow\">Haskell&#039;in Tarihi: S\u0131n\u0131f Konusunda Tembel Olmak<\/a><\/li>\n<\/ol>","protected":false},"featured_media":468006,"menu_order":0,"template":"","meta":{"_acf_changed":false,"content-type":"","inline_featured_image":false,"footnotes":""},"class_list":["post-476419","wiki","type-wiki","status-publish","has-post-thumbnail","hentry"],"acf":{"faq_title":"Frequently Asked Questions about <mark>A Deep Dive into Continuation-passing Style (CPS)<\/mark>","faq_items":[{"question":"What is Continuation-passing Style (CPS)?","answer":"<p>Continuation-passing Style (CPS) is a method of managing control flow in computer programming. Instead of returning a value to the caller in the usual way, functions in CPS receive an extra argument (often termed as \"continuation\") representing what should happen after the function finishes its computation.<\/p>"},{"question":"When was Continuation-passing Style (CPS) first mentioned?","answer":"<p>The concept of Continuation-passing Style (CPS) was first introduced by computer scientist Christopher Strachey in the 1960s when exploring denotational semantics, a framework for defining the meanings of programming languages.<\/p>"},{"question":"How does a Continuation-passing Style (CPS) function work?","answer":"<p>In CPS, every function receives an extra argument, representing the continuation of the program. When the function has computed its result, it \"returns\" this result by passing it to the continuation, making control flow explicit.<\/p>"},{"question":"What are the key features of Continuation-passing Style (CPS)?","answer":"<p>The key features of CPS include explicit control flow, increased flexibility, improved handling of non-blocking or asynchronous operations, and enhanced tail call optimization.<\/p>"},{"question":"What types of Continuation-passing Style (CPS) exist?","answer":"<p>There are mainly two types of continuations: direct style and continuation-passing style. In direct style, a function completes its execution and returns control to the calling function. In continuation-passing style, the function passes the result to a received continuation, making the control flow explicit.<\/p>"},{"question":"What are the main uses and problems related to CPS?","answer":"<p>CPS is mostly used in functional programming languages and for managing asynchronous operations. It's useful in JavaScript, particularly in Node.js, and languages like Scheme and Haskell. However, it can lead to problems like reduced code readability (due to callback hell) and increased code size. These can be mitigated by using Promises or async\/await in JavaScript and tail-call optimization in other languages.<\/p>"},{"question":"What is the future perspective of Continuation-passing Style (CPS)?","answer":"<p>CPS continues to be essential in structuring asynchronous code, with developments like async\/await in JavaScript improving upon traditional CPS. As web and server applications become more complex and concurrent, CPS and other asynchronous programming paradigms are likely to become more important.<\/p>"},{"question":"How are proxy servers related to Continuation-passing Style (CPS)?","answer":"<p>Proxy servers, acting as intermediaries for requests from clients seeking resources from other servers, might use CPS or similar asynchronous programming paradigms to manage concurrent client requests without blocking, thereby improving throughput and performance.<\/p>"}]},"_links":{"self":[{"href":"https:\/\/oneproxy.pro\/tr\/wp-json\/wp\/v2\/wiki\/476419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneproxy.pro\/tr\/wp-json\/wp\/v2\/wiki"}],"about":[{"href":"https:\/\/oneproxy.pro\/tr\/wp-json\/wp\/v2\/types\/wiki"}],"version-history":[{"count":0,"href":"https:\/\/oneproxy.pro\/tr\/wp-json\/wp\/v2\/wiki\/476419\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oneproxy.pro\/tr\/wp-json\/wp\/v2\/media\/468006"}],"wp:attachment":[{"href":"https:\/\/oneproxy.pro\/tr\/wp-json\/wp\/v2\/media?parent=476419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}