What is Kaleido?

Kaleido is a sample programming language implemented with F#, Kaleido is a general-purpose, interpreted "toy" language that has blocks as first-class citizens and anonymous blocks (and hence, higher-order "functions" in a way).

Kaleido's main organization primitive is simply a block of code. The core concept really being the : (start block) and ; (end block) characters. Here's some sample Kaleido code:

Loan: (initialAmount)
    Amount = initialAmount
    
    TotalAfterFirstYear: (calculator)
        return calculator(Amount)
    ;
;

GenerateCalculator: (interest)
    return : (amount)
        return amount + (interest * amount)
    ;
;

loan = Loan(65000)
afterFirstYear = loan.TotalAfterFirstYear(GenerateCalculator(0.0525))
print(loan.Amount)
print(afterFirstYear)

There are a couple of things to notice with this code:
  1. Use of Higher-Order "Functions" from the GenerateCalculator block that generates and returns a block that is then passed to another block
  2. Loan is used like we would normally expect an object to be used, with a "Property/Field" for Amount and a "Function" for TotalAfterFirstYear

Why Kaleido?

First of all, why the name "Kaleido"? Though I would love to take credit for the name, the idea came from my coworker Jonathan Carter. Since the language is primarily built around a "scope", the name is a play off the word "Kaleidoscope".

Kaleido was started merely as a project in which to learn about language implementation and design (simply a fun and education project). I also wanted to use language implementation as a context in which to dig deeper and learn more about F#.

I've always been intrigued by "elegant" programming languages that had minimal "primitives" or syntax built into the language (i.e. LISP/Smalltalk/Forth/etc.). In this vein, I wanted to see what I could try to do around removing a bunch of concepts we typically deal with today: private/protected/public scoping, "class" versus "function" objects and keywords, differing syntax between function definition and lambda definition, etc.

Implementation

Currently, the Kaleido lexer and parser is automatically generated via the FsLex and FsYacc tools that are in the F# PowerPack. The main eval function that is the heart of the Kaleido language is only around 40-50 lines of F# code.

Dependencies

Kaleido is built on the September 2008 CTP of F# (1.9.6.2) and uses the F# project integration into Visual Studio 2008.

Last edited Apr 16 2009 at 9:20 AM by jolson88, version 11

 

Want to leave feedback?
Please use Discussions or Reviews instead.

Updating...
© 2006-2010 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2010.1.12.16187