Skip to content

Fantom 入门与概述(docIntro) ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793586706/FIN+5.3.1+docIntro 中文整理基于 FIN 5.3.1


manual ​

Fantom 入门与概述(docIntro) ​

Fantom 概述与入门指南


chapters ​

Fantom Readme发行版说明
StartHere如何入门并使用文档
TourFantom 特性速览
WhyFantom为何打造 Fantom、要解决什么问题
HelloWorldHello World 入门
Faq常见问题
LicenseAcademic Free License 3.0
Change Log各构建版本变更列表

变更日志(Change Log) ​

本章为版本变更明细,保留英文便于检索 API/构建号;学习语言请优先读 Tour、WhyFantom、HelloWorld。

Build 1.0.82 (26 Jun 2025)

  • New fanc tool for transpiling to Java source
  • Java make List/Map generic types
  • Java List implements java.util.List
  • Java Map implements java.util.Map
  • Java make fan.sys.Type subclasses package scope
  • Java make all Map and List constructors package scope
  • Compiler: rename CParam.paramType to type
  • Compiler: rename CMethod.returnType to returns
  • Compiler: rename CField.fieldType to type
  • Compiler: rename MethodDef.ret to returns
  • Compiler: rename FuncType.ret to returns
  • Default default WebJsMode to es
  • Add File.withIn and File.withOut
  • Add StrBuf.joinNotNull
  • Add Win.devicePixelRatio
  • Add Stroke.scale
  • Add Doc.hasFocus
  • Add Win.hisState
  • Add concurrent ActorContext
  • Add util::SyntheticFile
  • Date convenience methods for quarter, year
  • ES support for IntArray and FloatArray
  • New docs: Interop, Java, and Fanc
  • Add string literal escape sequence for \u
  • Improve surrogate pair support in Java
  • France locale change start of week from Sun to Mon

Build 1.0.81 (6 Dec 2024)

  • New markdown pod
  • New util::Console API
  • Rewrite fant in Fantom as new util::TestRunner class
  • Add dom::Storage.keys to iterate all keys
  • Add new SqlConnPool API
  • Add support for postgres TEXT[] type
  • Support for static once methods
  • StrBuf.addRange
  • Add double checked locking into ClassType.java reflect and finish
  • Add sql escape syntax for "@" and ""
  • Deprecate old, undocumented sql escape syntax (This is a breaking change)
  • Add sql::Statement.executeBatch method
  • Add concurrent::ActorMsg
  • Add List/Map setNotNull
  • Fix PathEnv via fan.props to order path correctly
  • Unit db change sec and hr primary symbol to match Duration format

Build 1.0.80 (23 Apr 2024)

  • New ECMA class-based JavaScript design
  • Move fwt pods into separate repo
  • Crypto JWT and JWK APIs
  • Actor queue overflow limits
  • Add Doc.elemFromPos, elemsFromPos
  • Add Event.keyChar
  • Add new dom HttpSocket API
  • New concurrent Lock API
  • Add Graphics.drawEllipse,fillEllipse
  • Add Image.render and Image.write
  • Fixes for Crypto EC keypair support
  • Fix Time.minus 24hr boundary checks
  • Allow mixins to have non-abstract fields if no storage required
  • Fix Color HSL implementation to match browser behavior
  • Add MimeType.isText
  • Add util::LockFile
  • Redesign ES compiler to not generate code for every pod
  • Include TypeScript decl file in pods with JS code
  • Prompt support for jline 3
  • #2909 RGB to HSL conversion
  • #2912 remove Future.state

Build 1.0.79 (17 Jul 2023)

  • New yaml API
  • Zip.readEach, Zip.unzipInto
  • StrBuf.reverse
  • List.eachNotNull
  • Env.path
  • New util::FileLoc class
  • IpInterface.prefixSize
  • HttpReq.postFormMultipart
  • Convert File.copy to use NIO
  • Add WebRes.statusPhrase
  • Add Win.clipboardReadText,clipboardWriteText
  • Date toLocale support for quarter
  • Fix charset handling on wrapped InStreams
  • Enhance compiler to allow covariant dynamic calls
  • Elem.closest
  • Event.relatedTarget
  • New BuildPod "js" target to stage for Node.JS
  • JS support for file API when running in Node.JS
  • Deprecate Future.state in favor of Future.status

Build 1.0.78 (26 Apr 2022)

  • New graphics APIs: GraphicsEnv, Graphics, Image, Stroke, Paint
  • Canvas rendering via Elem.renderCanvas
  • New Java2D graphics implementation
  • Deprecate Font.metrics & DeviceContext in favor of Graphics.metrics
  • Deprecate Int/Float clip in favor of clamp
  • Duration.clamp
  • Str.eachWhile
  • WebOutStream.main
  • ConcurrentMap.getAndSet
  • dom: ResizeObserver

Build 1.0.77 (2 Sep 2021)

  • Distribution zip now shipped without tests
  • List groupBy, groupByInto
  • Move examples/js/ -> examples/webfwt/
  • Env.compileScriptToJs
  • Add new examples/js/ sample code for different JS use cases
  • New WebOutStream.initJs that deprecates WebUtil.jsMain
  • Move obix out of Fantom into Haxall repo
  • js: New formal Env.var initialization design for JS
  • js: TimeZone.cur now defaults to Env.var or queries browser for best match
  • js: Locale.cur can now be defaulted via Env.var
  • New asn1 pod
  • New crypto pod
  • New SocketConfig and TLS support in inet
  • #2652: List.groupBy()
  • #2798: JS Test Code

Build 1.0.76 (10 May 2021)

  • Allow This to be in any func param position as method param
  • Allow once methods to be used on const classes
  • Add once as new fcode bitmask flag 0x80000
  • BoolArray clear, eachTrue, getAndSet
  • Int.clip, Float.clip
  • dom: Elem.fromNative fix if already Elem instance
  • domkit: SashBox.onSashResize
  • WebClient.authBasic
  • Minor enhancements to compilerDoc APIs
  • #2488: Javascript - No warnings on func params
  • #2820: Proposal: once methods on const classes

Build 1.0.75 (24 Aug 2020)

  • Move repo from BitBucket to GitHub
  • List addNotNull, mapNotNull, findNotNull
  • Map addNotNull, mapNotNull, findNotNull
  • Deprecated List.addIfNotNull, Map.addIfNotNull
  • domkit: Add DropTarget.onLeave callback
  • Updates to original documentation
  • Actors now yield based on time instead of msg count
  • Actor improved diagnostics
  • ActorPool.balance experimental method
  • Future is now abstract
  • Pod flattenDepends, orderByDepends
  • Remove JS fixed sourceMappingURL in favor of SourceMap header
  • New web::FilePack class
  • Add opts to Zip.writeNext
  • New math pod
  • #2428: Remove actor message serialization
  • #2669: js: Ordered map is unordered after serialization
  • #2726: Serialising Nested Maps
  • #2770: JS: Type methods (undefined)
  • #2781: Proposal to remove Xmx512M as default option
  • #2809: JS: Depend.equals()
  • #2810: JS: Decimal.toStr()

Build 1.0.74 (2 Mar 2020)

  • Java 8 runtime required
  • Compiler support for Jigsaw Java 9+
  • Binary integer literals prefixed with "0b"
  • List/Map addIfNotNull
  • Buf.bytesEqual
  • Env.indexPodNames
  • dom: HttpReq.send support for sending DomFile as raw content
  • dom: HttpReq.onProgress callback
  • dom: allow Dialog.title to take Elem content in addition to Str label
  • dom: Event.fromNative
  • dom: Elem.scrollIntoView
  • domkit: Dnd support for DomFiles
  • domkit: DragTarget.onDragImage
  • Enhance Regex to support cross-platform flags
  • Update timezone database to tzinfo 2019c
  • web: WebRes.removeCookie
  • #2673: JS: Unimplemented methods on Pod.js
  • #2760: JS: Backwards compatibility issue
  • #2784: fan.sys.FileBuf.toDigest() bug

Build 1.0.73 (21 May 2019)

  • WebReq isGet, isPost conveniences
  • PathFile Java implementation
  • Prep for JDK 9 support

Build 1.0.72 (14 Mar 2019)

  • fanr: Eggbox is now the default fanr repo
  • Rework Java Buf APIs
  • dom: fix DomCoord to be const
  • dom: add Win.log
  • domkit: fix Tree.onAction to not fire on expanders
  • domkit: fix SashBox bug where nested resizable SashBoxs could throw NPE
  • domkit: fix SashBox Float.toLocale to use Locale.en to force . decimal
  • Date yesterday, tomorrow
  • List.containsSame
  • ext2mime: Add otf,ttf,woff,woff2
  • web: default SameSite attribute to "strict" on all cookies
  • #2711: FEP 1: fan build command line tool
  • #2724: Float.toLocale()
  • #2726: Serialising Nested Maps
  • #2730: BugFixes for domkit::ListButton
  • #2739: Lists of Lists

Build 1.0.71 (29 May 2018)

  • List.flatMap
  • concurrent: add ConcurrentMap
  • dom: add DomFile.ext
  • dom: add Geolocation API: geoCurPosition, geoWatchPosition, geoClearWatch, DomCoord
  • dom: add Elem.fromHtml
  • dom: fix Style.effective security exception
  • domkit: add GridBox.insertRowBefore, GridBox.rowIndexOf
  • domkit: add AccordionBox.isExpanded, expand
  • domkit: sdd Popup.fitBounds to verify overflow for async loaded content
  • domkit: support for MenuItem.disabled
  • domkit: add Combo.onItem to customize list items
  • domkit: FlowBox support for non-px gap units
  • domkit: SashBox support for non-px and mixed size units
  • domkit: rework SashBox resizable to use explicit divider children
  • inet: add broadcastAddrs to IpInterface
  • inet: add isLoopback and isSiteLocal to IpAddr
  • wisp: remove deprecated WispService.port field
  • wisp: allow session cookie name to be configurable
  • #2670: NodeRunner does not work on Windows
  • #2694: JS: Deserialisation bug

