Archive for February, 2006

PLT Scheme Macros

Saturday, February 25th, 2006

Scheme has a very rich macro system that helps to reduce redundant code. PLT Scheme support two ways of writting macros (syntax-rules) and (syntax-case). I’m writting a shallow embedding of XQuery in Scheme. In order to to acomplish the end goal, I’m parsing XQuery syntax into an abstract syntax tree form that I can then maninpulate and transform into scheme code for execution.
An abstact syntax tree is just a tree of specialized nodes. Each individual node in the tree can be seen as an arrays of values, a hashs or specialized data structure. I Choose the data-type structure format. Scheme provides a (define-struct) form and Essentials of Programming Languages (EOPL) provides a (define-datatype) form, both of which define data structures. However, neither one was exactly what I was looking for.

EOPL syntax would look like the following
(define-datatype Term Term? (StringTerm string) (RationalTerm numerator denominator))

That bothered me was having to provide both the name of the datatype and the name of the datatype test predicate, Term and Term?. Convention says that the predicate function name should be the same as the datatype name with a question mark appended. Why should I have to specify both. The define-datatype macro should take care of that for me.

Back to PLT Scheme. The syntax-rules form really is just a pattern/template replacement system. The syntax-case form on the other hand allow arbitrary transformation of syntax, using transformational expressions that are executed in a seperate environment at macro expansion time before actual execution begins.

To take a symbol such as Term and expand that to two functions Term and Term?, we need the power of arbitrary expressions, not the limitations of simple pattern/template replacement. So (syntax-case) is the for we need to use. It didn’t seem that hard, so I set out to write a new (define-datatype) macro.

Well after several days of agony and failure, I finally achieve success this morning.
The trick, Quasisyntax.

Just like quoting) and quasiquoting in standard scheme expressions, you can do the same thing in macro. But when developing syntax-case macros one uses the (syntax) and (quasisyntax) forms.

In the final form below #` is the abbreviated form of (quasisyntax) and #, is the abbreviated form of (unsyntax).
The let statement is where the magic occurs to transform “Type-name” into “Type-name?”

(define-syntax (define-datatype stx)
(syntax-case stx ()
((_ Type-name (Variant-name Field-name …) …)
(let ((Type-name? (datum->syntax-object (syntax a) (string->symbol (string-append (symbol->string (syntax-object->datum (syntax Type-name))) “?”)))))
#`(begin
(define (Type-name) (display “It works\n”)
(define (#,Type-name?) (display “This works too\n)
)

UUG: MythTV

Thursday, February 16th, 2006

I’m attending the BYU Unix Users Group tonight.
Andrew McNabb is presenting on MythTV. I’m interested in the particulars of which hardware to buy, HDTV support, and digital cable hangups.

Andrew pointed out that the discover channel often has the commentators speak very slow for dramatic effect. MythTV allows you to adjust the playback rate to something like 1.5x and an hour show is 20 minutes shorter.

MythWeb is a cool feature of MythTV that let you set up your MythTV box to record shows remotely.

Andrew’s MythTV Page

MPEG2 Encoders can be found as cheap as $30.
Sony makes the best learning remotes out there.

In related notes, if you haven’t seen this you should take a look at RIAA aims to ban CD ripping

Cool Scheme Resources

Saturday, February 4th, 2006

Several weeks ago I started to download the Structure and Interpretation of Computer Programs Video Lectures by Hal Abelson and Gerald Jay Sussman. I’ve had an opportunity now to view the first three or so. Both Abelson and Sussman are very good lecturers and teachers. I’ve greatly enjoyed them and would recommend them.

Second is the Scheme to C in 90 minutes presentation, about how to write a scheme to c compiler in 90 minutes.

Pretty cool stuff :)

Authorization and Sharing Transactional Data

Saturday, February 4th, 2006

Marco Barulli writes
It’s now clear that exporting a reputation should mean exporting the whole set of “identity transactional data” and implementing some countermeasures (signatures and encryption) to prevent frauds. Then the receiving reputation manager will apply its own computation and derive the reputation.

I disagree. My concerns may not matter as much in the specific case of blog comment reputation systems. However, I believe that they are large concerns to reputation systems in general.

I think the term “identity transactional data” is confusing. Phil Windley correctly clarifies that data feed to a reputation system is transactional data, not identity data. Transactional data is a record of interaction between parties. I buy a book from amazon, that is a transaction. Transactional data contains attributes pertaining to the interaction it is a record of. Identities that participated in a transaction may be recorded as part of the transactional record, but that doesn’t make the transaction part of the identities. Transactions are just a record of behavior exhibited by an entity or identity.

Others have said that exporting reputations from one reputation systems to another is difficult or of little worth. It seems to me that Marco is saying that exporting all the transaction data used to compute a reputation for a particular identity is a necessary condition to share reputation with another system.

Sending all the collected transactional data to an external reputation system seems easy and enpowers the external reptuation system to make its own conclusions from the raw or primary data. Doing so however, violates not only the privacy of the identity for which a repuation is being calculated, but also the privacy of the other reporting entities that originally reported the transactiona data for the identity in question.

The issue in question here is one of authorization. Just because the reporting entities have authorized the reputation system to use the transactional data to compute reputation metrics doesn’t mean they authorize the reputation system to share this source transactional data in raw format with other reputational systems.
Reporting entities usually share their transactional data understanding that it will be aggregated with reports from other reporting entities and summerized sufficiently that the resulting reptuation score while informative will not devulge specific about an individual transaction.

Reputation systems should be transparent. They should allow an identity to review and audit transactional data which it is an active party to. Likewise reporting entities should be able to review and revise transactional data they report.

Reputation systems are only as good as the data feed to them. Reputation systems are appealing because of their ability to reduce report information into manageable sized measures and indicators. Reputation systems can export detailed and informative reputations to external or systems(relying parties) or other peer reputation systems using aggregate statistics without exposing raw transactional data and violating the privacy of the reporting entities or of the individual identites.