This shows you the differences between two versions of the page.
ischeme:ischeme2 [2011/03/18 17:40] ebainomu created |
ischeme:ischeme2 [2011/03/18 17:40] (current) ebainomu created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== iScheme ====== | ||
+ | [[http:// | ||
+ | \\ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | iScheme is built on top of an R5RS [[http:// | ||
+ | |||
+ | |||
+ | ===== Accessing iPhone APIs ===== | ||
+ | |||
+ | iScheme provides developers with an event-driven programming style for accessing iPhone capabilities as well as interacting with native applications, | ||
+ | |||
+ | <code scheme> | ||
+ | (begin | ||
+ | (CURRENT-LOCATION | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | ;; | ||
+ | |||
+ | </ | ||
+ | |||
+ | Scheme programs are directly executed on the iPhone and it is possible to write scripts that interact with native applications e.g., making a phone call by simply evaluating '' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Distributed Programming in iScheme ===== | ||
+ | When writing distributed iPhone applications in iScheme, the developer does not need to deal with low-level distribution concerns in Objective-C such as dealing with the Bonjour framework for service discovery, and socket APIs for remote communication. iScheme provides distribution constructs that abstract away these low-level distribution issues. | ||
+ | |||
+ | Let us demonstrate these constructs with an example: Consider a simple news service iPhone app that allows news editors to submit news articles to news publishers in the surroundings as they move about. Then, the news publisher broadcasts the news to nearby iPhone devices of potential customers that have announced their interest in the current news trends. | ||
+ | |||
+ | So, how do we realise such an application in iScheme? Read on... | ||
+ | |||
+ | |||
+ | ==== Exporting functions as services ==== | ||
+ | |||
+ | In iScheme, distributed computation is expressed in terms of Scheme functions. A function represents a certain service offered by a device. A device can acquire a remote reference to a function owned by a remote device, and then interact with it by performing remote function invocations. As fixed name servers may not be available when two iPhones come in communication range and set up a collaboration, | ||
+ | |||
+ | In the example of the news service application, | ||
+ | |||
+ | <code scheme> | ||
+ | (define news-service (service-type iPhone-news)) | ||
+ | (export-service news-publisher news-service) | ||
+ | </ | ||
+ | |||
+ | A service type is defined using the '' | ||
+ | |||
+ | |||
+ | ==== Service discovery ==== | ||
+ | |||
+ | Service discovery in iScheme is by way of registering an event handler on a service type, which is triggered whenever a function exported under that type is encountered in the network. | ||
+ | |||
+ | <code scheme> | ||
+ | (when-discovered news-service | ||
+ | (lambda (publisher-ref) | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | ==== Asynchronous remote communication ==== | ||
+ | |||
+ | Once a reference to the remote function is obtained, remote function invocations can be performed by means of the '' | ||
+ | |||
+ | <code scheme> | ||
+ | (define (submit-news publisher-ref) | ||
+ | (for-each | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | The '' | ||
+ | The '' | ||
+ | |||
+ | In order to get the return value of a remote invocation, iScheme provides '' | ||
+ | <code scheme> | ||
+ | (define (submit-news publisher-ref) | ||
+ | .... ;;iterator over news articles | ||
+ | | ||
+ | (remote-send publisher-ref receive-article article) | ||
+ | (lambda (receipt) | ||
+ | (set! receipts (cons receipt receipts)))) | ||
+ | ... | ||
+ | ) | ||
+ | </ | ||
+ | The '' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Example Applications ===== | ||
+ | iScheme has been used to develop a couple of non-trivial iPhone applications. | ||
+ | * [[example_applications|AmbiScrabble: | ||
+ | |||
+ | |||
+ | ===== What about Apple' | ||
+ | iPhone apps developed in iScheme do not require any modifications to the iPhone OS, therefore, they can be deployed to the iPhone like any other third party apps. So far we have used Apple' | ||