Skip to content

Implement set!; EOL GoVar's, ref, and some var functionality

Pre-release
Pre-release
Compare
Choose a tag to compare
@jcburley jcburley released this 28 Apr 19:33
· 434 commits to gostd since this release

The (set! ...) special form is implemented, and supersedes use of (var ...) on field references. E.g. instead of (var-set (var (.member instance)) value), use (set! (.member instance) value), which is much more Clojure-like.

The GoVar object no longer exists. Variables are now implemented as GoObjects that wrap references (pointers) to the respective variables, with automatic derefencing for ordinary usage. So, SomeVar yields a snapshot of the SomeVar variable; now, (set! SomeVar new-value) is used to change the value of the variable, and (set! (.SomeField SomeVar) new-value) to change the value of a specific field when SomeVar is a struct. ((deref SomeVar), aka @SomeVar, no longer work on global variables as previously described for earlier versions of this fork. Similarly, (var (...)) is no longer supported.)

The ref function (in joker.core) has been removed, as it was not similar enough to Clojure's ref. A replacement function (or possibly a special form) is being contemplated for a future release.

Values of type error are now wrapped in GoObjects instead of being converted into Strings. This allows receivers for those values to be invoked, and is consistent with preserving the native type when not precisely implemented by a Joker type (in this case, Error, an abstract type). When an error type is needed, the supplied expression may be String or GoObject[error].