Home | About | Partners | Contact Us

SourceForge Logo

Quick Links
Home
News
Status
Building XL
XL Mailing List

Understanding XL
Conceptual overview
XL examples
Inside XL

In depth
Browse SVN
Browse CVS (deprecated)
SourceForge Info
Contact

Other projects
GNU Project
The Mozart Project

XLR: Extensible Language and Runtime

The art of turning ideas into code

XL, an extensible programming language, implements the ideas of Concept Programming.
If you want to know more, you should start here.

Back to work...

Friday, June 22, 2007

It had been a long time since I worked on XL, mostly because I had spent time writing an article about physics. For those interested, you will find more information about this "theory of incomplete measurements" in my blog, or on the dedicated web site.

After this little distraction, I finally returned to XL, and it was, as usual, a pleasure to. I finally got the range type to work with Revision 313 (but it took practically all the check-ins since Revision 299 to get there). There is a small example in this short test, also shown below:

// Test that basic ranges work
MyRange : variable := 1..3
MyOtherRange : variable := 1.5..7.2

It sure does not look like much, does it? But to get that to compile correctly, here is what needs to work:

  • First, the 1..3 expression is matched against all written forms, and found in the implicit module XL_BUILTINS (see native/xl_builtins.xs source code. The best match is:
        function Range (First, Last : ordered) return range[ordered] written First..Last is
             result.First := First
             result.Last := Last
    
  • Then, generic argument deduction finds that ordered in the code above is integer (from 1 and 3), so we instantiate range[integer].
  • Then, the compiler gives the variable type in the original code the type range[integer], and looks for a way to rewrite MyRange := 1..3.
  • There is no copy that matches, so the implicit record type copy applies (copying one field after the other). Making this work for a generic type found in a module is what I had the most trouble with.
  • So the compiler instantiates a Copy routine, written {tt "this := that"}, and invokes Copy to copy the range[integer].
  • The same thing happens with range[real] at the next line in the program for MyOtherRange.

One of the side effects of this effort was a new implementation of the core lookup algorithms in Revision 307, which was necessary mostly for maintainability. It very slightly degrades performance (44s instead of 41s to run the whole test suite on my laptop), but it makes it much easier to tweak the lookup order rules if I ever need to, since this will be done in a single place.


Meanwhile, C++0X continues to make slow progress towards standardization. Sadly, Daveed Vandevoorde's modules proposal did not make the cut. That's unfortunate, it looked rather well designed (to the extent that something like this can be said of anything related to C++...)

June 2007
Sun Mon Tue Wed Thu Fri Sat
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
May  Jul


Copyright 2007 Christophe de Dinechin (Blog)
E-mail: XL Mailing List (polluted by spam, unfortunately)