2024-09-16: Fuzion September Update
Major new features in the Fuzion language include type constraints in preconditions and conditionals, which permits specialized code, and various improvements for effects.
Our thanks go to Lisa Wirkner who worked on on a simple internationalization effect during a short internship in August. This sparked support for reference effects and dynamic binding when calling effect operations which leads to a cleaner integration of effect instances with Fuzion's inheritance mechanism.
- General
- Fuzion language
-
Type constraints can now be made more restrictive in preconditions and conditional code, fix #967 (#3480)
This provides a simple mechanism to add inner features that require additional type constraints such as
Sequence.findthat requires the element type toTto be constrained byproperty.quatable. As a precondition, this is written aspublic find(pattern Sequence T) option i32 pre T : property.equatable => ...using a new operator
infix :that operates on typesType.infix : (T type) boolSuch type constraints can also be done using conditions as follows:
f(x T) => if T : String say x.byte_countThese type-tests are evaluated at compile-time, there is no code generated for the type tests. Instead, the compiler validates that preconditions that impose addition type constraints can statically be verified to be met for every call of a corresponding feature.
-
Effects in fuzion now clearly distinguish effect types and effect instances: For a given effect type, one may instate any instance that is assignable to the effect type.
This means that instances installed for effect types that a reference types may be child features that inherit from the effect type, redefinition may be used to implement effect operation and dynamic binding is used when these operations are used.
Here is an example of an effect
Colorwith an operationgetand two instancesgreenandpurple:Color ref : effect is get String => abstract green : Color is redef get => "green" purple : Color is redef get => "purple"To
instateone of them, we need to callinstateon the effect typecolor, providing an argument of the value typegreenorpurple:Color.instate green ()->{say "color is {Color.env.get}"} Color.instate purple ()->{say "color is {Color.env.get}"}This avoids the need to have separate effect handler features that implement the operations and are called using dynamic binding from the effect's operation. The drawback is that to instate an effect, we now need the effect value and the effect type since the value's type might be different.
related pull requests
lib: support
refeffect types, make all effects simple, removeeffect_mode(#3574)bin/ebnf.fz: switch to
instate_selfsyntax of effects (#3584)C: fix code for
effect.type.instate0intrinsic for unit type effect (#3606)fix add_simple_test, replace
gobyinstate_self(#3594)jvm: Fix code generated for intrinsic
effect.instate0on a unit type effect (#3610)update example_1,
go ()->is nowinstate_self ()->(#3639)
-
Improved handling of semicolon after lambda expression, in particular, code like
m := (1..10).map x->2*x; say mis valid now while code with a parser ambiguity at semicolons like
my_feat => say "Hi"; say "ambiguous" if true if true then say "OK"; say "ambiguous"causes an error now.
{ }can be used for disambiguation:my_feat => { say "Hi" }; say "ambiguous" my_feat => { say "Hi"; say "ambiguous" } if true if true then { say "OK" }; say "ambiguous" if true if true then { say "OK"; say "ambiguous" }related pull requests
-
- Base library
-
New base library features
lib,be/c: add mutexes and conditions (#3428)
lib: Add
ignore(T type, x T) unitto drop a value (#3679)lib: add
thread_pooleffect (#3615)lib: add simple, fixed-size thread pool (#3579)
lib/net/server: add experimental feature handling connections in threads (#3554)
lib: add internationalization effect (#3571)
lib: Add currency to internationalization and fix small mistakes (#3635)
lib: add default effect for internationalization (#3620)
lib: add simple tests for internationalization effect (#3627)
lib: use new effects syntax for internationalization (#3587)
lib: replace int_eff with provide (#3616)
io/buffered/reader: switch to circular buffer (#3514)
related pull requests
-
Changes to the following standard library features
effect: Made
effect.aborta type feature and removedeffect.run, fix #3634 (#3640)lib: fix oneway monads (#3590)
lib: move
/!and%!fromwrap_aroundtointeger(#3522)lib: move
infix ∈andinfix ∉fromproperty.equatabletouniverse(#3622)lib: move features from
float_sequence,numeric_sequencetoSequence(#3668)lib/net: create the required mutate effect in the server/client effects (#3540)
lib/net: rename
Request_HandlertoConnection_Handler(#3509)lib:
closeon amutate.mutable_elementshould close only that element (#3573)lib/modules: fix typos in terminal API (#3636)
-
- Parser
- Front end
- Middle End
air: add preconditions that helped me debug #3613 / #3619 (#3623)
air: Clazz.toString created equal strings for a feature and its cotype (#3481)
air: FeatureAndActuals, add precondition checking type parameters mat… (#3643)
air: For a missing implementation of an abstract feature, show call chain (#3525)
air: make fields in Clazzes non static (#3479)
air: treat all intrinsics as intrinsic constructors (#3624)
ast: AbstractType.toString show
.this.typenot only.this(#3665)ast: change visibility of internal THIS#TYPE to private (#3582)
ast: For ambiguous calls, show the position of the feature declarations (#3572)
ast: Remove
Expr.typeForCallTarget(#3669)
- DFA
dfa: do not mark intrinsics as escaping, which prohibited tail call optimization to (#3434)
- FUIR
- JVM back end
be/jvm: implement intrinsics, mtx_*, cond_* (#3534)
- C back end
- Interpreter back end
- FZ Tool
- Tests
tests: calls_on_ref_and_val_target: remove NYI (#3489)
tests: add regression tests #1840 (#3612), #2339 (#3605), #1518 (#3519), #3147 (#3656), #3352 (#3633), #2111 (#3492)
tests: Added regression tests for safety, debug, and debug_level (Issue #3518) (#3580)
tests: turn positive into simple tests (#3526)
- Examples
examples: use connection handler instead of request handler (#3513)
- Other
ported shell script ebnf.sh to Fuzion ebnf.fz (#3436)
Cheers,
--The Fuzion Team.