Skip to Content
深入理解運算原理|從簡單的機器到無所不能的程式
book

深入理解運算原理|從簡單的機器到無所不能的程式

by Tom Stuart
November 2017
Beginner to intermediate
344 pages
7h 2m
Chinese
GoTop Information, Inc.
Content preview from 深入理解運算原理|從簡單的機器到無所不能的程式
168
|
6
演算的程式;這仍然只是 Ruby 程式設計,但強加的虛構限制讓我們無需學習全新語言
也很容易能探索有限的語意。接著只要我們看到這組功能非常有限的能力,我們將採
用這些功能,並使用我們在前幾章學到的技術(以它自己的解析器、抽象語法、操作語
意),將它們實作成獨立的語言。
模仿 Lambda 演算
要瞭解如何以最小語言的程式設計得以運作,就讓我們在不利用 Ruby 諸多實用功能的
情況下,試著以 Ruby 解決問題。當然,這意謂著 Ruby gem、標準程式庫、模組、方
法、類別或物件都不能使用,但因為我們試著盡量少用,因此也會避免使用控制結構、
指定運算、陣列、字串、數值、布林值。
當然,如果我們完全避開 Ruby 的所有功能,就不會有程式語言,因此我們將會保留:
參照到變數
建立 proc
呼叫 proc
這意謂著我們只能編寫像這樣的 Ruby 程式碼:
-> x { -> y { x.call(y) } }
這大致就是無型別 lambda 演算程式的外觀,它已經很接近我們的目的
了。我們將在第 206 頁的『實作 Lambda 演算』詳述這種演算。
為了讓程式碼更簡短也更容易閱讀,我們也將允許自己使用常數作為縮寫:如果建立複
雜的運算式,我們可以將它指定給常數,並賦予稍後可以重複使用的簡短名稱。參照這
個名字和再次重新鍵入原本的運算式並無不同(這個名字只是讓程式碼不那麼冗長),
所以我們不會依賴 Ruby 的指定運算功能。我們能讓程式變得更長(並以此作為代價)
的情況下,以常數所參照的 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JSON實務手冊

JSON實務手冊

Tom Marrs

Publisher Resources

ISBN: 9789864766000