I've implemented the shorthand, Python-style construction calling syntax based on the previous proposal. This feature is orthogonal to the construction/with-block issues, which I'm not ready to tackle since an elegant solution seems elusive.
This particular change is just for the shorthand sugar to omit explicitly calling make:
The new syntax rocks! Since it is convention, I've updated the entire codebase to use it. I think the shorthand syntax really removes a lot of noise from the code, especially with exceptions.
The updated section in the Methods chapter:
Construction Calls
Fan supports a special syntax called construction calls with the syntax Type(args). These calls are resolved as follows:
bind to Type.fromStrif there is exactly one Str argument andType.fromStr exists (see simple literals)
otherwise bind to Type.make
The construction operator works on static methods or constructors. So you can use it when make is a constructor or when make is a factory method. The method of construction call Foo(...) must return Foo.
Convention is to always prefer a construction call to using make explicitly:
brian Fri 25 Jul 2008
I've implemented the shorthand, Python-style construction calling syntax based on the previous proposal. This feature is orthogonal to the construction/with-block issues, which I'm not ready to tackle since an elegant solution seems elusive.
This particular change is just for the shorthand sugar to omit explicitly calling make:
ArgErr.make("bad arg") // longhand ArgErr("bad arg") // shorthandThe new syntax rocks! Since it is convention, I've updated the entire codebase to use it. I think the shorthand syntax really removes a lot of noise from the code, especially with exceptions.
The updated section in the Methods chapter:
Construction Calls
Fan supports a special syntax called construction calls with the syntax
Type(args). These calls are resolved as follows:Type.fromStrif there is exactly one Str argument andType.fromStrexists (see simple literals)Type.makeThe construction operator works on static methods or constructors. So you can use it when
makeis a constructor or whenmakeis a factory method. The method of construction callFoo(...)must returnFoo.Convention is to always prefer a construction call to using
makeexplicitly:ArgErr.make // non-preferred ArgErr() // preferred ArgErr.make("bad arg") // non-preferred ArgErr("bad arg") // preferredtompalmer Fri 25 Jul 2008
Great news.
alexlamsl Fri 25 Jul 2008
I think we all have concensus on this part of the discussion ;-)