1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

changelog: split items into separate topics (#18112)

This commit is contained in:
Petr Makhnev
2023-05-04 22:24:13 +04:00
committed by GitHub
parent 5bcc04e66a
commit 134e781965

View File

@@ -1,87 +1,170 @@
## V 0.3.4 ## V 0.3.4
*30 Apr 2023* *30 Apr 2023*
### Breaking Changes ### Breaking Changes
- `json`: enums are serialized as strings by default, `[json_as_number]` attribute can be used for the old behavior. The following changes may break compilation of existing code or change behavior at runtime:
- `json`: enums are serialized as strings by default, `[json_as_number]` attribute can be used for
the old behavior.
If you are serializing enums to JSON in your application, then you will need to add the If you are serializing enums to JSON in your application, then you will need to add the
`[json_as_number]` attribute to keep the old behavior! `[json_as_number]` attribute to keep the old behavior!
### Other Changes - Variable shadowing has been completely banned (previously variable names could conflict with
module names).
- **vweb now supports live page reloading**. The web app is instantly updated in the browser (no need to refresh the page) everytime a .v or a .html file is changed. ### Web
- vweb is now significantly faster and more stable under load, due to a new multithreaded worker pool, which is much more efficient at spreading the workload among all threads equally.
- Middleware support in vweb. - vweb now supports live page reloading.
- vweb now supports controllers. It's now possible to have multiple app structs to better separate logic. The web app is instantly updated in the browser (no need to refresh the page)
- vweb: overridable `.not_found()` method for custom 404 pages. every time a **.v** or a **.html** file is changed.
- A new pure WASM backend, based on binaryen, a WASM `builtin` module, and a pure V WASM serialization library. - vweb is now significantly faster and more stable under load, due to a new multithreaded worker
- Lots of playground improvements: [play.vlang.io](https://play.vlang.io), including a really cool feature: "Show generated C code". pool, which is much more efficient at spreading the workload among all threads equally.
- `v share file.v` for sharing code via the playground. - vweb now supports middleware.
- All ORM queries now return `![]` (`Result` of an array). This allows to handle/propagate DB errors and simplifies working with ORM (one way). - vweb now supports controllers.
- Many ORM improvements: type checks for `limit/offset/order by/where`; support of reference objects in `insert`; struct fields can be used with `limit/offset`; `Connection` interface. It's now possible to have multiple app structs to better separate logic.
- ORM now supports the `like` operator: `users := sql db { select from User where name like 'Bob%' }`. - vweb now supports overridable `.not_found()` method for custom 404 pages in vweb.
- A new `-d trace_orm` option to see all SQL queries generated and used by V ORM and `-d trace_pg_error` to trace PG errors. - vweb now uses database pool.
- A new command line flag `-e` for running short V programs on command line: `v -e "println(2+5)"` (works just like in Perl). - Fixed multipart form parsing in vweb.
- `v up` sped up for when it hasn't been run for a long time (vc/ bootstrapping has been optimized).
- Lots of new checks in the checker. ### Backends
- Variable shadowing has been completely banned (previously variable names could conflict with module names).
- If guards now work with struct fields which are `Option` functions. Such fields can now also be assigned to other fields/variables. - A new pure WASM backend, based on binaryen, a WASM `builtin` module, and a pure V WASM
- net.ssl: types using ssl contexts can now be converted to strings via `.str()`/printed via `println()`. serialization library.
- v.reflection: type symbol info metadata has been added. - Lots of fixes and new features in the native backend, including making codegen logic
- cgen: do not generate unused interface functions. platform independent.
- A new `[spawn_stack: 131072]` fn attribute for controlling the max size of the stack of the spawned threads.
- Final steps in making the Option type a first class type.
- Lots of documentation/readme improvements.
- Option receivers can no longer have methods.
- `none` can now be cast to all `Option` types, including aliases.
- Enums can no longer be initialized like structs.
- Builtin methods `first/last/repeat` can now be used in custom user types (previously they only worked in builtin arrays).
- `v init` no longer overwrites existing `src/main.v`.
- Anonymous fn params can no longer be shadowed.
- Channel pop now works with an `or` block: `ch := <-self.item or { return none }`
- Option references are now supported: `?&Type`.
- Now code generated by the С backend, can be compiled by a C++20 compiler. - Now code generated by the С backend, can be compiled by a C++20 compiler.
- `v self` now uses a faster tcc backend on macOS/Apple Silicon, just like on Windows/Linux. - C backend does not generate unused interface functions now.
- `os.hostname()` and `os.loginname()` now return `Result`.
- The "Is V still fast?" web page has been sped up by splitting the results table into multiple years. ### Compiler CLI
- Allow `foo := Foo{}`, when `Foo` has an Option field, that is a struct, that has a `[required]` tag on its fields (#17516).
- Comptime reflection now supports interface fields. - `v share file.v` for sharing code via the playground.
- comptime: `$option` (`for f in Foo.fields { $if f.typ is $option { ...`). - `v up` speed up for when it hasn't been run for a long time (**vc/** bootstrapping has been
- comptime: compile-time enum evaluation with `$for optimized).
- comptime: all types are now lowercase (`$int, $enum, $option` etc). - `v init` no longer overwrites existing `src/main.v`.
item in MyEnum.fields { dump(item.value) dump(item.name) }`. - `v self` now uses a faster TCC backend on macOS (Intel/Apple Silicon), just like on Windows/Linux.
- Arrays of `Option`s are now allowed. - A new command line flag `-e` for running short V programs on command line: `v -e "println(2+5)"` (
- `it` has been renamed to `index` in array inits. works just like in Perl).
- `datatypes.LinkedList[map]` now works correctly.
- `crypto` and `math` modules have been updated to use `Result` instead of `Option`.
- `[required]` fields are now checked for embedded structs.
- `readline` module now works much better on macOS: key navigation, history, etc (now on par with Linux).
- Basic QNX support.
- A new `-ldflags` option, in addition to `-cflags`. Works just like LDFLAGS in C. - A new `-ldflags` option, in addition to `-cflags`. Works just like LDFLAGS in C.
### ORM
- All ORM queries now return `![]` (`Result` of an array).
This allows handling/propagating DB errors and simplifies working with ORM (one way).
- Many ORM improvements: type checks for `limit/offset/order by/where`; support of reference objects
in `insert`; struct fields can be used with `limit/offset`; `Connection` interface.
- ORM now supports the `like` operator:
```v
users := sql db {
select from User where name like 'Bob%'
}
```
- A new `-d trace_orm` option to see all SQL queries generated and used by V ORM and
`-d trace_pg_error` to trace PG errors.
### Standard Library
- Added new `termios` module.
- `net.ssl`: types using ssl contexts can now be converted to strings via `.str()`/printed
via `println()`.
- `v.reflection`: added type symbol info metadata.
- `crypto` and `math` modules have been updated to use `Result` instead of `Option`.
- `datatypes.LinkedList[map]` now works correctly.
- `urllib.Values.get()` now returns an Option. - `urllib.Values.get()` now returns an Option.
- `strconv`: `v_printf()` was made private, `v_sprintf()` was deprecated. String interpolation should be used instead. - `strconv`: `v_printf()` was made private, `v_sprintf()` was deprecated. String interpolation
- Fixed a bug with closures with fixed array variables. should be used instead.
- Generic struct inits no longer need explicit types provided: `struct Foo[T, U] { a T; b U } foo := Foo{a:2, b:'x'}`
- `os.Process` now has a `create_no_window` option (Windows only).
- `os.Process` now has a `set_work_folder()` method to set the initial working folder of the new child process.
- `net.http`: mime types have been updated to include all official types. - `net.http`: mime types have been updated to include all official types.
- `gg`: `create_image()` now returns `!Image` instead of `Image`, allowing to handle errors. - `gg`: `create_image()` now returns `!Image` instead of `Image`, allowing to handle errors.
- sokol: errors during image creation no longer result in a panic, but can be handled by the programmer. - `sokol`: errors during image creation no longer result in a panic, but can be handled by the
- sokol: macOS apps can now be quit using Cmd+Q. programmer.
- A new `termios` module. - `sokol`: macOS apps can now be quit using **Cmd+Q**.
- Lots of fixes and new features in the native backend, including making codegen logic platform-independent. - `os.hostname()` and `os.loginname()` now return `Result`.
- `strconv.atoi` optimizations. - `strconv.atoi` optimizations.
- `println()` now supports arrays with recursive references. - `println()` now supports arrays with recursive references.
- Multipart form parsing fixes in vweb. - `termux`: support for cross-compilation from termux to other platforms.
- A database pool in vweb. - `readline` module now works much better on macOS: key navigation, history, etc (now on par with
- termux: support for cross-compilation from termux to other platforms. Linux).
- GitHub Copilot summaries in PRs. - `os`: fixed a memleak in `getline()`.
- unsafe: dereferencing nil references is no longer allowed. - `os.Process` now has a `create_no_window` option (Windows only).
- os: fixed a memleak in `getline()`. - `os.Process` now has a `set_work_folder()` method to set the initial working folder of the new
- Mixing multi-return results with other types in return statements is no longer allowed (this simplifies the code). child process.
- Assigning anonymous structs to named structs is no longer allowed.
### Option as a first class type
Final steps in making the Option type a first class type:
- If guards now work with struct fields which are `Option` functions.
Such fields can now also be assigned to other fields/variables.
- Option receivers can no longer have methods.
- `none` can now be cast to all `Option` types, including aliases.
- Option references are now supported: `?&Type`.
- Arrays of `Option`s are now allowed.
- Allow `foo := Foo{}`, when `Foo` has an Option field, that is a struct, that has a `[required]`
tag on its fields.
### Compile-time Reflection
- Compile-time interface fields evaluation.
- Compile-time enum evaluation:
```v
$for item in MyEnum.fields {
println(item.value)
println(item.name)
}
```
- Added `$option` as a compile-time reflection type representing an any Option type.
- All special compile-time reflection types are now lowercase (`$int`, `$enum`, `$option`, etc).
### Checker Improvements/Fixes
- Enums can no longer be initialized like structs.
- Capture variables can no longer shadow anonymous function params.
- Mixing multi-return results with other types in return statements is no longer allowed.
- Assigning anonymous structs to named structs is no longer allowed.
- `[required]` fields are now checked for embedded structs.
- Fixed a bug with closures with fixed array variables.
- Builtin methods `first/last/repeat` can now be used in custom user types (previously they only
worked in builtin arrays).
- Generic struct initialization no longer needs explicit types to be provided:
```v
struct Foo[T, U] {
a T
b U
}
foo := Foo{
a: 2
b: 'x'
}
println(foo)
```
- unsafe: dereferencing nil references is no longer allowed in the following case:
```v
a := unsafe { nil }
println(*a)
```
### OSes
- Added basic QNX support.
### Other changes
- Lots of documentation/readme improvements.
- Lots of playground improvements: [play.vlang.io](https://play.vlang.io), including a really cool
feature: "Show generated C code".
- A new `[spawn_stack: 131072]` function attribute for controlling the max size of the stack of the
spawned threads.
- Channel pop now works with an `or` block: `ch := <-self.item or { return none }`
- `it` has been renamed to `index` in array inits.
- "Is V still fast?" web-page has been sped up by splitting the result table into multiple years.
### Development
- GitHub Copilot summaries in PRs.
## V 0.3.3 ## V 0.3.3
*30 Jan 2023* *30 Jan 2023*