Mulling a small syntax change

Posted: February 4th, 2012 | Author: Mars | Filed under: Design, Syntax | Comments Off

Radian has three sorts of definitions: variables which hold a value and can be reassigned, constants which hold a value and cannot be reassigned, and functions which may have parameters and can be invoked to return a value. (Objects, methods, generators, and tasks are all different types of functions.)

Constants bug me because they aren’t really constant in the sense I am used to from C++. The definition can’t be changed, but its value certainly may, when it is defined in terms of variables. What’s more, the difference between a constant and a one-line function without parameters is so slight that I can’t think of any way you could tell the difference in code.

The change I’m pondering would be to ditch const entirely, then split the one-line function form apart from the block form. The new one-line simple definition statement would use the keyword def, borrowed of course from Python and Ruby. The zero-parameter form of this statement would be equivalent to the current const and to the current single-line parameterless function.

This change would regularize the syntax somewhat, in that each leading keyword would then unambiguously introduce either a single-line statement or a multi-line block. I haven’t been using const much because it often feels wrong, especially as an object member, where the “constant” is often defined in terms of variables; I think I might use def somewhat more.

The downside is that programmers familiar with Python or Ruby might find it jarring to find their familiar def keyword set to a similar but rather more restricted use.


‘yield from’ works now

Posted: February 3rd, 2012 | Author: Mars | Filed under: Progress | Comments Off

The async features continue to be my major focus of development. I’ve just pushed a couple of commits that make the yield from statement work. Where the plain yield statement produces a single value in the generator’s sequence of outputs, the yield from statement splices an entire sequence into the output stream.

An identical feature showed up in Python a couple of weeks ago, though that language has offered the simple yield statement for a decade now. I chose to head straight for the enhanced form of yield because I intend to use it as a foundation for the rest of the generator feature: any control-flow block nested in a generator will itself become a generator, and its container will implicitly yield from this nested block.


Release 0.1.1

Posted: February 1st, 2012 | Author: Mars | Filed under: Uncategorized | Comments Off

I made a couple of stupid mistakes in yesterday’s build, so I’ve tagged and uploaded version 0.1.1.

  • Removed debug spew when inserting or doing lookups on a map object.
  • String literal comparison no longer returns spurious “false” results when comparing two equal strings. This also caused map lookups to fail.