I saw a very interesting piece of code in the SICP. It took quite sometime for me to understand it completely. In fact, the meaning flashed to me today during my morning jog!

In a programmer's perspective, what exactly is data?

This is a very subtle concept. Very difficult to explain.

Example: consider the notion of a 'pair' in lisp. A 'pair' is a way of glueing two pieces of data. This is how I will probably explain it:In a programmer's perspective, what exactly is data?

This is a very subtle concept. Very difficult to explain.

Data is something that is constructed and behaves in a particular way. i.e, What data is, is determined by how it behaves.

How do you say this programmatically? - Data is that which is defined by constructors and procedures, together with specified conditions that these procedures must fulfill in order to be a valid representation.

How do you say this programmatically? - Data is that which is defined by constructors and procedures, together with specified conditions that these procedures must fulfill in order to be a valid representation.

(define z (cons x y))

(define z (cons x y))

`(car z) => x`

`(cdr z) => y`

We never actually said what a pair was, only that there are procedures

The interesting thing is that any triple of procedures that satisfies the above condition can be used as the basis for implementing pairs. This is one such triple:

`cons`,`car`, and`cdr`for operating on pairs. But the only thing we need to know about these three operations is that if we glue two objects together using`cons`we can retrieve the objects using`car`and`cdr`.The interesting thing is that any triple of procedures that satisfies the above condition can be used as the basis for implementing pairs. This is one such triple:

`(define (cons x y)`

(lambda (m) (m x y)))

(define (car z)

(z (lambda (p q) p)))

(lambda (m) (m x y)))

(define (car z)

(z (lambda (p q) p)))

`(define (cdr z)`

(z (lambda (p q) q)))

(z (lambda (p q) q)))

This point is illustrated strikingly by the fact that we could implement

`cons`,`car`, and`cdr`without using any data structures at all but only using procedures. This blurs the distinction between 'procedure' and 'data'. Procedure <---> data. Data <---> procedure. Hmm...I need to think.
## 3 comments:

It looks like you are too much into lisp these days..

Yes dude, I am entirely blown over by it! :-)

there's no such thng as procedure and data.. it's just the way you percieve it ;)

Post a Comment