Skip to content

Releases: vlang/v

weekly.2023.35

28 Aug 09:21
9d4233d
Compare
Choose a tag to compare
releases: weekly.2023.35

weekly.2023.33

15 Aug 20:38
815439a
Compare
Choose a tag to compare
releases: weekly.2023.33

weekly.2023.32.2

13 Aug 13:39
59f8310
Compare
Choose a tag to compare
releases: weekly.2023.32.2

weekly.2023.32

08 Aug 05:13
320057d
Compare
Choose a tag to compare
releases: weekly.2023.32

weekly.2023.31

04 Aug 08:56
ffdd5bb
Compare
Choose a tag to compare
releases: weekly.2023.31

weekly.2023.30

25 Jul 04:34
3a91a5e
Compare
Choose a tag to compare
releases: weekly.2023.30

weekly.2023.28

10 Jul 17:43
e7af25e
Compare
Choose a tag to compare
releases: weekly.2023.28

weekly.2023.27

03 Jul 12:20
df3c85e
Compare
Choose a tag to compare
releases: weekly.2023.27

0.4

01 Jul 12:26
Compare
Choose a tag to compare
0.4

V 0.4

1 July 2023

Improvements in the language

  • Coroutines with a scheduler. Only Linux/macOS for now, requires -use-coroutines and
    coroutines.sleep() instead of time.sleep(). They work with IO and net, but not with GC
    for now.
  • spawn now spawns system threads, go spawns coroutines.
  • Static type methods: Foo.new() to replace factory functions like new_foo().
  • Smartcasting with complex conditions:if sum_type is Foo && !sum_type.is_info && get_name(sum_type.info.name) == 'foo' .
  • Functions can now return fixed size arrays.
  • Enum values now can have attributes.
  • Generic functions as function parameters are now supported: fn f[T](x T, i int, f_ Fn[T]) T { .
  • Anonymous structs can no longer have attributes.
  • 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.
  • String interpolation simplified to just '${name}', enforced by vfmt, and updated in the entire code base.
  • go foo() has been replaced with spawn foo() (launches an OS thread, go will be used for
    upcoming coroutines instead).
  • vfmt now supports // vfmt off and // vfmt on for turning off the formatting locally for short snippets of code.
    Useful for keeping your carefully arranged matrices intact.
  • Match branch range expressions with consts: match x { const1...const2 {} }
  • Hot code reloading via [live] is now supported in imported modules, not just the main module.
  • Syntax sugar for map inits without needing explicit casts for interfaces: all.children := { "abc": rect, "def": ui.rectangle()}.
  • $embed_file() fixes, including variable args support.
  • none fixes: no longer allowed to be used as a separate type, dump() support, not allowed inside unsafe.
  • Const functions: const y = term.yellow, then println(y('abc')).
  • Builtin type names can no longer be used as identifiers.
  • Generic typeof[T](), sizeof[T](), isreftype[T]() functions.
  • Deprecated -error-limit in favour of the documented -message-limit option.
  • Maps now support aliased keys.
  • Operator overloading now works with reference types.
  • Generic struct inits with nested generic structs and generic optional types are now allowed.
  • During array creation, len: is required when using default values for the array.
  • Optimized one byte []u8 arrays creation.
  • Recursive aliasing is no longer allowed (e.g. type Alias = map[string]Alias).
  • Easier custom error creation: return MyCustomErr{} instead of return IError(MyCustomErr).
  • All floats outputs now have .0 conditionally appended to them to improve clarity.
  • Custom integer enum types: enum Xyz as u64 {.
  • AST transformer fixes and optimizations.
  • Stylistic improvements and bug fixes in vfmt.
  • Casting integers to enums now requires unsafe{}.
  • Improved error and warning messages.
  • Parallel compilation now uses sync.Pool.
  • -skip-unused fixes, soon to be made the default.
  • Anonymous structs.
  • Lots of bug fixes: 90% of all bugs ever submitted are closed.
  • New keyword/type: nil. Only to be used inside unsafe. Replaces voidptr(0).
  • V can now find code in the src/ directory. This allows making V repos much cleaner.
  • Support assert condition, extra_message, where the extra_message will be evaluated and shown if the assertion fails.
  • Operator overloading now works with aliases and generics.
  • Scanner optimizations.
  • Using C's #define is no longer allowed in normal V code, only in .c.v files.

Breaking changes

  • byte deprecated in favor of u8 (byte is automatically converted to u8 by vfmt).
  • json: enums are serialized as strings by default, [json_as_number] attribute can be used for
    the old behavior.
  • Variable shadowing has been completely banned (previously variable names could conflict with
    module names).
  • [] is now used for generics instead of <>.
  • Accessing a pointer map value requires an or {} block outside unsafe.
  • Anonymous sumtypes have been removed (deprecated for now) due to complicating the language and the compiler too much.

Checker improvements/fixes

  • Disallow Result type aliases (type Foo = !Bar) and Result in maps (map[key]!Type).
  • Add a missing check for taking address of literal value member.
  • Fixed map initialization for maps with option values.
  • Allow a << none, where a is []?&int.
  • Disallow multiple else branches in a match.
  • Fix index expression with sumtype of array types.
  • Remove hardcoded check for function calls for C.stat, C.sigaction, etc.
  • Fix multiple embedded external module interface.
  • Fix missing check for diff type on map value declaration.
  • Simplify error handling in the checker (#18507).
  • Option alias fixes.
  • Fix alias to struct ptr on struct init.
  • Sumtypes can no longer hold references.
  • Fix a bug checking generic closures.
  • A hard to reach limit of 1 million iterations for resolving all generics.
  • Fix missing check for unwrapped shift operation.
  • Fix enum max value validation.
  • Add a missing mutability check for array.delete calls.
  • Disallow _ = <- quit.
  • Disallow type matching with primitive vars.
  • Warning instead of error for unnecessary brackets in if/match.
  • Include import aliases when checking for import duplicates.
  • Fix infering generic array type in nested call.
  • Allow casted enum val and const as fixed array size.
  • Disallow multiple return values in const declarations.
  • Fix contains() with array of interfaces.
  • Disallow mut for blank idents.
  • 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 Options are now allowed.
  • Allow foo := Foo{}, when Foo has an Option field, that is a struct, that has a [required]
    tag on its fields.
  • 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:
    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:
    a := unsafe { nil }
    println(*a)
  • Lots of fixes in the type checker.
  • Int signedness mismatch is now checked: cannot use literal signed integer as u8.
  • Improved type checker: lots of new type checks and fixed checker bugs.
  • Unused last expression in if is now checked.
  • Anonymous structs visibility issues fixed.
  • More type checks.
  • Lots of fixes in shared types.

Standard library

  • json: Enum value string serialization supports [json:'alias'] to change its string values.
  • Struct fields can now be skipped during JSON/ORM serialization via [json:'-'] and [sql:'-'],
    in addition to [skip]. This allows having custom behavior for different serialization methods.
  • builtin: heap usage API (gc_memory_use() and gc_heap_usage())
  • math.big: refactoring, gcd fixes/improvements, overflow fixes, mod_inverse.
  • flag: fix finalize with multiple shortargs.
  • runtime: add new functions total_memory/0 and free_memory/0.
  • time: small cleanup of parse_iso8601 comments, make the C.strftime declaration forwards compatible
  • stbi: allow customization of number of channels in stbi.load().
  • stbi: add a resize_uint8 function for resizing images in memory.
  • time, x.json2: improve iso8601 time decoding.
  • builtin: zero out internal map/array pointers on m.free(), to reduce the work for the GC
    mark phase for non escaping maps/arrays, used in hot loops.
  • time: add more detailed error descriptions, add custom format parsing with time.parse_format.
  • sync: add Mutex.destroy and RwMutex.destroy methods.
  • datatypes: add Bloom filter.
  • rand: add missing rand.u16(), update doc comments, add test.
  • builtin: speed up string methods with vmemcpy instead of for loop for copying data.
  • 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.
  • strconv: v_printf() was made private, v_sprintf() was deprecated. String interpolation
    should be used instead.
  • 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.
  • sokol: errors during image creation no longer result in a panic, but can be handled by the
    programmer.
  • sokol: macOS apps can now be quit using Cmd+Q.
  • os.hostname() and os.loginname() now return Result.
  • strconv.atoi optimizations.
  • println() now supports arrays with recursive references.
  • termux: support for cross-compilation from termux to other platforms.
  • readline module now works much better on macOS: key navigation, history, etc (now on par with
    Linux).
  • os: fixed a mem...
Read more

0.3.5

29 Jun 21:02
Compare
Choose a tag to compare

Improvements in the language

  • Coroutines with a scheduler. Only Linux/macOS for now, requires -use-coroutines and
    coroutines.sleep() instead of time.sleep(). They work with IO and net, but not with GC
    for now.
  • spawn now spawns system threads, go spawns coroutines.
  • Static type methods: Foo.new() to replace factory functions like new_foo().
  • Smartcasting with complex conditions:if sum_type is Foo && !sum_type.is_info && get_name(sum_type.info.name) == 'foo' .
  • Functions can now return fixed size arrays.
  • Enum values now can have attributes.
  • Generic functions as function parameters are now supported: fn f[T](x T, i int, f_ Fn[T]) T { .
  • Anonymous structs can no longer have attributes.
  • Allow fixed array returns.

Breaking changes

  • byte deprecated in favor of u8 (byte is automatically converted to u8 by vfmt).

Checker improvements/fixes

  • Disallow Result type aliases (type Foo = !Bar) and Result in maps (map[key]!Type).
  • Add a missing check for taking address of literal value member.
  • Fixed map initialization for maps with option values.
  • Allow a << none, where a is []?&int.
  • Disallow multiple else branches in a match.
  • Fix index expression with sumtype of array types.
  • Remove hardcoded check for function calls for C.stat, C.sigaction, etc.
  • Fix multiple embedded external module interface.
  • Fix missing check for diff type on map value declaration.
  • Simplify error handling in the checker (#18507).
  • Option alias fixes.
  • Fix alias to struct ptr on struct init.
  • Sumtypes can no longer hold references.
  • Fix a bug checking generic closures.
  • A hard to reach limit of 1 million iterations for resolving all generics.
  • Fix missing check for unwrapped shift operation.
  • Fix enum max value validation.
  • Add a missing mutability check for array.delete calls.
  • Disallow _ = <- quit.
  • Disallow type matching with primitive vars.
  • Warning instead of error for unnecessary brackets in if/match.
  • Include import aliases when checking for import duplicates.
  • Fix infering generic array type in nested call.
  • Allow casted enum val and const as fixed array size.
  • Disallow multiple return values in const declarations.
  • Fix contains() with array of interfaces.
  • Disallow mut for blank idents.

Standard library

  • json: Enum value string serialization supports [json:'alias'] to change its string values.
  • Struct fields can now be skipped during JSON/ORM serialization via [json:'-'] and [sql:'-'],
    in addition to [skip]. This allows having custom behavior for different serialization methods.
  • builtin: heap usage API (gc_memory_use() and gc_heap_usage())
  • math.big: refactoring, gcd fixes/improvements, overflow fixes, mod_inverse.
  • flag: fix finalize with multiple shortargs.
  • runtime: add new functions total_memory/0 and free_memory/0.
  • time: small cleanup of parse_iso8601 comments, make the C.strftime declaration forwards compatible
  • stbi: allow customization of number of channels in stbi.load().
  • stbi: add a resize_uint8 function for resizing images in memory.
  • time, x.json2: improve iso8601 time decoding.
  • builtin: zero out internal map/array pointers on m.free(), to reduce the work for the GC
    mark phase for non escaping maps/arrays, used in hot loops.
  • time: add more detailed error descriptions, add custom format parsing with time.parse_format.
  • sync: add Mutex.destroy and RwMutex.destroy methods.
  • datatypes: add Bloom filter.
  • rand: add missing rand.u16(), update doc comments, add test.
  • builtin: speed up string methods with vmemcpy instead of for loop for copying data.

Web

  • The builtin websocket library is now thread safe.
  • Enhanced builtin csrf protection in vweb.
  • vweb: ability to set and get values on vweb.Context.
  • vweb: support for host specific static files.
  • vweb: host option added to controller, and a new host attribute.
  • vweb: middleware docs improved; same with docs for [vweb_global] and shared.
  • vweb: return 404 on file not found.
  • net.http: copy IANA's list of methods to the http.Method enum.
  • net.conv: use a pure V implementation instead of C.hton etc.
  • net.html: get_tag() methods to find first tag occurrence.
  • net.html: fixed text parsing for inline tags.
  • net.html: fix parsing of nested quoted strings in code tags.
  • picoev: FreeBSD support.

ORM

  • Fixed a foreign key bug that could result in an extra insert.
  • Comptime bug with [skip] and [sql:'-'] fixed.
  • Checker error for unsupported field types.
  • Allow structs without the id field, more flexible primary keys.
  • Improved docs and examples.
  • Uninitialized structs are no longer inserted into related tables.

Database drivers

  • mysql: TIMESTAMP support.
  • mysql: allocate memory for each string and blob dynamically depending on its value length.
  • mysql: add the ability to commit transactions.

Native backend

  • Refactoring, splitting large files into multiple.

C backend

  • Fix code generation for generic unions.
  • Fix [N]chan (fixed arrays of channels).
  • Fix nested fixed array instantiation.
  • Fix fixed array of map.
  • Fix stringification of usize struct fields (before, they were treated as 32 bit signed numbers).

Comptime

  • A new $res comptime function to get returned value in defer block (#18382).
  • Fix comptimeselector option propagation.
  • A mutability check for comptime assignments.
  • Fix comptime assigning to sumtype or indexexpr.
  • Make comptime calls work with or-block.

Tools

  • A new VPM site: vpm.vlang.io. A better design, discoverability of packages, descriptions, most downloaded packages etc.
  • vpm: installation of mixed modules.
  • v ls --install -p D:\path\vls.exe to install a local vls executable.
  • vdoc: highlight comments with gray color.
  • vet: allow vetting files with global variables.
  • Make util.launch_tool/3 more robust, by recompiling V tools always in a known current working folder.