Blog Post

#1306 Build 1.0.56

brian Thu 11 Nov 2010

I have posted the new 1.0.56 build and updated the online docs.

Operator Methods

The biggest change in this build was ticket #604. This ticket has been around since May 2009 so its been sitting around a while on the docket. I probably should have tackled it sooner because it created several breaking changes, but the new design is much better.

Previously the methods such as "plus", "get", "set" were implicitly mapped to an operator symbol. Now you must explicitly annotate methods with the @Operator facet. Naming conventions are enforced to determine which operator symbol is used by the method:

prefix     symbol    degree
------     ------    ------
negate     -a        unary
increment  ++a       unary
decrement  --a       unary
plus       a + b     binary
minus      a - b     binary
mult       a * b     binary
div        a / b     binary
mod        a % b     binary
get        a[b]      binary
set        a[b] = c  ternary

The unary and set operators require the exact name specified above. The binary operators must only start with the given name. We now allow binary operators to be overloaded by parameter type. Many sys APIs have been enhanced to support this feature:

  • Date - Duration
  • DateTime - Duration
  • Num classes now overload arithmetic operators, for example Int + Float yields Float

As part of this change you might find that code which previously compiled fine now reports errors that an operator has ambiguous resolution. In most cases the fix is simply to insert an explicit case. Also note that string concatentatino only works now if left-hand side is actually a string.

For more information:

  • Ticket 605: full description of design and breaking changes
  • docLang: full description of feature

Localized Str Interpolation

My favorite feature in this build is the ability to easily declare localization strings right in your source code:

Label { text = "$<app.title=My App Title>" }

The code above automatically generates a localization key "app.title", and calls sys::Pod.locale to use the localized string for that key. Now you have no reason not make your applications support localization ;-)

Further information may be found in docLang

Units

One interesting feature I've done in our commercial product SkySpark is add support for units directly into our scripting language. It is a core aspect of all numbers (sort of like Frink). As part of that feature I really put the Unit API thru its paces and decided it needed some changes:

  • Unit may be be keyed/found using multiple identifiers including its name and symbol
  • Unit.fromStr now looks up a unit by its key
  • Unit.define is now used to define a new unit in the VM (previously done by fromStr)
  • Unit database is now simple text file (versus fog file)
  • Initial support for multiplication and division

Facet Inheritance

Facets may now be inherited by annotating them as follows:

@FacetMeta { inherited = true }
facet class MyFacet {}

As part of this change the sys::Serialization facet is now inherited. Also see docLang

Serialization - Slot Literals

I beefed up support for serialization to support slot literals using normal Fantom syntax of Type#slot. I suspect this will be handy for people building meta-data frameworks.

Change Log

Build 1.0.56 (11 Nov 2010)

  • Redesign Unit to be keyed by arbitrary ids list including symbols
  • Redesign Unit definition: fromStr -> define, find -> fromStr
  • Redesign unit database as simple text file
  • Add Unit.mult, Unit.div
  • js: Full Charset and Stream support
  • compilerJs: Wrap CondExpr in parens to preserve grouping
  • Float.isNaN
  • fwt::Monitor.dpi
  • WebReq.socketOptions
  • Remove deprecated json pod (use util)
  • #604: Operator overloading with multiple types
  • #1153: Wisp session data in db
  • #1212: overriding methods returning nullable java type
  • #1213: Returning null as Java array
  • #1215: Compiler error when setter method invokes the same setter of another instance
  • #1233: Widget.layout
  • #1248: Fix WispService shutdown to release port
  • #1263: Serialization of List/Map fields always use field type
  • #1268: Slot literal serialization
  • #1271: Java FFI mixin routers with primitives
  • #1273: Localization string interpolation
  • #1276: Uri.decodeQuery does not handle duplicate keys
  • #1279: ActorPool.maxThreads
  • #1284: Ensure closure parameters are named
  • #1287: JarDist accessing fan:// resources
  • #1293: Facet inheritance
  • #1297: Report variable names which conflict with imported types
  • #1301: Func.bind immutability

qualidafial Fri 12 Nov 2010

Very nice!

I am getting one compiler warning though:

Deprecated slot 'sys::List.slice'

For this line of code:

return list[1..-1].reduce(list.first) |a,b| { PropertyService.buildProperty(a).chain(b) }

Maybe the compiler still emitting obj[Range] as calls to slice instead of getRange?

champt0n Tue 16 Nov 2010

Awesome!

The home page still links to build 1.0.55 though. Maybe I missed some other obvious download link, but I ended up going to fan.googlecode.com directly to grab 1.0.56.

yachris Tue 16 Nov 2010

@champt0n -- your browser (or an upstream provider) may have cached the page. I got 1.0.56 directly off the front page several days ago with no problem.

champt0n Thu 18 Nov 2010

Damn you web page caching! Making me look like a n00b!! Oh well, it shows up correctly now.. LOL

Login or Signup to reply.