Build 1.0.70 (8 Nov 2017)

  • Require Java 1.7
  • js: Node.js-based NodeRunner now default js runtime for fant -js
  • graphics: new graphics API
  • dom: remove dom::Size; convert to float-based graphics::Size
  • dom: remove dom::Pos; convert to float-based graphics::Point; Move Pos.rel -> Elem.relPos
  • dom: formalize Elem attr vs prop; get/set routes to attr; trap to prop
  • dom: remove Elem.draggable (use elem->draggable)
  • dom: Win.confirm
  • dom: Win.scrollPos, scrollTo, scrollBy
  • dom: Doc.activeElem, Doc.head
  • dom: Doc.elem -> elemById
  • dom: Doc.exec
  • dom: Elem.attrs,attr/setAttr, Elem.prop/setProp
  • dom: Elem.clone, Elem.hasChildren, Elem.ns
  • dom: Elem.fromNative
  • dom: Event.get,set,trap
  • dom: HttpReq.withCredentials
  • dom: DomFile support
  • dom: Style.addPseudoClass
  • dom: Doc/Elem support for creating namespaced elements
  • dom: add Java peers for Elem,Style,Event
  • domkit: DragTarget.onEnd, DropTarget.onOver
  • domkit: add GridBox.removeRow, removeAllRows
  • domkit: change GridBox cell key "all" -> "*"
  • domkit: add Link.target
  • domkit: fix SashPane.sizes setter to update style
  • domkit: add WellBox
  • domkit: add ButtonGroup.enabled, inheritEnabled, onBeforeSelect
  • domkit: add Table.onHeaderPopup
  • domkit: add Checkbox.indeterminate
  • domkit: add TreeNode.parent,isExpanded methods
  • domkit: make TreeNode abstract; remove Obj field/ctor arg
  • domkit: add TreeNode.onTreeEvent support
  • New docDomkit manual
  • Add options to Zip deflate in/out methods
  • Fandoc support for explicit img size
  • Float.isNegZero, normNegZero
  • compiler: fix to check invalid coercion with shortcut assignments
  • fandoc: add support for horizontal rules
  • Make sys::TestErr public
  • concurrent: add Future waitFor and waitForAll
  • #1386: js: dynamic invocation of a slot inherited from a mixin
  • #1421: js: equality operators compile like assignments
  • #1986: Fanr pod cache out of sync with the FileRepo
  • #1988: Nullability problems with facet
  • #2090: JS: Abstract class creation
  • #2357: URI Encoding / Decoding
  • #2388: fandoc: Wrapping an image in a link
  • #2457: super.trap() in Javascript
  • #2483: Method.func.typeof is not parameterized
  • #2499: Compiler check for shortcut with Int to Float implicit cast
  • #2511: Check null safe chaining with shortcuts
  • #2519: Date/Time toLocale support for single quote literal
  • #2540: Edge cases and java.lang.VerifyError
  • #2551: New line char after Markdown links
  • #2577: js: missing Uri.hash implementation
  • #2592: VerifyError for value based null check in it-block ctor
  • #2620: Err.trace dump to stderr
  • #2629: Javascript: List.unique() throws NotImmutableErr

Build 1.0.69 (14 Jul 2016)

  • Initial domkit code
  • dom: Doc.onEvent, removeEvent
  • Buf.toFile to create in-memory "files"
  • Str.mult
  • Wisp: remove pipelining support
  • #2518: change readLine max to be null
  • #2528: FAN_HOME and fanlaunch.bat
  • #2536: NPE when compiling scripts

Build 1.0.68 (6 Apr 2015)

  • Windows replace exe launchers with batch scripts
  • Windows fansc service controlller
  • JsonOutStream: remove newlines from output
  • WispService.extraResHeaders
  • Doc: deprecate query, queryAll -> use querySelector, querySelectorAll
  • Elem: add Style type
  • Elem: trap support
  • Elem: deprecate hasClassName, addClassName, removeClassName -> moved to Style
  • Elem: deprecate name, val, checked -> use trap operator
  • Elem: deprecate first, last, prev, next -> firstChild, lastChild, prevSibling, nextSibling
  • Elem: deprecate find, findAll in favor of querySelector, querySelectorAll
  • Elem: add animate(), replace(), scrollPos, scrollSize
  • Elem: drag and drop API support
  • dom: add MutationObserver
  • dom: add WeakMap
  • DomEvent renamed to Event; rework API to use dom::Key
  • Map.getChecked
  • Win.hisReplaceState
  • Win.screenSize
  • JS compiler optimized closure call sites
  • JS source map support
  • JS support for compressed timezone database
  • HTTPS support for WispService
  • Rework WispSession to use immutable session maps
  • WebSocket prototype
  • Change Java emitter to raise exception in abstract factory methods
  • Range.eachWhile
  • Enhance Env.props to work with pods
  • Method.paramDef reflection (JVM only)
  • Immutable Buf support
  • Buf.pbk to add PBKDF2 support
  • Enhance Future API: state, complete, and completeErr
  • Deprecate Actor.sendWhenDone in favor for sendWhenComplete
  • InStream.readNullTerminatedStr
  • Bit I/O: OutStream.writeBits, InStream.readBits
  • MarkdownDocWriter
  • #1466: js: Func.arity is missing
  • #1591: JS RegexMatcher support
  • #2396: dom::HttpReq.send() should take nullable content
  • #2403: Returning Void
  • #2428: Actor deprecate support for serialized messages
  • #2436: Cannot parse .props file when first line is # comment
  • #2438: Handle quotes in Cookie per RFC 6265
  • #2453: js: MapType casting errs
  • #2454: Javascript Float.toStr()
  • #2455: Mixin vs Abstract in Javascript
  • #2501: ClosureFuncSpecs for non JS classes

Build 1.0.67 (8 Jan 2015)

  • Mark sys::Regex as serializable and add defVal
  • DateTime.fromJava add negIsNull flag
  • Add fandoc::FandocDocWriter
  • Add locale parameter to sys toLocale methods
  • CompilerInput.docTests
  • WebClient includes Accept-Encoding: gzip
  • Str.trimToNull
  • MimeType.parseParams accepts valueless attributes
  • DocElem redesigned parent/child APIs
  • File.list optional Regex parameter
  • Env.prompt and integrated support for JLine
  • Dom: Win.parent,top, Doc.query,queryAll, Elem.text
  • JavaScript compiler now includes all a pod's props files
  • Fwt: JavaScript impl for WebBrowser
  • Rebuild timezone database using tzinfo 2014h
  • Deprecate Buf.flush in favor of Buf.sync
  • Tweak locale dateTime formats to always include timezone
  • Enum support for facets on items
  • #1948: js: Pod meta-data not available in js
  • #2059: Ordered map is unordered after serialization
  • #2246: Java FFI: ClassFormatError: Illegal class name
  • #2256: Improve Map.make error message
  • #2257: # Comment in Fantom Property Files?
  • #2260: File.copyTo() overwrite func is passed the wrong file
  • #2265: Deprecated enum values
  • #2270: Wrapper object refs not immutable
  • #2325: document.querySelectorAll() in dom::Doc

Build 1.0.66 (19 Mar 2014)

  • Wisp support for secureSessionCookie config prop
  • ActorPool name
  • MimeType.parseParams fix for equals in value
  • BuildPod.compileJni added
  • Date, DateTime weekInYear and VVV formatting pattern
  • DateTime.hoursInDay
  • WispService.errMod
  • New inet APIs: MulticastSocket, IpInterface
  • OutStream wrappers default to charset of inner stream
  • Fix WispRes charset for non-persistent connections
  • InStream.avail
  • List.indexr
  • fwt-js: Improve mouseMove/mouseExit when exiting widget/browser bounds
  • webfwt::CanvasTable: rewrite for large table performance
  • FileStore API to check file system capacity
  • FileUploader.useMultiPart,headers
  • XParser charset sniffing
  • WebClient default receiveTimeout to 1min
  • MimeType.noParams
  • Redesign Num/Int/Float/Decimal formatting to use locale props
  • Add adm/tools/textadept and notepadpp
  • Image.write
  • Int.toRadix
  • GraphicsPath API
  • #1478: js: Invalid type order for sys pod
  • #1614: fwt-js: Parse order bugs for peer defs
  • #2147: Stack trace manipulation / filter
  • #2149: java.lang.ClassFormatError: Duplicate field name&signature

