This blog is now obsolete. Go to scott.arbeitman.id.au for all new content.

Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts
0

Minor Thesis: Inference of Enumerated Types In Java

| Wednesday, September 2, 2009

If you're not from the Computer Science discipline, you can safely skip this post.

After doing some hard drive spring-cleaning, I came across the Latex files relating to my master's thesis at the University of Melbourne. Although I undertook a Masters of Software Systems Engineering by coursework, I was able to write a minor thesis in lieu of 2 subjects.

At the time, compilers and type analysis were of particular interest to me, having thoroughly enjoyed the Compiler Design class at McGill several months earlier. In that class, we wrote a compiler for a toy language called WIG and added features to an existing compiler for the JOOS language, a subset of Java. We used the SableCC lexer/parser, an open source compiler compiler written by another McGill student. I remember staying up several late nights before the project was due. It was great fun.

The forthcoming language enhancements in Java 5 provided a good platform for static code analysis and enhancement; a similar paper inferred generic types, for example. I had also competed a survey of programming languages class which compared functional, logic and imperative language (Haskell, Prolog and Java respectively) taught by Peter Schachte. Peter was kind enough to supervise.

With that background, I thought I would post the PDF of the paper I wrote. I'm not sure if this is the exact paper I submitted, and it certainly includes some typos and, having reread it recently, I can see that my writing needed a bit of work. It is very difficult to decipher some of the content. I suspect I used the most complex symbols and wording possible, but I had slaved through reading similar papers during my research so I must of thought that was the best way to do things.

Without any further ado, please find my paper, Inference of Enumerated Types In Java in PDF format. Note that this paper has not been published in any journal, and has had minimal peer review. It is presented for educational purposes only. However, if you'd like to chat about it, do get in touch.


0

Building a Better CFLOOP

| Saturday, June 23, 2007
ColdFusion 8 introduces slightly improved looping for arrays, as well a new way to loop over the contents of the file. Unfortunately, I don't believe these changes go far enough and, as I'll demonstrate, even better results can be accomplished even with older versions of ColdFusion.

My improved looping tag uses a little known ColdFusion feature, the <cfexit method="loop" /> tag. When used inside a custom tag, this returns control to the top the tag's "end" execution mode. This is ColdFusion's way of allowing custom iterators.

Here's what the syntax of my array looping tag:


<cfimport taglib="/custom-tags/loop/" prefix="loop" />

<loop:array array="#myArray#" index="i" element="e" cycle:shading="light,dark" cycle:odd="true,false" cleanup="true">

</loop:array>


Let me break it down:

  • array: this is the array you want to loop through, just like a regular CFLOOP

  • index: again, just like in CFLOOP, except this attribute is not required and has no defaults. it simply is not set.

  • element: the current item in the array. By default this a variable called element

  • cycle:variableName: the tag sets variableName to one of the values based on current index. This is inspired by a similar function in Rails. For example, in the above example, the variable odd will either have the value of true or false depending on the iteration number.

  • cleanup: This is perhaps the nicest feature. cleanup will remove references to all variables created during the iteration of the tag. This eliminates the need to var-scope lots of variables inside a CFC. By default, this is true.

Update
I've posted the code on github.