C3 0.8.2 a Modest Improvement

birdculture1 pts0 comments

C3 0.8.2 A modest improvement - C3 Programming Language Skip to content

Initializing search

Language Overview<br>C to C3<br>Language Fundamentals<br>Language Common<br>Generic Programming<br>Build Your Project<br>Language Rules<br>Misc Advanced<br>Implementation Details<br>FAQ

Get Involved

Thank You

Single Page Docs<br>📖 Standard Library<br>Blog

Standard library<br>Fixes<br>Thank yous

C3 0.8.2 A modest improvement<br>C3 0.8.2 is out. This release brings a batch of language ergonomics improvements — most notably reusable target templates for libraries and generic constdef — along with new reflection capabilities and a round of bug fixes.<br>Compared to 0.8.1, this is a rather modest release, but anyway, here's what's new:<br>Language changes & improvements&para;<br>Reusable target configurations for libraries&para;<br>Libraries can now expose a templates map in their manifest, and projects can pull one into a target with template: "library/template". Template properties load first and target-local settings override them, so libraries can ship sensible, shareable build configurations instead of asking every user to copy-paste setup.<br>Reflection for generics&para;<br>Foo::is_generic(...), Foo::generic_qname, and Foo::generic_args finally lets you inspect generic instantiations.<br>alias Foo = List{int};

fn void main()<br>typeid t = List{String}::generic_args[0]; //String::typeid<br>String name = Foo::generic_qname; // "std::collections::list::List"<br>bool x = Foo::is_generic(List); // true<br>bool y = int::is_generic(List); // false

Bitstruct properties&para;<br>Bitstruct members gain bitoffset and bitsize properties:<br>bitstruct Foo : uint<br>uint a : 0..1;<br>bool b : 6;<br>bool c : 10;<br>int d : 14..20;

fn void main()<br>int a = $reflect(Foo.a).bitsize; // 2<br>int b = $reflect(Foo.d).bitoffset; // 14<br>int c = $reflect(Foo.c).bitoffset; // 10

New @param options: own, init and drop&para;<br>It's now possible to annotate more than in/inout/out on parameters:<br>own signifies that the function will in some way retain the variable beyond the scope of the function.<br>drop means that the pointer and the data pointed to will be invalid when the function returns.<br>init means that the data in pointed to will be initialized by the function.<br>This can be used by the compiler for static analysis and also documents the function or macro.

@param [own] f<br>*><br>fn void foo(Foo* f)<br>some_global.foo = f;

Asm stack alignment&para;<br>Before 0.8.2, all asm blocks would be stack aligned, which didn't match C behaviour. This is now fixed. Stack alignment is now opt-in by using @align:<br>asm // Unaligned<br>syscall;

asm @align // Stack aligned<br>syscall;

Windows improvements&para;<br>The Windows subsystem can now be set directly. Windows can still use @winmain to implicitly set the Window subsystem, but all subsystems are now available, allowing for things like EFI applications.<br>Standard library&para;<br>Atomic.compare_exchange added.<br>array::contains_slice and array::index_of_slice for substring-style searches over arrays.<br>log::register_dynamic_category, for libraries to define their own logging categories dynamically.<br>String.index_of and rindex_of now accept finding empty strings.<br>Fixes&para;<br>Stdlib fixes&para;<br>Denormal (subnormal) results are now handled correctly by String.to_double() — very small magnitudes near the floating-point floor previously came out wrong.<br>A float literal with an uppercase F suffix was incorrectly typed as a double instead of a float.<br>JSON serialization now correctly handles Unicode and \v (#3353).<br>IPv6 parsing: "a::b:c:d:e:f:0" is now accepted as valid.<br>A regression in BackedArenaAllocator when destroying it could cause a crash.<br>Fixed macOS regression which was breaking stack traces.<br>Compiler fixes&para;<br>$stringify would sometimes wrap output in extra parentheses.<br>constdef vector with an alias was incorrectly lowered<br>The compiler asserted when concatenating a struct to an untypedlist<br>untypedlist was not detected as invalid as an enum associated-value type or as a pointer<br>Thank yous&para;<br>Again, this release wouldn't have been possible without the C3 community. I'd like to extend a deep thank you to all who have contributed, both through filed issues, PRs and just plain discussions.<br>PR contributors for this release&para;<br>Stdlib: AtomicSynth, Book-reader, GuineaPigUuhh and Manu Linares<br>Compiler & toolchain: Book-reader, Johannes Müller, Manu Linares, Osama Badeeb, rickyadastra and Rodrigo Camacho<br>CI/Infrastructure: Hade and Manu Linares<br>Change Log&para;<br>Click for full change log Changes / improvements&para;<br>@weak now works with all declarations.<br>Add @align for asm blocks to stack align them. Stack alignment is no longer default.<br>Allow setting Windows subsystem directly.<br>Add bitoffset and bitsize reflection properties to bitstruct members. #3219<br>Improve error message on trying to cast char array to String. #3343<br>Add Foo::is_generic(...), Foo::generic_qname and Foo::generic_args. #2909 #3329<br>Add own, init and drop parameter annotations.<br>constdef can now be generic.<br>Libraries can now expose reusable target...

para language stack libraries list string

Related Articles