```C3 0.8.2 小幅改进```
C3 0.8.2 a Modest Improvement

原始链接: https://c3-lang.org/blog/0_8_2_a_modest_improvement/

C3 0.8.2 版本现已发布,带来了多项易用性改进和增强的反射功能。 **主要亮点:** * **可重用模板:** 库现在可以通过 `templates` 映射暴露共享的构建配置,从而简化项目设置。 * **泛型反射:** 新增了属性(`is_generic`、`generic_qname` 和 `generic_args`),允许检查泛型实例化。 * **位结构体(Bitstruct)与参数注解:** 为位结构体添加了 `bitoffset` 和 `bitsize` 属性,并引入了新的 `@param` 注解(`own`、`init`、`drop`),以辅助静态分析和文档生成。 * **编译器与构建增强:** 汇编堆栈对齐现在可通过 `@align` 选择性开启,用户还可以直接设置 Windows 子系统。 * **标准库:** 新增内容包括 `Atomic.compare_exchange`、改进的数组搜索功能以及动态日志分类。 此版本还修复了各种错误,包括浮点数解析、JSON 序列化、IPv6 处理以及影响 macOS 和堆栈跟踪的几个回归问题。本次更新持续致力于提升 C3 的开发效率和工具链的稳定性。

抱歉。
相关文章

原文

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.

Compared to 0.8.1, this is a rather modest release, but anyway, here's what's new:

Language changes & improvements

Reusable target configurations for libraries

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.

Reflection for generics

Foo::is_generic(...), Foo::generic_qname, and Foo::generic_args finally lets you inspect generic instantiations.

Bitstruct properties

Bitstruct members gain bitoffset and bitsize properties:

New @param options: own, init and drop

It's now possible to annotate more than in/inout/out on parameters:

  1. own signifies that the function will in some way retain the variable beyond the scope of the function.
  2. drop means that the pointer and the data pointed to will be invalid when the function returns.
  3. init means that the data pointed to will be initialized by the function.

This can be used by the compiler for static analysis and also documents the function or macro.

Asm stack alignment

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:

Windows improvements

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.

Standard library

  • Atomic.compare_exchange added.
  • array::contains_slice and array::index_of_slice for substring-style searches over arrays.
  • log::register_dynamic_category, for libraries to define their own logging categories dynamically.
  • String.index_of and rindex_of now accept finding empty strings.

Fixes

Stdlib fixes

  • Denormal (subnormal) results are now handled correctly by String.to_double() — very small magnitudes near the floating-point floor previously came out wrong.
  • A float literal with an uppercase F suffix was incorrectly typed as a double instead of a float.
  • JSON serialization now correctly handles Unicode and \v (#3353).
  • IPv6 parsing: "a::b:c:d:e:f:0" is now accepted as valid.
  • A regression in BackedArenaAllocator when destroying it could cause a crash.
  • Fixed macOS regression which was breaking stack traces.

Compiler fixes

  • $stringify would sometimes wrap output in extra parentheses.
  • constdef vector with an alias was incorrectly lowered
  • The compiler asserted when concatenating a struct to an untypedlist
  • untypedlist was not detected as invalid as an enum associated-value type or as a pointer

Thank yous

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.

PR contributors for this release

Stdlib: AtomicSynth, Book-reader, GuineaPigUuhh and Manu Linares

Compiler & toolchain: Book-reader, Johannes Müller, Manu Linares, Osama Badeeb, rickyadastra and Rodrigo Camacho

CI/Infrastructure: Hade and Manu Linares

Change Log

Click for full change log

Changes / improvements

  • @weak now works with all declarations.
  • Add @align for asm blocks to stack align them. Stack alignment is no longer default.
  • Allow setting Windows subsystem directly.
  • Add bitoffset and bitsize reflection properties to bitstruct members. #3219
  • Improve error message on trying to cast char array to String. #3343
  • Add Foo::is_generic(...), Foo::generic_qname and Foo::generic_args. #2909 #3329
  • Add own, init and drop parameter annotations.
  • constdef can now be generic.
  • Libraries can now expose reusable target configurations via a templates map in their manifest, which projects reference from a target using template: "library/template". Properties from the template are loaded first and can be overridden by target-local settings.

Stdlib changes

  • Atomic.compare_exchange added.
  • Added array::contains_slice and array::index_of_slice.
  • String.index_of and rindex_of will now accept finding empty strings.
  • Add log::register_dynamic_category, for libraries that wish to define their own categories dynamically.

Fixes

  • $stringify would sometimes include parens.
  • Regression when destroying a BackedArenaAllocator in some cases #3332.
  • "a::b:c:d:e:f:0" was not parsed as a valid ipv6 string.
  • constdef vector with alias incorrectly lowered #3335.
  • Compiler asserts on concatenating a struct to an untypedlist #3326.
  • untypedlist was not detected as invalid in enum associated value type or as a pointer #3342.
  • Regression using non-posix libc.
  • Crash with an optional struct recursively defined with a function type. #3358
  • Denormal results were not handled correctly by String.to_double().
  • A float literal with an uppercase 'F' suffix would be a double instead of a float.
  • Json serialization would not correctly handle unicode and \v. #3353
  • Semantic checking was incorrect in the case of &a - &b where one or both are optional and the result isn't assigned.
  • Regression on MacOS, breaking stack trace.

Want To Dive Into C3?

Check out the documentation or download it and try it out.

Have questions? Come and chat with us on Discord.

联系我们 contact @ memedata.com