Tuesday, July 23, 2013

Frost! v.0.1.1

A new version of the Frost Programming Language interpreter is now available! Now it is possible to create function pointers (or function references), call a function referenced by a variable or an array, and it is possible to create Blocks (just like Objective-C Blocks but with a different syntax)!


This generic bubble-sort can receive an array of any type of data to sort, as long as you provide it with a "compare" function capable of comparing these types of data.

How to create a function pointer?

var printPointer = @print;

// OR

var someFunctions = {@print, @scanInt};
How to create a block?

var a = ^ { [print string:"I am a Block!\n" format:{}]; };

// OR

const b = ^:a {
    [print string:"I am another Block... \'a\' equals %v\n" format:{a}];

// OR

var arrayOfBlocks = {
    ^{ [print string:"First!\n" format:{}]; },
    ^{ [print string:"Second!\n" format:{}]; },
    ^{ [print string:"Third!\n" format:{}]; }

How to call a block or a function referenced by a variable?

[~printPointer string:"Hello!\n" format:{}];

[~someFunctions[0] string:"Hello again!\n" format:{}];

[~b a:5];

var i;
for(i = 0; i < arrayOfBlocks.length; i = i + 1) {

No comments:

Post a Comment