Prexonite standard repository finally released.

I just checked the collection helper functions I call Prexonite standard repository (psr) into SVN. As I am too lazy to create a full release, I will just supply you with a trac generated zip file.

Following is a short documentation (or rather an overview) of psr:

The Prexonite Standard Library is a collection of scripts that help in day-to-day hacking with Prexonite Script. This page shortly outlines the contents of each of the currently available files.

debug.pxs

Dependencies
none

The script enables special treating of the debug command using compiler hooks for increased performance. For each call to the debug command, it checks whether the function requests debugging (through the debugging MetaKey). Unless that is the case, the call will be removed. if-Blocks using debug as their condition will be evaluated at compile time in respect to the debugging key.

It is possible to use the debug command without including this script, in that case, however, your scripts will also contain calls to debug when not being debugged.

The actual functionality of this script has been moved to managed code inside the Prexonite.dll for performance reasons in #18. CompilerHooks have to be used with care. While the loss in compiler performance is barely noticeable with just one user defined CompilerHook, many of them can really slow the translation down. The managed implementation uses a shared CompilerHook to further save time, should Prexonite.dll ever include additional CompilerHooks

More »

Prexonite October07 Edition

I doubt anyone has noticed it, but yesterday I published a new version of Prexonite. It sort-of replaces the fourth beta preview I had planned to ship earlier.

First, I have to disappoint you: There is not going to be anything like tab-completion in the near feature. Prexonite fully supports Unicode and I couldn't find a library that supports non-ASCII character encoding. Although Prx.exe currently contains an experimental tab-completion solution, I refuse to enable it by default as long as it ignored my umlauts.

Yet another disappointment is, that Prexonie October07 does not yet contain the collection of scripts I plan to include in the Prexonite Standard Repository, but I promise you, to release them in the next edition.

"Did you actually change anything?"

... you might be wondering. In addition to the features announced in the last post, I have added/changed the following:

Improved local variable access

By addressing local variables using an index instead of looking up a name in a dictionary, the time required to access a local variable has measurably decreased. Specialized variants for all instructions dealing with local variables have been added. This is necessary because global code cannot take advantage of this feature.

Also note that this optimization happens after the code has been emitted, so even assembler code takes advantage of the new access method.

Experimental 'data flow' operator

When chaining functions that manipulate lists, I often found myself tediously counting brackets as the expressions got more and more sophisticated. Brackets don't scale very well, so a different way of chaining functions had to be found. While an actual 'chain' operator, like those found in many functional programming languages, might have been the solution, I went a different way.

I wanted pipe the result of one function into another function like it is done in shell scripts. Instead of overloading the '|' operator though, I went with '>>' and '<<'.

Prexonite Script:
  1. function main =
  2.     ::Console.ReadLine~Int>> [1,5,7,1,5].Insert(3)>>
  3.         map(x => 2*x)>> where(x => x mod 3 == 0)>>
  4.         foldl((l,r)=>l+r,"")>> println("[ ") <<"] ";

This sample reads an integer from stdin, inserts it after the third element in the list, which is then restricted to numbers divisible by three. The result is then concatenated and printed.

Although the compiler allows multiple arguments to be added in the way, functions still can only return one value. It might look like tuples are used but that's just a facade for plain vanilla arguments.

Misc.

Prexonite already contains some extensions, that were previously part of the Standard Repository. Most notably the debug command and a set of benchmarking classes.

Also: Tomorrow I will hand in a paper I have been writing on for the past few months. 'Creating a programming language' is a short overview over the concepts of the implementation of a programming language, from its design over the compiler to the runtime environment. As I cannot just print out the Prexonite source code (about 460 pages), the paper will point to the October07 release available from SealedSun.ch.

If you think, the new additions are worth an update, go
Get Prx

New features in the 4th beta preview

Hey, it's been a while but I have added a number of neat features to Prexonite and especially to Prexonite Script.

Conditional expressions

Prexonite Script:
  1. function max(a,b) =
  2.     if(a> b)
  3.         a
  4.     else
  5.         b;

You can also use the 'traditional' {cond} ? {expr} : {expr} syntax but it won't be as easy to read.

Loop expressions

Prexonite Script:
  1. function main()
  2. {
  3.     var xs = for(i = 0; i <100; i++)
  4.                 yield i;
  5.     ;
  6.     var ys = foreach(var x in xs)
  7.                 if(x mod 2 == 0)
  8.                     yield 2*x;
  9.     ;
  10. }

Loops can be used as expressions. Their 'value' is a list of all values 'returned' via the yield keyword. Although it may look like a coroutine, in reality a Prexonite list is returned and not a coroutine reference. More »

Beta Preview 3 available

Hi,
I finally found time to polish and wrap a copy of Prexonite in the two usual *.zip files. This third beta preview contains a lot of bugfixes and also marks the transition from the private SVN repository at unfuddle.com to the public one at assembla.com.
I will use a trac site to keep track of changes made to the Prexonite SVN repository (located at http://tools.assembla.com/svn/prx).

Downloads

There still s no ReadMe.txt but I have included the partial documentation as a *.chm help file.

If you have any questions, please ask through the comments on this site.

Finally trying hard to catch exceptions

Prexonite now comes with exception handling in the form of try-catch-finally blocks. Their implementation is a bit different from the ones in C#.

Prexonite Script:
  1. Add System::IO to Imports;
  2.  
  3. function main
  4. {
  5.     try
  6.     {
  7.         var sw = new StreamWriter("foo.txt");
  8.         sw.WriteLine("It worked!");
  9.     }
  10.     catch(var exc)
  11.     {
  12.         println(exc);
  13.     }
  14.     finally
  15.     {
  16.         dispose(sw);
  17.     }
  18. }

More »