Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 15 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 11.1 ('PDF')
Instant purchase and download via GumRoad!

FEATURE

Intro to Fun, Part 2

Towards Functional Programming with Real Studio

Issue: 11.1 (January/February 2013)
Author: Daniel Gross
Author Bio: Dr. Daniel Gross, the principal of Goal-oriented solutions (www.goalorientedsolutions.com), is a business and system analyst and a researcher with a keen interest in software requirements, architecture as well as software engineering methods. Dr. Gross recently discovered Real Studio while consulting a client on cross-OS development. The fun library is a result of some tinkering done to better understand Real Studio and fine-tune its impressive capabilities to produce software code that not only accomplishes its tasks, but is also easier to understand, maintain, and change.
Article Description: No description available.
Article Length (in bytes): 24,011
Starting Page Number: 24
Article Number: 11106
Related Web Link(s):

http://en.wikipedia.org/wiki/Filter_%28higher-order_function%29
http://en.wikipedia.org/wiki/Map_%28higher-order_function%29
http://en.wikipedia.org/wiki/Currying

Excerpt of article text...

Introduction

In part one of this two-part article series I illustrated how looping functions, such as the filter [1] and map [2] functions, implemented in the fun functional library, support a functional programming style in Real Studio. I also discussed how a functional coding style helps make code easier to understand, maintain and change. In this article I illustrate two additional functional programming features offered by the fun library, functional composition and closure, and explain why they are needed and the benefits that the features offer.

The next section illustrates how to use functional composition to flexibility and add functionality to already existing code. Section three motivates the need for closure, a key concept in function programming, explains the concept and illustrates its use. Finally, I conclude the article with a discussion describing how function composition and closure was implemented in the fun library.

Functional composition in Real Studio

Let us briefly recall the example from the previous article. Figure 1 shows a Listbox with a number of selected rows. Each row stores in its RowTag a reference to a Contact object. Suppose, further, we subclass the Listbox and implement a function in the subclass that returns for all selected rows the RowTag object. Code listing 1 shows how one typically accomplishes this task:

...End of Excerpt. Please purchase the magazine to read the full article.