Build 1.0.65 (20 May 2013)

  • Add build javacParams config option (#1765)
  • Fandoc abstract Test classes
  • WebOutStream: add header, footer, nav, section, article, aside
  • Convert SqlConn from class to mixin
  • fwt: AsyncTask
  • Locale default support for /etc/sys/config.props
  • Normalize Uri https, ftp ports
  • #1891: Fix fandoc images embedded in paragraph text
  • #2051: Opening Uri by its scheme handler
  • #2052: sys::Uri.encodeQuery does not conform standard
  • #2054: Problem of Reduced Stack Trace
  • #2121: Runtime error when using Map as a type
  • #2133: Errs on Service.start()
  • #2134: NullErr with Safe Invoke
  • #2139: Can not override method that returns This

Build 1.0.64 (21 Dec 2012)

  • Move webfwt into Fantom core
  • BuildScript.applyMacros
  • fwt: Dialog.defCommand
  • FanClassLoader support for resource URLs
  • Fix sql::Statement.execute to return Row[] on result sets
  • Add StrBuf getRange, replaceRange
  • Fix fanr signature encoding from abs to rel URI
  • Suppress deprecated warnings from within deprecated type
  • Enhance JarDist to generate Main.boot method
  • Buf.crc
  • Add bin/msvcr100.dll
  • Upgrade SWT to 4.2
  • Add Time.plus/minus(Duration)
  • Keep InStream.readProps ordered
  • #1942: Err when making of err
  • #1960: Add List.removeAll
  • #2029: compiler bug - wrong non-nullabillity inference
  • #2031: json bug linebreak before comma crushed parser
  • #2043: Compiler NPE in static field assignment
  • #2058: No shutdownInput and shutdownOutput for inet::TcpSocket

Build 1.0.63 (16 Jun 2012)

  • Move dispose from Desktop to Color, Font, Image
  • Add util::FloatArray
  • Add IntArray, FloatArray sort
  • Add gzip factories to sys::Zip
  • FileWeblet gzip compression for text files
  • Propagate Widget.enabled down widget tree
  • Rename JVM MmapBuf to NioBuf
  • Map.getOrThrow, add UnknownKeyErr
  • flux: autoSaveTabOnClose option
  • flux: ensure FileResource can be overridden
  • Canvas.doubleBuffered
  • Add SocketOptions.connectTimeout
  • Add Text fg, bg colors
  • Add Key.minus method
  • @Js for Fandoc API
  • File.isEmpty to efficiently check for empty directory
  • Refactor JavaType to always preload the class
  • fwt-js: Table.onAction support
  • SmtpClient STARTTLS support
  • ObixMod batch op support
  • Add IpAddr.toNative
  • #1479: Cannot use strings inside string interpolation
  • #1788: Range Serialization from Fantom1.0.60 -> Fantom1.0.61
  • #1790: Fix Java dasm overloaded inheritance
  • #1792: Lenient compilation for once methods
  • #1844: sys::Field.get
  • #1862: WebReq.locales
  • #1862: Wisp set Locale.cur via WebReq.locales for request
  • #1885: the too-clever-editor bug
  • #1901: fwt::Tree does not repaint on refreshAll on OS X

Build 1.0.62 (24 Feb 2012)

  • Add gedit config file
  • Tweak compiler to omit fcode/types.def if no types
  • Refactor Compiler.depends
  • Redesign compilerDoc
  • Add localeTestMode for JS environment
  • Fix fanlauncher to work in Cygwin
  • Fix Decimal to handle non-terminating divide
  • SmtpClient SSL support
  • Zip limit checks
  • Add locale keys for Duration.toLocale
  • Require "d" suffix for Decimal literals
  • Fant can now run script files
  • Add classfile disassembler to compilerJava
  • Switch Java FFI to use disassembler instead of reflection
  • Fix resource handle to allow jars to be bundled with pods
  • Fix compiler/runtime to search dependencies for Java classfiles
  • Compiler check for type visibility for is, isnot, as, casting
  • Prototype for "fan.props" PathEnv
  • #1143: js: Method.call fails for some core types
  • #1385: js: sys::List API problems
  • #1577: js: exception when Map->size
  • #1652: js: Type.params not implemented
  • #1683: JS: Assignment operator complie error
  • #1684: JS: Call super field
  • #1718: Require func param types when used in slot signatures
  • #1722: Cycle-dependent pod
  • #1738: Ambiguous slot issue
  • #1776: Proposal: Enhanced Constructors
  • #1778: Map#findAll() and Map#exclude()
  • #1780: Enhanced Java Support
  • #1782: js: Support for overriding virtual fields
  • #1783: js: checks for type dependencies

Build 1.0.61 (17 Nov 2011)

  • Upgrade timezone database with zone info version 2011j
  • Generate apidocs for @NoDoc type/slots, but hide in compilerDoc
  • Add fwt::Clipboard
  • Add readme.html to distribution
  • WispService.addr to bind to specific IP interface
  • Add util::IntArray, util::BoolArray
  • Fix Java runtime class loading deadlock
  • Duration.min, max
  • Duration mult/multFloat, div/divFloat
  • WispService.maxThreads
  • ActorPool.maxMsgsBeforeYield NoDoc hook
  • Remove support for named supers on class types
  • Add ACC_SUPER to JVM emitted classes
  • Fix sql Col lookup to be case insensitive
  • Compiler check for chaining non-null safe call after null safe call
  • Env.indexKeys
  • Remove UriScheme.scheme method
  • js: convert fwt::Table to desktop style selection UX
  • js: Obj.hash default implementation
  • js: rewrite Map implementation; use Obj.hash; support key collisions
  • js: Map.caseInsensitive support
  • #1464: js: Obj.hash always returns 0
  • #1485: js: Map doesn't handle equal hash codes
  • #1494: JarDist - support for main(Str[]) params
  • #1556: Timezone support (ISO 8601) - doesn't support all formats
  • #1564: Compiler error on abstract Func
  • #1607: Fix List.size to not automatically change capacity
  • #1608: extending sys::Str with replaceMatch/replaceMatches
  • #1639: Confusing error report when variable error in a string.
  • #1654: Fix example doc hyperlinks
  • #1667: protected modifier provides internal access
  • #1676: compiler: Non-nullable field mytext must be assigned in ctor

Build 1.0.60 (1 Sept 2011)

  • WebClient.proxy support
  • JsProps.writeProps: include etc/xxx files
  • WebOutStream: thead, tbody, tfoot
  • WebClient: postFile
  • Finish up fanr infrastructure
  • New docFanr chapter
  • Process.kill and bit of Java rework
  • Web support and docs for Expect: 100-continue
  • Env.promptPassword
  • fwt-js: onKeyDown/onKeyUp support for all widgets
  • fwt-js: keyboard support for Table, Dialog, Button
  • fwt-js: onBlur/onFocus support
  • Add fwt/table.fan example
  • Fix fwt::Table view/model bugs
  • wisp::Main to run simple WebMods under Wisp
  • Add deprecation warnings for facet fields
  • New compiler apidoc format
  • New syntax pod
  • New compilerDoc pod
  • Fandoc: shift heading levels
  • Rework fluxText to depend on new syntax pod
  • Nuke old docCompiler
  • Remove doc target from build scripts
  • #1091: KeyDown not working in FWT/JS
  • #1558: js: DateTime.toHttpStr lacks JS implementation
  • #1576: Fix Java sys method reflection
  • #1617: Map.get returns default value for existing key if value is null

Build 1.0.59 (2 Jun 2011)

  • Remove support for deprecated readonly keyword
  • fwt::Cursor API
  • Graphics drawRoundRect, fillRoundRect
  • Allow null comparisons to fields inside an it-block constructor
  • Change default fields for LogMod
  • Fix Dialog commands button where always only OK
  • compilerJs: escape "name" for slots
  • compilerJs: fix reflection for escaped slot names
  • Fix Date.toLocale for DDD
  • WebOutStream.label
  • js: fwt::Button.image support, ButtonMod.sep support
  • js: fwt::ToolBar
  • Fix sys::Param to be const
  • fwt::Widget.addAll
  • Str.toCode escape control chars
  • Fix File.moveTo to create parent directory if needed
  • Improve Test.verifyEq failure msg for multi-line strings
  • Stand alone fwt::ScrollBar support
  • dom::Win.hisBack, hisForward, hisPushState
  • Str.toXml/OutputStream.esc change ' -> '
  • Make gfx::Brush const
  • js: fwt::Widget.onMouseWheel support
  • Initial fanr support
  • List.binaryFind
  • js: fwt::Widget support for add/remove EventListeners after Widget creation
  • Upgrade SWT from 3.5.1 to 3.6.2
  • js: fwt::Event.count,consume support, fixes for event bubbling
  • js: sys::Depend implementation
  • Change pod meta "build.time" -> "build.ts"
  • js: Facet support
  • js: full readObj/writeObj serialization support
  • Add standard pod meta tags for org, proj, license, and vcs
  • Rename dom::Event -> dom::DomEvent
  • #717: Err extend RuntimeException
  • #1331: Fix set assignment to work with value types
  • #1390: js: List of numbers sorting differs
  • #1419: js: safe field access
  • #1427: js: fwt.window.root possible error
  • #1448: Mmaped Buf end of stream issue
  • #1471: js: List.binarySearch and List.shuffle are missing
  • #1474: Ensure super only used with slot call
  • #1477: Report error if mixin has native methods
  • #1480: Map#map doesn't preserve ordered/caseInsensitive
  • #1482: Overriden non-nullable fields can be left uninitialized
  • #1496: fanx.interop.Interop.toFan/toJava
  • #1497: override with static field
  • #1501: ensure override has matching param default state
  • #1509: Horizontal mouse wheel support
  • #1512: ffi override once with array
  • #1526: Virtual methods in OutStream
  • #1534: Build problem when using java native code and PathEnv
  • #1543: Key.fromMask doesn't work for complex modifier
  • #1545: email "from" field error

Build 1.0.58 (4 Mar 2011)

  • Remove deprecated sql APIs (#1318)
  • Weekday.localeVals
  • js: fwt::ProgressBar
  • Add major world currencies to units database
  • Add service shutdown hook to AbstractMain
  • Desktop.callLater
  • List.shuffle
  • Rect.intersects, intersection, union
  • Graphics.clipBounds
  • Tree.bg, Tree.isExpanded
  • dom: Win.open, Win.close, Doc.out
  • Mark GfxEnv as NoDoc
  • Image.makePainted
  • #1139: File.copy: maintain permissions
  • #1156: Image API enhancements
  • #1369: Deprecate readonly keyword
  • #1375: Serialization type/slot reads too far
  • #1384: fansh Variables are always nullable
  • #1396: Java subclass method visibility widening disallows Fantom overriding
  • #1407: Better Error Messages
  • #1415: Cannot pass a closure to the enum class constructor

Build 1.0.57 (6 Jan 2011)

  • Rename sql::Col.of => type
  • Change how JDBC classes are preloaded by sql
  • Update timezone database
  • Add support for timezone aliases (tzinfo backward list)
  • FileMod: remove requirement that file exists, just return 404
  • Fix Map.add, getOrAdd handling of null values
  • Change Border.defVal from 1 to 0 width
  • Tighten up Num toLocale to reject invalid patterns
  • Add Subtype Substitution section to docLang::TypeSystem chapter
  • Improve closure performance making Func.params lazily loaded
  • js: Complete DateTime/Date/Time toLocale/fromLocale
  • sql: add support for sys::Decimal type
  • js: Deployment and running docs
  • Add sys locale files for most major languages
  • Remove deprecated slice methods (replaced by getRange)
  • #430: Bundle Java classes in pod
  • #1260: Seeding the random number generator
  • #1307: VerifyError with as/+ operator combo
  • #1308: Closures param names are not available at runtime
  • #1313: Require Operator facet on add for comma operator
  • #1314: Env.addShutdownHook
  • #1316: BorderPane not a subclass of ContentPane?
  • #1318: Sql API changes
  • #1326: Support for is/as operators on value-types
  • #1328: Str.in not working properly with Unicode
  • #1344: fansh doesn't handle Java FFI variables
  • #1345: Coerce in shortcut assignments
  • #1348: Make inet Sockets non-const classes
  • #1363: Obj.trap support for default args of null

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

Build 1.0.55 (13 Sep 2010)

  • Enhance DateTime/Time pattern for AM/PM
  • dom: Win.sessionStore, Win.localStore, Doc.title
  • Remove obsolete support for * field storage operator
  • Add EnumOrdinalAttr to fcode format for enum fields
  • Java annotations support
  • Add DateTime chapter to docLang
  • #668: Java FFI - use Java annotations
  • #863: Java FFI issue: Failed to assign an value to arrays of Objects through FFI
  • #1114: Invalid field for tableswitch: compiler::FField
  • #1150: Require ++/-- to be on same line
  • #1183: Str as CharSequence and sys::List as java List
  • #1190: compile error on list of java arrays
  • #1191: Param default expr cannot access itself
  • #1192: Formalize type inference rules with parameterized generics
  • #1194: Disallow () call operator on non-func types
  • #1204: Don't allow |A->| function signatures
  • #1208: BootEnv should use ext classloader

Build 1.0.54 (14 Jul 2010)

  • Support for Java FFI Type->toClass
  • Fix WebClient to report port number in Host header
  • ObixMod abstract base class for server side functionality
  • Support for WebSocket Protocol Handshake HTTP 101 response
  • List.unique,union,intersection,moveTo support in js
  • Fix Float.equals to work consistent with == operator
  • Flush out Float/Range API in js
  • Add sql::Statement.limit
  • Ensure "{fan}/lib/java/ext" added to Java FFI classpath
  • Flush out docLang::Native chapter
  • Etc/Rel TimeZone
  • Change CompilerInput to accept files or dirs
  • Support for SS optional seconds in DateTime and Time formatting
  • Str: chars, fromChars
  • Change Obj.typeof to be non-virtual
  • #895: Allow () operator to be used on func fields
  • #1112: JarDist omitting .class file
  • #1127: Expand scope of illegal nullable to non-nullable errors

Build 1.0.53 (13 May 2010)

  • Fix boxed boolean JVM checks
  • Make Int.shiftr unsigned (Java >>> operator)
  • Add etc/sys/config.props support to fanlaunch bash script
  • Rewrite gfx::Gradient to support CSS3 model
  • Add Map.ordered support to .NET runtime
  • FWT patch to allow mounting under arbitrary SWT widgets
  • Make java primitive wrappers and java.lang.Class immutable
  • Fix LogRec.print to return Void (to match Java/C# signatures)
  • Fix FileLogger to include stack trace and use new non-null fields checks
  • Rework JavaTypes to delegate to Env for caching and loading
  • Func.arity
  • Implement Int/Float toLocale for javascript
  • Remove deprecated dom::Elem.x/y/w/h methods
  • TableModel and TreeModel changed from mixin to abstract class
  • Table sorting and column visibility
  • Improve Map support under JavaScript
  • Fix FileLogger/LogMod to write headers on open of new files per day/month
  • Compiler support for native classes
  • Allow CompilerInput to specify a custom CNamespace
  • #569: docCompiler gives |Obj| for |This| it-block
  • #965: Compiler TypeParser doesn't handle Java FFI
  • #977: New concurrent pod (move Actor)
  • #1031: StrBufOutStream does not delegate correctly
  • #1039: It not typed as Obj? correctly
  • #1045: Compiler check error for LoadMixinInstance
  • #1051: Gradient API
  • #1053: HTTP 1.0 request using chunked transfer encoding
  • #1055: Misc BNF grammar problems
  • #1056: It-block parameters have incorrect reflection signature
  • #1057: compiler bug in exprOrLocalDefStmt
  • #1060: Ensure Map types don't have nullable keys
  • #1066: Double ?? are allowed when defining type which should not
  • #1067: compilerJava - findMethods() patch
  • #1073: Storage operator
  • #1077: VerifyError when Safe Invoke is used to call java method returning int
  • #1079: ResolveImports: catch CompilerErr around resolveImportedTypes() call
  • #1080: BuildJava should allow specifiybg custom classpath/jars

Build 1.0.52 (24 Mar 2010)

  • Color: makeArgb, makeRgb
  • WebUtil.jsMain
  • Win: viewport, reload, onEvent
  • Elem: deprecate x,y,w,h; add pos, size, bounds
  • New concurrent pod
  • SqlService.lastAutoKey => Statement.execute
  • Tweak grammar to disallow chaining comparison operators
  • Change config API for FileLogger and LogMod to allow datetime pattern
  • Date/Time fromLocale - parsing with pattern
  • Default all ext2mime.props to assume charset=utf-8
  • Str: getSafe
  • Add util::CsvInStream and util::CsvOutStream
  • #762: fix sql API for auto-generated keys
  • #832: Runtime checking of non-nullable fields
  • #949: IllegalAccess in mixin field override
  • #986: Field initializer List and Map type inference
  • #994: java.lang.VerifyError on broken code
  • #995: If statement returned in a closure - Internal compiler error
  • #1032: Move json to util to match csv API
  • #1033: Why is not avilable type "Obj[]?[]" ?
  • #1036: Serialization of const fields

Build 1.0.51 (6 Feb 2010)

  • Roll fcode version from 1.0.45 => 1.0.51
  • Change enum to positional keyword "enum class"
  • Rename build::Target => TargetMethod
  • Refactor build script design for facets and pod meta-data
  • Refactor pod format meta.props and fcode sub-directory
  • Replace Type Database with Env pod indexing
  • Move docLib chapter into their respectiive pods as pod-doc
  • #936: Symbols/Facet Redesign

Build 1.0.50 (2 Feb 2010)

  • Pod.loc => locale
  • Locale.get => Env.locale
  • Remove UriSpace
  • Change syntax of fan: URI scheme
  • Change flux options design
  • Change build symbols to be config props
  • Pod.files: now returns list, added Pod.file, now used fan: URI
  • Repo replaced with util::PathEnv
  • Remove readSymbols, writeSymbols APIs
  • sql::SqlService.autoCommit change to field
  • sql::Dialect - renamed some methods for consistency
  • lib/sys.props => etc/sys/config.props
  • JarDistEnv and JarDist build task
  • #753: JDBC drivers and preloading
  • #867: JVM ClassLoader per Pod
  • #935: Env API
  • #952: Jar Dist
  • #953: Fanp can't find a pod in a custom ${FAN_REPO}

Build 1.0.49 (27 Jan 2010)

  • Obj.type => typeof
  • List added: containsAny, moveTo
  • List removed: containsSame, containsAllSame
  • Buf.empty => isEmpty
  • Test.id => curTestMethod
  • Field.of, Param.of, Symbol.of, Pod.findType => type
  • DateTime, Time: isMidnight
  • DateTime, Date support for DDD pattern 1st, 2nd, etc
  • Integrate JavaScript compiler into main compiler pipeline
  • js: Int.toCode, toDuration, toDateTime
  • js: Remove Long support; use native Numbers for integers
  • compiler::Location => Loc
  • Remove methods deprecated in 1.0.48
  • Remove deprecated support for |,| closure syntax
  • Remove deprecated support for val in field setters
  • #749: compilerJs bug in list initializer
  • #750: JS: (Int?)null == (Int)0
  • #789: File upload support for web pod
  • #800: += operator doesn't work correctly in JavaScript
  • #849: Internal compiler error
  • #869: Obj.type => Obj.typeof
  • #870: Proposal: bitwise operators
  • #878: Use Native Number type for sys::Int on JavaScript
  • #883: Simplify standard build targets
  • #889: compilerJs Rework
  • #892: Proposal: using ?: operator with throw
  • #922: Don't allow one char scheme names in File(Uri)
  • #927: List API Changes

Build 1.0.48 (21 Dec 2009)

  • Fix List.insertAll error checking
  • Int.toLocale "B" pattern for formatting size in bytes
  • Add sys::deprecated facet and compiler warnings
  • DateTime, Date, and Time support in sql
  • Fix Uri.relTo(/) to remove leading slash
  • Change build::CreateZip.inDir => inDirs
  • Rename dom::Window -> dom::Win
  • Move dom::Win, dom::Doc to singletons
  • #768: Fan source to HTML bug
  • #796: Using Json to read/write Fan objects
  • #797: Setting const fields with reflection
  • #826: New docTools::IDEs chapter
  • #836: New WebMod API
  • #841: Proposal: fand to util
  • #844: List.getSafe
  • #848: Remove sys::Context
  • #851: Change |,| to |->|
  • #853: InStream::readChars
  • #854: Dom API cleanup
  • #855: Some API renames
  • #860: Range.offset
  • #861: compiler: fix Obj to Void coercion bug
  • #865: Make fwt::TreeModel.children non-nullable
  • #869: deprecate Obj.type, Type.loc, Type.log
  • #870: depreate bitwise operators ~ | ^ &
  • #873: InStream / OutStream endianness
  • #874: Field setters: val => it
  • #875: Add 1-step bootstrap script
  • #876: Source Doc Changes

Build 1.0.47 (17 Nov 2009)

  • Rename Fan to Fantom!
  • Range fromStr, isEmpty, min, max, first, last
  • List.eachrWhile
  • Map.getOrAdd
  • FWT javascript enhancements
  • Float.random
  • Range.map
  • Date.today and Time.now take optional TimeZone
  • Date firstOfMonth, lastOfMonth
  • Fix StrBuf.out anomalies
  • XNode.writeToStr
  • dom::Doc.cookies
  • Tweak compiler to hide private/internal default exprs in fandoc
  • Graphics: drawPolyline, drawPolygon, fillPolygon
  • JavaScript: proper type coercion
  • FWT Tree/Table onPopup support for Event.pos
  • Fix Future.get timeouts for OS X
  • js: Fully pass UriTest; encode/decode Uris properly in browser
  • Sys os, arch, platform
  • Upgrade SWT from 3.4 to 3.5.1
  • Redesign Java extension mechanism to use lib/java/ext/
  • #685: File naming bug?
  • #697: Remove & curry/partial apply operator
  • #731: Method calls should always require parens
  • #740: Cannot load 32-bit SWT libraries on 64-bit JVM
  • #743: Issues building from hg on Snow Leopard
  • #788: Coercion of indexed assignment shortcut
  • #806: can't read MapType from ObjectDeserializer

Build 1.0.46 (8 Sep 2009)

  • Closure variable redesign
  • Change JavaScript field naming model
  • gfx::Border
  • gfx::Pattern
  • Move Halign, Valign, Orientation from fwt to gfx
  • Color: alpha => a, makeHsv, h, s, v, lighter, darker
  • Obj.toImmutable
  • Err.trace now takes options
  • Fix chunked transfer encoding bug in wisp
  • DateTime.timeZone => tz
  • Func.curry => bind
  • WebClient.postStr
  • Fix fwt::ScrollPane to actually work
  • Compiler warning for curry & operator
  • #676: Compiler bug? walkback in closure type inference
  • #679: JVM - emit LocalVariable attr for debuggers
  • #710: Actor programming example?
  • #712: UI enhancements
  • #721: Cookbook versus Examples

Build 1.0.45 (24 Jul 2009)

  • Roll fcode version code 0x01_00_0034 => 0x01_00_0045
  • LoadSymbol opcode
  • Change field storage operator from "@" => "*"
  • fwt::Canvas support in IE using JavaFX
  • DateTime,TimeZone support for JavaScript
  • Fix Int.fromStr to work for signed 64-bit integers with radix 16
  • Split webappClient into sys and dom
  • Change all uses of javascript => js
  • Fix Str indexIgnoreCase/indexrIgnoreCase bug
  • Switch to new, more compressed timezone database format
  • #425: Separate pod install location
  • #558: DocCompiler - Facet Documentation
  • #564: Symbols
  • #606: Partial closure type inference?
  • #620: Dynamically controlled function types
  • #651: Type description of inferred function types
  • #657: Bug in docs with default arguments
  • #659: Rename sys::Namespace to sys::UriSpace
  • #663: wisp sluggish via apachebench
  • #664: Nullable params w/out name in func sig

Build 1.0.44 (25 Jun 2009)

  • Fix bug in WebReq.absUri
  • Fix webappClient to use Uri instead of Str
  • Remove old webServlet code
  • Regex.glob
  • Flux Goto File command
  • DateTime.toHttpStr use toLocale to avoid race conditions
  • FWT Canvas widget (Widget.make is now internal)
  • Graphics removed clipRect, drawPoint
  • fwt::Command.invoke final, override invoked now
  • Int.pow
  • List on JVM now uses backing store with typed array
  • Json fixes
  • Fix Wisp HTTP pipeling bug when no request body
  • JavaScript compiler enhancements for script support
  • 64-bit integer emulation in JavaScript
  • #612: Change signature of List.map and Map.map
  • #617: Compiler bug - traceback in switch with missing case expression
  • #618: Ambiguous method call on java object
  • #629: NoClassDefFoundError when accessing public static final field with JavaFFI

Build 1.0.43 (28 May 2009)

  • FWT port to JavaScript
  • Change default for value type local variables
  • Remove support for "..." range literals (replaced with "..<")
  • Add register parameter to sys::Log.make
  • ObixClient
  • #429: Triple Quoted Strings and DSL Str/Regex
  • #438: DSL Proposal
  • #532: Improved detection immutable closures
  • #578: Uri Interpolation
  • #595: Definite assignment of non-nullable fields

Build 1.0.42 (13 May 2009)

  • Tweaks to flux
  • Loosen restrictions on it/this ambiguity errors
  • webappClient::Effect
  • Disallow nullable types in as expression
  • Fix as with generics to work like cast
  • Rename ActorGroup to ActorPool
  • Move Point, Size, Rect, Hints, Pen, Color, Brush to gfx
  • Color/Font system color/font methods moved to Desktop
  • Date: isYesterday, isToday, isTomorrow
  • DateTime: nowUnique
  • Window: showTrim, activate
  • List: eachRange
  • Duration: nowTicks
  • StrBuf.grow => capacity
  • InStream.makeForStr => Str.in
  • OutStream.makeForStrBuf => StrBuf.out
  • Func/Method call => callList
  • Func/Method callx => call
  • fanx.sys.Interop utility methods
  • #518: Problem in check of reflective field set
  • #520: Flux Last Line
  • #527: Func.curry with optional parameters
  • #528: Compiler bug - duplicate slot x$num
  • #529: Private method in mixin bad classfile
  • #530: Ctor bug with default params
  • #531: Allow curry of private methods
  • #533: Fandoc bug
  • #534: RichText scrollbar bug
  • #542: Compiler - Internal class cast error
  • #543: Compiler - Chaining dynamic calls
  • #544: Move graphics API out of fwt
  • #545: Compiler bug: using ... as ...
  • #546: Packaging of Fan
  • #547: WebOutStream - FavIcon tag
  • #548: Flux bug - tabstops not quite right
  • #551: it and Str interpolation
  • #554: docCompiler bug with |,| signatures
  • #559: API request: sys::StrBuf.remove(Range)
  • #561: Compiler: Internal error - auto-cast of Func
  • #574: Request: Range.random, List.random
  • #591: Flux: View menu in NavBar for .fan files doesn't show
  • #592: Proposal: Method/Func call

Build 1.0.41 (11 Apr 2009)

  • It-Blocks
  • Comma operator for it.add
  • Closure type inference
  • Require return expr to be on same line
  • Duration: minVal, maxVal
  • Move jfan to sys/java; nfan to sys/dotnet
  • Change exclusive range from "..." to "..<"
  • Disallow it-block: Point, Size, Rect, Insets, Hints
  • Require it-block: Font
  • Rename def => defVal: Point, Size, Rect, Insets, Hints, Pen
  • Rename Locale.with => use

Build 1.0.40 (2 Apr 2009)

  • Added sys::Actor API
  • Added sys::Service API
  • Renamed UnknownThreadErr to UnknownServiceErr
  • Refactor fand to work with Services
  • SqlService API changed from Thread to Service
  • Image resize
  • ScrollBar added
  • ProgressBar.value renamed val

Build 1.0.39 (25 Mar 2009)

  • Remove dynamic types
  • Redesign sql::Row API
  • Int: minValue/maxValue -> minVal/maxVal
  • Uuid: removed createdTicks and created
  • Bool: toLocale
  • Date: toDateTime, midnight, plus, minus
  • DateTime: midnight, nowTicks
  • Decimal: toLocale
  • Duration: abs
  • Float: toLocale
  • Int: toLocale, toDuration, toDateTime
  • List: fill
  • Num: localeDecimal, localeGrouping, localePercent, localeInf, localeNaN
  • Map: any, all
  • Str: padr, padl, toLocale
  • Time: toDateTime, toDuration, fromDuration
  • Thread: loopCoalescing, stop/kill
  • Type: toLocale
  • Uri: toLocale
  • Tree: nodeAt
  • Table: rowAt, colAt
  • BuildScript: defaultTarget now defaults to first script declared
  • BuildPod: rename compileJavascript to javascript
  • WebOutStream: css->includeCss, js->includeJs, style, script
  • WebOutStream: change title,h1,h2,h3,h4,h5,h6 to use separate start/end tags
  • Reflection fix to inherit concrete slot over abstract slot if two choices
  • Fix buildall.pods to bootstrap correctly on Unix

Build 1.0.38 (15 Feb 2009)

  • Str: in, toBuf, toDisplayName, fromDisplayName
  • Buf: dup, fill, hmac
  • Duration, DateTime, Date, Time: toIso, fromIso
  • Map: ordered, join, setList, addList
  • Test: verifyNull, verifyNotNull
  • Type: make support for defVal
  • Type: emptyList
  • MimeType: charset, parseParams
  • Add toCode: Bool, Int, Float, Decimal, Uri, Duration, DateTime, Date, Time, List, Map
  • Unsafe wrapper class
  • New compilerJavascript and webappClient APIs
  • New obix API
  • Rework webapp APIs
  • Doc compiler support for @nodoc facet
  • Web Cookie refactor into const class
  • Web Cookie enforce name and value chars and use quoted string value
  • Web Cookie fix use both max-age and expires for cookies for IE and Safari
  • More linux timezone work arounds
  • Json fix for parsing top level array
  • Json.write API change
  • Flux add findInFiles into context popup of dirs
  • Flux fix undo/redo stack to check point on save
  • Flux syntax definition for ActionScript
  • Compiler allow single statement expression based return
  • Compiler allow const field to override a method
  • Compiler fix when local variable shadows field with storage operator
  • Compiler fix when using null safe call with no-leave primitive return
  • Compiler fix when calling super with default params results in stack overflow
  • Compiler fix allow mixins use const keyword
  • Compiler fix for once methods used with subclasses in same pod
  • Compiler fix for construction call against fromStr in super class
  • Compiler fix to check for dup method params and dup enum defs

Build 1.0.37 (11 Jan 2009)

  • Java FFI: array overrides of methods which use primitives or arrays
  • Java FFI: coerce sys::Func to Java interface with one abstract method
  • New sys::Date and sys::Time APIs
  • New sys::Unit API
  • New sys::Uuid API
  • New web::WebClient API
  • Wisp support for chunked transfers and persistent connections
  • Str isAlpha, isAlphaNum
  • OutStream sync
  • Allow closures in constructor to set const fields (same for static ctors)
  • Change Obj.trap arg signature to Obj?[]?
  • Flux enhancements for goto into, find, find in files
  • Protection checks to prevent internal types being used in public APIs
  • Expose sys::File ctor to allow new implementations
  • Optimize common MimeTypes to be interned
  • BuildScript dumpenv target

Build 1.0.36 (13 Dec 2008)

  • Java FFI
  • Use dotnet to denote .NET instead of net
  • Initial json API
  • Remove compiler support for for(...); and while(...);
  • DateTime toJava, fromJava
  • Reorganize icons
  • Fan launcher -fcodeDump option to disassemble a Fan script
  • List, Map eachBreak -> eachWhile
  • Emacs support adm/tools/emacs/fan-mode.el

Build 1.0.35 (14 Nov 2008)

  • Update documentation for nullable and value types
  • New docLib::Fwt chapter
  • New docLang::Deployment chapter
  • Turn on non-null coercion runtime checking
  • Allow function types const fields with implicit toImmutable
  • Allow any list or map type as const field via implicit toImmutable
  • New xml API
  • OutStream.writeXml
  • Fix compiler checking of internal types
  • Fix compiler auto-casting of function types
  • Fix compiler to disallow empty try blocks
  • Fix compiler to allow for(...); and while(...);
  • Fix compiler to include fandoc for enum defs
  • Enhance docCompiler to show overridden slot and inherited fandoc
  • Fwt: file and directory dialogs
  • Fwt: RichText line background styling
  • Flux: persist undo/redo stack between hyperlinks
  • Flux: allow drag and drop of files to hyperlink
  • Flux: highlight current line
  • Flux: show short filenames in console instead of full paths

Build 1.0.34 (24 Oct 2008)

  • Roll fcode version for value-type support
  • Bool, Int, Float are now value types
  • Disallow covariance with value types
  • Disallow === !== is isnot as operators to be used againt value types
  • Java runtime maps sys::Boolean to primitive boolean
  • Java runtime maps sys::Int to primitive long
  • Java runtime maps sys::Float to primitive double
  • Change semanatics of Float.nan compare to match JVM

Build 1.0.33 (13 Oct 2008)

  • Java runtime: fan.sys.Obj -> java.lang.Object
  • Java runtime: fan.sys.Bool -> java.lang.Boolean
  • Java runtime: fan.sys.Int -> java.lang.Long
  • Java runtime: fan.sys.Float -> java.lang.Double
  • Java runtime: fan.sys.Num -> java.lang.Number
  • Java runtime: fan.sys.Decimal -> java.math.BigDecimal
  • Nullable type support
  • Support for parameterized fields (sys::Map.def)
  • Add build::CreateZip task, buildall.fan handles dist zip
  • Fix RichText editor home/end to take whitespace into account
  • Change fwt::Image constructors
  • Add icons to flux history items

Build 1.0.32 (20 Sep 2008)

  • Remove support for old type literal syntax
  • Add adm/tools with fan support for various editors
  • Remove haven pod
  • Fix thread queue notify bug
  • Fix infinite loop in compiler bug
  • Fix race condition loading $Pod class
  • Fix win32 launchers to not require .NET
  • Fix compiler handling of unparameterized generic types like List
  • Fix adm/unixsetup script (mostly)
  • Breaking change to Uri.get (inserted base parameter before checked)
  • Breaking change Locale.prop -> get
  • Process API enhanced: join, out, err, in, mergeErr, and env
  • Int.equalsIgnoreCase
  • Str.indexIgnoreCase, indexrIgnoreCase
  • List.eachBreak, flatten
  • Map.eachBreak
  • Uri.sliceToPathAbs, isPathOnly
  • Pod.uri, loc
  • Type.loc
  • File.normalize now includes file: scheme
  • Require Namespace uris to be path only
  • New UriScheme naming design
  • New docLang chapters: Naming, Conventions
  • New docTool chapters: Flux
  • New docLib chapters: Flux
  • Refactor native methods in fwt
  • fwt::Command localization
  • fwt::Font metrics
  • New fwt::Dialog API
  • New fwt::Desktop and Monitor APIs
  • New fwt::TextWidget base class for Text and RichText
  • New fwt text selection and clipboard APIs
  • Flux prototype!

Build 1.0.31 (24 Aug 2008)

  • New leading whitespace rules for multi-line Str literals
  • Upgrade SWT to 3.4
  • Using statement support in serialization files
  • List.removeRange
  • Range.toList
  • Str.containsChar, trimStart, trimEnd, numNewlines, splitLines
  • StrBuf.join
  • Relax rules for const field types to allow Obj, Obj[], Obj:Obj
  • Change fwt callbacks to be EventListeners
  • Enhance fwt eventing
  • Key eventing and accelerators
  • New fwt::CommandStack API

Build 1.0.30 (30 Jul 2008)

  • Short construction call syntax Type(args)
  • FWT widgets: Combo, Tree, RichText
  • fwt::Command
  • GridPane enhanced, see tab in demo
  • File.listDirs, listFiles, walk, osRoots
  • Expand auto-cast to include any assignable type
  • Weblet.doGet,doPost,... => Weblet.onGet,onPost,...
  • webapp::Widget API changes
  • Add field default to fandoc
  • Change Uri.name to return "" instead of null
  • Rework sample code apps/ to examples/
  • List.binarySearch
  • New type literal syntax: Type#
  • Slot literals: Type#slot or #slot

Build 1.0.29 (18 Jul 2008)

  • New isnot operator
  • New null convenience operators: ?: ?. ?->
  • New FWT widgets: WebBrowser, Text, InsetPane, SashPane
  • FWT graphics: Pen, Brush, Gradient
  • FWT serialization support
  • New icons pod
  • Web view priorities
  • Require indexing open bracket on same line
  • Allow |->Int| to fit |->Void|
  • Sys.idHash
  • List.findIndex, indexSame, containsSame, containsAllSame, removeSame
  • Pod.log, Type.log
  • Str.split(Str) => Str.split(Int,Bool)
  • Compiler implicitly generates toImmutable for const List/Map/Type fields

Build 1.0.28 (25 Jun 2008)

  • Fix bug in threading flow control
  • Map.def
  • Update unix scripts to use bash
  • Fix timezone on unix when GMT offset
  • Require call open paren on same line
  • With-blocks support implicit call to add
  • Support @collection facet in readObj and writeObj
  • C# fixes including filtered catch blocks
  • Launcher exe and bash support for lib/java/ext
  • Fix closures inside once methods
  • Improved support for calling main
  • Rename some of the shortcut operators methods
  • New fwt pod which wraps SWT

Build 1.0.27 (28 May 2008)

  • Fix this return for mixins
  • Sanity check for bootstrap build
  • sys::MimeType, Uri.mimeType, File.mimeType
  • New email pod for MIME and SMTP support
  • Charset.make => fromStr (now serializable simple)
  • Thread.isService, findService
  • Fix fandoc blockquotes
  • Native fields
  • Allow non-storage fields in const class
  • Fix constructor, field init ordering
  • Allow single statement for try, catch, finally
  • Log.setLevel() => Log.modified
  • File.setModified() => File.modified

Build 1.0.26 (26 Apr 2008)

  • Require f suffix for float literals
  • Decimal type and literal syntax
  • Decimal API enhancements: InStream, OutStream, Num, Str
  • This return types
  • Update APIs to use return This return
  • Fix Firefox3 form handling
  • Allow this and super keywords in string interpolation
  • Fix various fandoc bugs seen on discussion forum

Build 1.0.25 (16 Apr 2008)

  • Fix Unix build problems
  • Sys.env is now case insensitive map
  • File.pathSep
  • Skip .NET compiles if not on Windows

Build 1.0.24 (14 Apr 2008)

  • Cleanup old ruby scripts
  • Cleanup docs

Build 1.0.23 (14 Apr 2008)

  • Weekday, Month increment/decrement
  • Enhance webapp steps
  • File support for checkSlash
  • New docs: Namespaces, Fandoc, Web, WebApp, Widget, Maps
  • LogStep for W3C extended log format
  • Haven enhancements - prepared statements
  • Duration boot, uptime, toLocale
  • Sys.diagnostics (mem, threads, classes)
  • Uri queryPlus and escaping fixes

Build 1.0.22 (30 Mar 2008)

  • web::Cookie support
  • WebSession support
  • Once methods
  • Func.curry
  • Slot, Field, and Method are now const
  • Make parameter names optional in function signatures
  • New Cookbook chapters: Reflection
  • Unix launcher scripts

Build 1.0.21 (10 Mar 2008)

  • Haven ORM engine
  • Type immutability
  • Doc meta-data, doc default expressions
  • File copyTo, copyInto, moveTo, moveInto, rename, open, mmap
  • Buf redesign -> MemBuf, FileBuf, MmapBuf
  • Redesign Resource -> Namespace
  • Uri pathOnly, relToAuth, plusName, tail -> slice, minus -> relTo
  • Allow const field set in ctor with-block
  • Rename test pods: testSys, testNatives, testCompiler
  • Move Windows executables from bin/win/ to bin/
  • Sys.compile and script caching
  • Coverage for .NET sysTests 364/375 - 97%

Build 1.0.20 (13 Jan 2008)

  • Fan shell
  • Type literal support in serialization syntax
  • More docs (docTools, docIntro)
  • Rework build scripts to use facets

Build 1.0.19 (30 Dec 2007)

  • Basic fand bootstrap
  • Tweaks to InStream.readObj
  • Logging APIs
  • File now subclasses Resource
  • WebService pipeline
  • Refactor Resource implementation
  • SysResources
  • Sys.appDir
  • Raw string literals
  • Regex regular expression API
  • Optimize pod/type lazy loading
  • Pod level user defined facets
  • Type database

Build 1.0.18 (13 Dec 2007)

  • Int, Str, Month, Weekday, DateTime localization methods
  • DateTime string encoding/decoding
  • Resource and MemResource APIs
  • Support final override modifiers
  • Int.random
  • Pretty stack traces
  • Tons of new documentation

Build 1.0.17 (5 Nov 2007)

  • Obj auto-casts to anything
  • Use serialization for thread messaging when not immutable
  • Dynamic methods
  • Buf: hex, base64, digest support
  • TimeZone database and buildtz script for importing Olsen database
  • Rename Time -> DateTime
  • DateTime ticks to date/time calculations
  • Locale API
  • Rename parse -> fromStr

Build 1.0.16 (11 Sep 2007)

  • Facets completed
  • Override implies virtual fix
  • Roll fcode version to support method var attributes

Build 1.0.15 (5 Sep 2007)

  • Serialization support
  • Simple literals
  • With-blocks
  • Refactor fcode attributes
  • New facet design

Build 1.0.14 (12 Aug 2007)

  • Add maxStack to fcode format

Build 1.0.13 (4 Aug 2007)

  • Indexed assignment expressions: x[y] += z
  • Buf no longer mixins InStream and OutStream
  • InStream and OutStream changed from mixins to classes
  • Fix case insensitive Map equality/hash
  • FileWeblet with ETag and Last-Modified support
  • Rewrite Uri with custom parser
  • Allow escape sequence in Uri literals
  • Uri decoding/encoding
  • Fix maxLocals, maxStack in emitter

Build 1.0.12 (17 Jul 2007)

  • InStream.eachLine
  • Covariant field overrides of methods

Build 1.0.11 (10 Jul 2007)

  • Java runtime dependency checking
  • Compiler dependency checking
  • MethodParam->Param, fieldField->of, paramType->of, returnType->returns
  • Split Func out of Method

Build 1.0.10 (7 Jul 2007)

  • Remove all the old Java based compiler code
  • Change Int intern to -256 to 1024
  • Major refactoring of compiler - fcode now implements namespace mixins
  • Ability to compile against any arbitrary dependsDir

Build 1.0.9 (1 Jul 2007)

  • Add: List.containsAll
  • Remove: Type.sourceFile, Type.lineNumber, Slot.lineNumber
  • Hidden: Field.getter, Field.setter
  • Dynamic types
  • Dynamic types emitter for subclass with type per instance
  • Dynamic fields
  • New sql pod using JDBC
  • New chapters: docLang::DynamicTypes, docLib::Sql

Build 1.0.8 (30 Jun 2007)

  • Add doc target to buildall script
  • Add StrBuf.remove, buff up test suite
  • DocLang chapters: Expressions, Statements, Exceptions, TypeSystem, CompilationUnits, Fields, Methods
  • InStream peek, peekChar, readStrToken
  • Changes to web API
  • New wisp pod with simple web server implementation

Build 1.0.7 (12 May 2007)

  • New inet pod
  • IpAddress, TcpSocket, TcpServerSocket
  • Str.equalsIgnoreCase, compareIgnoreCase, any, all
  • Time.now with tolerance
  • Time.parseHttp, formatHttp
  • InStream.readLine max parameter
  • Map cannot have null keys
  • Map.caseInsensitive
  • New fandoc pod to parse fandoc into DOM
  • New docCompiler pod to generate HTML documentation
  • Doc chapters: docIntro::Overview, docLang::Literal
  • .NET runtime support for most of sysTest

Build 1.0.6 (5 Feb 2007)

  • Make sys::Err const
  • Obj.isImmutable, List.toImmutable, Map.toImmutable
  • Slot.isConst for thread-safe methods
  • Thread API

Build 1.0.5 (21 Jan 2007)

  • Use () operator on sys::Methods as callx() shortcut
  • Curried methods
  • Use soft references for pod cache
  • InStream, OutStream.charset changed to abstract field
  • Float constants changed to static const fields
  • Fan.exe now uses Fan compiler to run scripts

Build 1.0.4 (14 Jan 2007)

  • Virtual fields
  • Move field accessor generation to Parser
  • Fix closures in field accessor methods
  • Fix multiple static initializer closures and scoping
  • Optimize if(true), if(false)
  • Fix indirect mixin router emitting

Build 1.0.3 (8 Jan 2007)

  • Fan launcher options (--v and --D)
  • Refactor Sys methods into respective classes
  • Field storage @ operator
  • Storage fcode flag

Build 1.0.2 (1 Jan 2007)

  • New pod format for pod meta-data and facets

Build 1.0.1 (1 Jan 2007)

  • First official build
  • Both old Ruby build scripts and new Fan build scripts

Dec 2006

  • CLR protected region support
  • Try finally blocks
  • Virtual fields (mixins support abstract fields)
  • Mixin reflection
  • Covariant return types
  • Change inheritance syntax to use colon
  • Named super calls
  • Const fields and const classes
  • Launcher C++ executables for Win32
  • Transition from Ruby build scripts to Fan build scripts

Nov 2006

  • Deprecate DupDown (dup_x1) opcode
  • Nested closure support
  • List.dup(), Map.dup()
  • Not a statement checking
  • Protection scope checking

Oct 2006

  • Props file and Sys.env
  • Constant folding in compiler
  • Compiler can finally compile itself!

Sep 2006

  • First Fandoc goes live on fandev.org
  • Precompiled Java bytecode mode

Aug 2006

  • Fan compiler does first end-to-end compile
  • Fanp disassembler ported from Java to Fan
  • Zip API

Jul 2006

  • Parser rewritten in Fan
  • Version API
  • Using/import statements
  • Facets
  • Uri API, refactor File to use Uri
  • Stub Time API

Jun 2006

  • Dynamic -> call operator
  • Try/catch blocks
  • Initial web API
  • String interpolation
  • CompareNull, CompareNotNull opcodes
  • Tokenizer rewritten in Fan

May 2006

  • Refactor Err to use Fan type system
  • Math methods for Int, Float
  • Switch statement
  • New character methods for Int, Str

Apr 2006

  • Tomcat integration
  • Field accessors
  • Enums
  • Charset I/O support

Mar 2006

  • Native methods
  • Superclass constructor chaining
  • Closures
  • I/O, List, and Map APIs
  • Mixins

Feb 2006

  • Refactor to use fcode intermediate format
  • Refactor local variables for .NET emit
  • Fandoc comments

Jan 2006

  • Generic types
  • Support for is and as operators
  • Type literals
  • Method parameter defaults
  • Unit test harness

Dec 2005

  • Redesign to use pure OO (everything boxed)
  • Type inference for locals
  • Duration literals
  • Shortcut operator overloading
  • Static initializers
  • Comparision operators
  • Constructors

Nov 2005

  • Casting
  • Primitive operators and auto-boxing (since removed)
  • String concat, unary operators, assignment operators
  • Local variables

Oct 2005

  • Original jblock and nblock native method design
  • Methods
  • Fields
  • Type checking
  • Method argument overloading (since removed)
  • New operator (since removed)
  • If, throw statements
  • Class aliasing (original Java/.NET integration strategy)

Sep 2005

  • Begin work on Java version of Fan parser
  • Compiler emits straight to Java bytecode or .NET IL
  • Basic expr compilation
  • Basic class, method support

常见问题(Faq) ​

如何联系? ​

问题或反馈请发到 讨论组,也可发邮件:

  • Brian: briansfrank at gmail dot com
  • Andy: afrankvt at gmail dot com

这门语言以前是不是叫 Fan? ​

是的。语言最初叫 Fan,取自我们居住的弗吉尼亚州里士满「The Fan」街区——那是世纪之交以人为中心(而非汽车)规划的街区。后来因「Fan」不便搜索,2009 年 11 月改名为 Fantom。

Fantom 使用什么许可证? ​

Fantom 使用 Academic Free License 3.0,属 BSD 风格(与 Apache 2.0 很接近)。

Fantom 目前状态如何? ​

Fantom 已成熟稳定,可用于生产;自 2008 年起已用于商业软件。

版本号如何编号? ​

版本号为用点分隔的三或四段十进制整数:major.minor.build.patch。当前 1.0 以递增构建发布:1.0.30、1.0.31 等。


Hello World(HelloWorld) ​

安装与配置 ​

Fantom 以 zip 发行,解压到本机后,请把正确的 bin 目录加入 PATH:

{fan.home}/bin

首次安装后会自动尝试使用当前配置的 Java VM(需 Java 8+)。正常时可运行 fan -version:

C:\dev\fan\bin>fan -version
Fantom Launcher
Copyright (c) 2006-2020, Brian Frank and Andy Frank
Licensed under the Academic Free License version 3.0

Java Runtime:
  java.version:    1.8.0_91
  java.vm.name:    Java HotSpot(TM) 64-Bit Server VM
  java.vm.vendor:  Oracle Corporation
  java.vm.version: 25.91-b14
  java.home:       /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre
  fan.platform:    macosx-x86_64
  fan.version:     1.0.74
  fan.env:         sys::BootEnv
  fan.home:        /work/fan

若不行,可尝试:

  1. 复查 setup 说明
  2. 安装 Java 8 或更高版本后重试
  3. 显式 配置 JVM 安装路径

Fantom Shell ​

Fantom Shell 是求值表达式与语句的命令行工具,适合试写。运行 fansh,再调用 Obj.echo:

C:\dev\fan\bin>fansh
Fantom Shell v1.0.74 ('?' for help)
fansh> echo("hello world #1")
hello world #1
fansh> quit

更多说明见 Fansh。

Fantom 脚本 ​

也可把 .fan 文件当脚本执行。脚本须含完整类定义,并有名为 main 的方法。创建 hello.fan:

class Hello
{
  static Void main() { echo("hello world #2") }
}

把脚本文件名传给 fan:

C:\dev\fan\bin>fan hello.fan
hello world #2

与 Java/C# 不同,main 不必声明参数;需要时可声明 Str[],或通过 Env.args 获取。

运行脚本详见 Fan。另见 unix setup 与 windows setup,可不显式调用启动器直接执行脚本。

Fantom Pod(程序包) ​

生产环境通常把代码组织成预编译模块,即 pod。用 Fantom 构建工具包 构建。创建名为 hello 的新 pod 可用 init:

C:\projects> fan build init hello

会生成类似目录:

hello
├── etc
├── fan.props
├── lib
└── src
    ├── build.fan
    └── hello
        ├── build.fan
        ├── fan
        └── test

在 src/hello/fan/ 下添加 Main.fan:

hello
└── src
    └── hello
        └── fan
            └── Main.fan

其中声明名为 Main 的类:

class Main
{
  static Void main() { echo("hello world #3") }
}

构建文件本身就是普通 Fantom 脚本,用于编译该 pod:

C:\projects> cd hello\src
C:\projects\hello\src> fan build.fan
compile [hello]
  Compile [hello]
    FindSourceFiles [1 files]
    WritePod [C:\projects\hello\lib\fan\hello.pod]
BUILD SUCCESS [70ms]!

此时 lib/fan 下应有 hello.pod。若类名 Main、方法名 main,可用 fan 运行:

C:\projects\hello> fan hello
hello world #3

C:\projects\hello> fan hello::Main
hello world #3

C:\projects\hello> fan hello::Main.main
hello world #3

在 pod 中运行方法见 Fan,构建见 Build。

Fantom WebApp ​

下面用启动脚本拉起内置 Web 服务器,挂一个简单的 hello WebMod,做成最小 Web 应用。

示例代码(见 examples/web/hello.fan):

using util
using web
using wisp

class WebHello : AbstractMain
{
  @Opt { help = "http port" }
  Int port := 8080

  override Int run()
  {
    wisp := WispService
    {
      it.port = this.port
      it.root = HelloMod()
    }
    return runServices([wisp])
  }
}

const class HelloMod : WebMod
{
  override Void onGet()
  {
    res.headers["Content-Type"] = "text/plain; charset=utf-8"
    res.out.print("hello world #4")
  }
}

启动脚本含两个类。WebHello 继承 AbstractMain,提供标准 main 脚手架;主要作用是把 Web 服务器配在 8080,并挂上处理 HTTP 的 WebMod。

HelloMod 继承 WebMod(Fantom 的 servlet 式 Web API),只设置 Content-Type 并写出响应文本。

运行该脚本:

C:\dev\fan\bin>fan ../examples/web/hello.fan
[09:57:40 11-Apr-08] [info] [fand] booting...
[09:57:40 11-Apr-08] [info] [web] WispService started on port 8080

You should be able to hit http://localhost:8080/ with your browser!


许可证(License) ​

法律文本保留英文原文(Academic Free License 3.0)。

Academic Free License 3.0 ​

  1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
    1. to reproduce the Original Work in copies, either alone or as part of a collective work;
    2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
    3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
    4. to perform the Original Work publicly; and
    5. to display the Original Work publicly.
  2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
  3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
  4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
  5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
  6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
  7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
  8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
  9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
  10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
  11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
  12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
  13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
  14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
  15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
  16. Modification of This License. This License is Copyright (c) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

Fantom 说明(Readme) ​

快速链接 ​

Setup ​

  1. 确保 {home}/bin 在 PATH 中
  2. Fantom 启动器:
    • Unix: "bin/fan" bash script
    • Windows: "bin/fan.exe" executable
  3. 验证:fan -version

更多信息见 docTools::Setup

工具 ​

常用工具:

  • fan: Fantom launcher for scripts and pods
  • fansh: Fantom 交互式 Shell
  • fant: Fantom test runner
  • IDEs: different IDE and editor options

更多信息见 docTools

文档 ​

在线文档:https://fantom.org/doc/。

也可在本地用下列命令生成 HTML 文档:

fan compilerDoc -all

会为本地环境中所有 pod 生成 HTML 文档。

社区 ​


从这里开始(StartHere) ​

深入学习 ​

通过下列链接了解 Fantom:

快速开始 ​

想马上动手写代码:

社区资源 ​

另见 IDE 页 了解社区工具。

文档组织 ​

文档与 API 按模块(pod)组织。索引分为 手册(manuals) 与 API。API 由源码生成(类似 Javadoc);手册按主题分章:

此外 examples 提供 HTML;示例均为可当脚本运行的独立程序。

学习 Fantom ​

要深入学习,先浏览 docIntro 打基础;再通读 docLang(按书设计)。写代码时多用 examples 与 API 参考学标准库;做真实应用时务必掌握 单元测试 与 构建脚本。

参与贡献 ​

提问与反馈请到 讨论组,也可直接 联系我们。欢迎反馈!


特性速览(Tour) ​

Hello World ​

We start our Fantom 特性速览, with the quintessential hello world:

class HelloWorld
{
  static Void main()
  {
    echo("hello world")
  }
}

与 Java/C# 的细微差别:

  • 所有类型名均大写,包括 Void(没有原始类型及其关键字)。
  • 类与方法默认 public。
  • 可用 echo 写控制台,或用 Env.cur.out。
  • 语句可用换行结束(也可用分号)
  • 可声明 Str[] 参数,或从 Env.args 读取

字面量(Literals) ​

Fantom 支持与 Java/C# 类似的基本 字面量,并加入不少脚本语言常见字面量:

true                // Bool literal
123                 // Int literal
0xcafe_babe         // Int hex, can use _ as separator
'\n'                // Int character literal
"hi"                // Str literal
3.4f                // Float literal
3.4d                // Decimal literal
5sec                // Duration literal
`/dir/file.txt`     // Uri literal
[0, 1, 2]           // List literal
[,]                 // List literal for empty list
[1:"one", 2:"two"]  // Map literal
[:]                 // Map literal for empty map
Int#                // Type literal
Int#plus            // Slot literal

表达式(Expressions) ​

表达式语法大体沿用 Java/C#:

obj.toStr()   // call the toStr method
obj.toStr     // parenthesis are optional
obj.field     // access field
x && y        // logical and
x === y       // reference equality
x == y        // shortcut for x.equals(y)
x < y         // shortcut for x.compare(y) < 0
x <=> y       // shortcut for x.compare(y)
x + y         // shortcut for x.plus(y)
x = y         // assignment
a ? b : c     // ternary operator
a is Str      // instance of operator
a isnot Str   // convenience for !(a is Str)
a as Str      // like C# as operator
a?.func()     // safe invoke operator (like Groovy)
a ?: b        // elvis operator for a != null ? a : b

多数运算符其实是方法调用的语法糖,例如:

3 + 4  =>  3.plus(4)

字符串(Strings) ​

字符串支持 插值,用 $ 嵌入表达式:

// string interpolation
"$x + $y = ${x+y}"

// longhand for above
x.toStr + " + " + y.toStr + " = " + (x+y).toStr

简单变量或点表达式前加 $ 即可;更复杂表达式用花括号包裹。

还内置本地化字符串:

// lookup a locale props value
"$<fwt::err.name>"

// add locale lookup and automatically add default
// key/value to the pod's locale/en.props resource file
"$<fileNotFound=The file was not found>"

语句(Statements) ​

语句 大体类似 Java/C#:

Str s := "hello"    // local variable declaration
s := "hello"        // type inference
if (x) {} else {}   // if/else statement
while (x) {}        // while

最显眼的是用 := 声明局部变量。支持类型推断,可省略类型。用 := 而非 = 区分声明与赋值,避免变量名拼写等低级错误。

字段(Fields) ​

字段 自动带访问器,无需冗长样板代码:

class Person
{
  Str name
  Int age
}

上面代码大致等价于下列 Java:

public class Person
{
  public String name() { return name; }
  public void name(String x) { name = x; }

  public int age() { return age; }
  public void age(int x) { age = x; }

  private String name;
  private int age;
}

Java/C# 写那么啰嗦,是为了偶尔拦截 get/set。在 Fantom 中字段总是经自动生成的 getter/setter 访问,且可覆盖:

class Person
{
  Str name
  Int age { set { checkAge(val); &age = it } }
}

it 表示用来赋值的值;&age 表示写 age 的实际存储(不走 setter)。

方法(Methods) ​

方法 参数可有默认值:

class Person
{
  Int yearsToRetirement(Int retire := 65) { return retire - age }

  Int age
}

once 方法 仅首次调用时计算,之后返回缓存:

once Str fullName() { return "$firstName  $lastName" }

构造器(Constructors) ​

不同之处:构造器 是具名方法:

class Point
{
  new make(Int x, Int y) { this.x = x; this.y = y; }
  Int x
  Int y
}

// make a point
pt := Point.make(30, 40)   // longhand
pt := Point(30, 40)        // shorthand

约定主构造器叫 make,其它以 make 为前缀。若未提供,编译器自动生成 make。

继承(Inheritance) ​

继承 语法类似 C#:

class Animal
{
  virtual Void talk() { echo("talk") }
}

class Dog : Animal
{
  override Void talk() { echo("bark") }
}

注意 virtual 与 override。与 Java 不同,方法须显式标 virtual 才可被覆盖——覆盖需刻意设计。

混入(Mixins) ​

Java/C# 用接口做多类型继承。Fantom mixin 类似接口,但可带方法实现:

mixin Audio
{
  abstract Int volume
  Void incrementVolume() { volume += 1 }
  Void decrementVolume() { volume -= 1 }
}

class Television : Audio
{
  override Int volume := 0
}

用等价 Java 最容易理解上面的 Fantom 代码:

interface Audio
{
  int volume();
  void volume(int volume);
  void incrementVolume();
  void decrementVolume();
}

class AudioImpl
{
  static void incrementVolume(Audio self) { self.volume(self.volume() + 1); }
  static void decrementVolume(Audio self) { self.volume(self.volume() - 1); }
}

class Television implements Audio
{
  int volume() { return volume; }
  void volume(int x) { volume = x; }

  void incrementVolume() { AudioImpl.incrementVolume(this); }
  void decrementVolume() { AudioImpl.incrementVolume(this); }

  private int volume = 0;
}

注意抽象字段:与接口一样 mixin 不能真正持有状态,但可声明抽象字段(定义 getter/setter,无实际存储)。

闭包(Closures) ​

Fantom 支持一等 函数 与 闭包,标准 API 大量使用函数式。闭包语法有点像 Ruby;集合遍历几乎总用闭包:

// print a list of strings
list := ["red", "yellow", "orange"]
list.each |Str color| { echo(color) }

// print 0 to 9
10.times |Int i| { echo(i) }

闭包函数签名可从上下文 推断:

10.times |i| { echo(i) }

It-block 是隐含参数为 it 的特殊闭包:

10.times { echo(it) }

也常用闭包把代码块传给标准方法:

// sort a list of files by timestamp
files = files.sort |a, b| { a.modified <=> b.modified }

闭包本质上就是创建 Func 实例的表达式:

// create a function that adds two integers
add := |Int a, Int b->Int| { return a + b }
nine := add(4, 5)

动态编程(Dynamic Programming) ​

需要时可用关键特性摆脱强类型束缚:用 . 访问时编译器做类型检查;也可用 -> 动态调用跳过检查:

obj->foo         // obj.trap("foo", [,])
obj->foo(2, 3)   // obj.trap("foo", [2, 3])
obj->foo = 7     // obj.trap("foo", [7])

-> 其实是调用 Obj.trap 的语法糖;默认用反射调方法或访问字段。也可覆盖 trap 以创意方式处理动态调用。

另一便利是把 Obj 当通配:可赋给任意类型或传入方法而无须显式转型:

Obj obj
Str s := obj->foo     // Str s := (Str)obj->foo
Int.fromStr(obj)      // Int.fromStr((Str)obj)

可空类型(Nullable Types) ​

类型可为可空或不可空。不可空保证永不存 null;可空在类型后加 ?。默认不可空,除非另行指定:

Str   // never stores null
Str?  // might store null

编译器会拦明显错误(如对不可空使用 null 字面量)。可空强制为不可空时运行时还有隐式检查,使 null 问题在引入点快速失败,而不是扩散到无关代码。

序列化(Serialization) ​

序列化 语法是编程语言的子集,因而可在代码里用序列化搭建任意复杂对象结构,且对人友好可读可写:

@Serializable class Person
{
  Str? name
  Int age
  Person[]? children
}

// built up tree of objects in code (or from file)
homer := Person
{
  name = "Homer Simpson"
  age  = 39
  children =
  [
    Person { name = "Bart";   age = 7 },
    Person { name = "Lisa";   age = 5 },
    Person { name = "Maggie"; age = 1 }
  ]
}

// dump serialized structure to console
Env.cur.out.writeObj(homer, ["indent":2])

不可变性(Immutability) ​

类可声明为 const 以创建 不可变 类:

const class Point
{
  new make(Int x, Int y) { this.x = x; this.y = y }
  const Int x
  const Int y
}

const 类的字段本身也须 const,并在构造器中赋值。为防线程共享可变状态,静态字段必须始终为 const:

const static Point origin := Point(0, 0)

List/Map 可用 toImmutable 变为不可变:

vowels := ['a','e','i','o','u'].toImmutable

Actors(并发角色) ​

Fantom 含 Actor 框架 用于构建并发应用:

// spawn actor which aynchronously increments an Int msg
actor := Actor(group) |Int msg->Int| { msg + 1 }

// send some messages to the actor and block for result
for (i:=0; i<5; ++i) echo(actor.send(i).get)

为什么选择 Fantom(WhyFantom) ​

概述 ​

Fantom 存在的理由:编写可移植软件——服务端跑在 JVM,并转译为 JavaScript 做 Web 前端。2005 年起步,正值 Java 语言停滞期,也早于任何可转译到 JS 的静态类型方案。

可移植性 ​

最初目标是同时无缝跑在 JVM 与 .NET CLR。后来重心转向 JavaScript 以在浏览器运行。.NET 运行时已不再积极开发,但足以跑核心栈。如今专注 JVM,并为 Web 应用转译到 JavaScript。

独特之处在于从一开始就面向多运行时。因此用一套干净 API 抽象底层 Java/C#/JS。我们认为这是主要优势之一:得以打造比底层更优雅易用的系统 API。

从底层为可移植而设计,面向新平台应相对容易。未来可能包括 iPhone 的 Objective-C/Swift、LLVM 或 WASM。

优雅的 API ​

审美因人而异——但我们执着于把 Fantom API 做美。Java/.NET API 多年积累已显杂乱。有些 API 很糟:Java 的 Calendar 是反面教材,要用怪异的 C 式常量,月份从 0 起、星期却从 1 起!

部分是历史包袱,更多是 Java/.NET 的 API 哲学:大量过度抽象又能力不足的小类。Fantom 相反——少量但强大的类。例如 java.io 有 60+ 类型,做点事要三四个类,忘了 缓冲流 性能就崩;即便如此,把文件按行解析仍很繁琐。Fantom 把多数 java.io 能力收成四个类:File、Buf、InStream、OutStream。默认缓冲,支持二进制与文本,并内置大量便捷方法。

强类型与动态类型 ​

业界在强类型与动态类型阵营间分裂。我们觉得两边都偏极端,故 Fantom 走中间路线。

强类型一面:字段与方法签名必须标注类型。我们认为这很好。编程是在组件间建立明确契约——类型系统不完美,但擅长文档化与定义契约。若方法吃 Str 返回 Int,就应写在代码里。

除此之外对类型声明较宽松:局部变量与集合字面量常用类型推断。

有时确实需要动态类型。关键特性是可用强类型或动态方式调用:. 经编译器检查并编成高效操作码;-> 则动态调用、跳过类型检查,可做 鸭子类型。-> 实际路由到可覆盖的 Obj.trap,便于各种动态设计。

泛型(Generics) ​

有趣的是,Fantom 在减弱过度强类型时,Java/C# 却在加强。泛型即一例——二者近年才加入。完全参数化类型系统很复杂;我们努力在价值与复杂度间找 平衡。

目前泛型是有限支持:尚无用户自定义泛型。但内置 List、Map、Func 可用特殊语法参数化。例如 Int 列表写成 Int[](类似 Java/C# 数组语法)。这一折中既发挥泛型价值,又不拖垮类型系统。

模块化(Modularity) ​

模块化是 CS 入门就学的好设计基础:把程序拆成可复用块,便于版本管理、分发,并通过清晰依赖组合。

Java 几十年所谓模块管理就是 JAR——等于没有。Jigsaw 到 Java 9 才发布,要克服多年无模块的惯性,且为了往非模块系统上叠模块而过度复杂。

JavaScript 也是天生无内置模块的典型;像 Java 一样模块是事后补的,且晚于 Fantom 多年。

.NET 在模块化上较认真,高层版本、GAC 等设计不错,细节却不尽如人意。Java 用简单灵活的 ZIP;.NET 用不透明 DLL 与大量 Windows 包袱,难用。还要另带未文档化的 pdb 才能得到有意义堆栈,更不合理。

Fantom 一切围绕称为 pod 的模块单元:版本与部署单位,经清晰依赖组合;像 Java 一样就是可轻松查看的 ZIP。

命名空间与部署 ​

Java(.NET 较轻)把命名空间与部署分开:包管命名空间,JAR 管部署,二者无对应,加剧 classpath 地狱——缺类时类名看不出在哪个 JAR。

类型命名空间与部署命名空间虽灵活,也添不必要复杂度。Fantom 用固定三层 pod::type.slot:第一层永远是 pod 名,同时也是部署与版本单位。用 pod 组装大型系统时这种一致性很重要——如序列化类型 acme::Foo 立刻知道要哪个 pod。

面向对象 ​

Java 重要折中之一是原始类型:不是真正 Object,导致各种特例;但对数值性能很重要。后来用自动装箱打补丁,类型系统仍割裂。

.NET 用值类型优雅解决:有原始类型性能,又干净地继承 System.Object。

Fantom 跟随 .NET 值类型模型:Bool、Int、Float 在 Java 上是原始类型、在 .NET 是值类型,性能等同 boolean/long/double,又干净继承 Obj 形成统一层次;编译器按需自动装箱拆箱。

函数式编程 ​

Fantom 起步时 Java 几乎没有函数式支持。Java 8 加了很多,但函数仍非类型系统中真正的一等公民。

Fantom 从一开始就把函数当一等对象;闭包是语言关键特性,API 在合适处使用函数与闭包。

声明式编程 ​

代码里常需声明数据结构(如 list/map)。在 Java/C# 里这些事噪音大、冗长难看,于是声明部分常被赶到 XML/JSON/YAML。

Fantom 把声明式编程纳入语言:list、map、range、uri、duration 均有字面量;还有可读可写的文本序列化语法,是语言的干净子集——可把序列化文件直接贴进源码当表达式。

并发(Concurrency) ​

主流语言多用共享状态:线程共享内存,须仔细加锁防竞态,锁用错会死锁。这是较低层的并发手段,也难以做出可组合组件。

Fantom 用若干技术应对并发:

  • 语言内置不可变(线程安全类)
  • 静态字段必须不可变(无共享可变状态)
  • Actor 消息传递(Erlang 风格并发)

细节之处 ​

新语言的好处是能从白纸修掉烦人细节(Fantom 就是为解决我们自己的痛点)。相对 Java,我们还加入:

  • 默认参数:方法可有默认实参——不必再为便捷重载写样板代码
  • 类型推断:局部变量可推断类型
  • 字段访问器:隐式定义——又一处 Java 惯用写法信噪比低的地方
  • 可空类型:在代码中声明参数/返回值是否允许 null,而非只靠文档
  • 受检异常:受检异常是有害语法盐——难扩展、难版本演进、妨碍可组合系统,这也是 Anders Hejlsberg 不在 C# 中采用的原因。
  • 数值精度:不提供 32/16/8 位整型与浮点,只有 64 位 Int 与 Float,消除文件长度、Unicode、超大列表等精度复杂度。底层 Java/C# 实现仍可能用 16 位字符与 32 位 int,但 Fantom API 面向未来。