archives

Union types in Java?

In C/C++ union types are useful in coding dynamic type systems. Does anyone know if this is possible in Java? I don't see any "union" types in my Java book. Perhaps there is a "work around"? Can a cell in an array be a union?

Edit: Is reflection necessary to discover type information in a dynamic context?

Chris Okasaki on Indentation Syntax

Interesting blog post by Chris Okasaki on how indentation-based syntax seemed easier for novice programmers to learn. Reddit also has some discussion of his post. Novice programming has been touched on a few times on LTU, as have usability studies for some languages.

I think Chris raises some good points which apply to experienced developers just as much as novices. In keeping with the "programs are written once, but read many times" principle, I think it's probably good to enforce indentation in some way. How that's done may be open to interpretation however. I'm interested in exploring the possibilities of indentation-based syntax. What other languages use indentation-based syntax and how does the syntax differ from Python?

exceptions again

The topic of exceptions has come up plenty of times on LtU, with concomitant good food for thought discussions. But I'm not sure I've yet to see a real break down of the issue into basic components from which one could consider designs for languages when it comes to not/doing error handling. Does anybody know of some theory or math or something more solid that is an eye on error handling? Unfortunately, even with that, it sounds like good design for error handling also has to take into consideration subjective usability. And, there is a lot of important nuance in how the 'basic components' interact - yay combinatorics.

Random examples of what I mean / am trying to find / understand: Error codes vs. exceptions (dealing with clarity of non-error code flow). Java differentiates between Errors and Exceptions (dealing with the fact that some exceptions are more exceptional than others). C++ advertises RAII (dealing with the fact that you want a sane way of creating-destroying things in light of errors). Erlang eschews threads (dealing with the fact that threads can make exception handling way more complicated). Option types are useful (dealing with the fact that some errors aren't exceptional). D supports scope-exit (dealing with clarity of error code flow).

Is there something which helps us get at all these issues more rigorously and sanely?