今日已更新 80 条资讯 | 累计 20052 条内容
关于我们

标签:#generics

找到 1 篇相关文章

AI 资讯

Sprint 7 Review: Generics.Collections | Review Sprint 7: Generics.Collections

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Sprint 7 Review: Generics.Collections Mintlify docs tour — after Sprint 4 exceptions , Sprint 7 brings the collections every Horse API and CRUD service needs. Generic containers are not syntactic sugar in Delphi — they are how you build caches, registries, and JSON maps. Sprint 7 ( v2.15.0 ) shipped System.Generics.Collections with working TDictionary<K,V> and TList<T> , including TryGetValue with proper var write-back. What the review documents From Sprint 7 Review : var parameters — Value::Reference , write-back in procedures/functions and TryGetValue . TDictionary::Add / TryGetValue — dispatch in simulate_function_execution ; direct routing for instantiated generics. Parser — generic types with Integer / String in expressions ( TDictionary<String,Integer> ). RTL — rtl/sys/System.Generics.Collections.pas ; semantic layer recognizes Generics.Collections . Tests — generics_collections.rs plus fixtures. Tag v2.15.0 approved. Dictionary pattern in production code program DictDemo ; uses System . SysUtils , System . Generics . Collections ; var D : TDictionary < string , Integer >; V : Integer ; begin D := TDictionary < string , Integer >. Create ; try D . Add ( 'apples' , 3 ); if D . TryGetValue ( 'apples' , V ) then WriteLn ( 'apples = ' , V ); finally D . Free ; end ; end . TryGetValue only writes V when the key exists — the Delphi idiom you expect in services and controllers. Why var was the sprint's hidden hero Before v2.15.0, incomplete var semantics blocked realistic APIs. TryGetValue requires the callee to mutate the caller's variable through a reference. CrabPascal introduced Value::Reference and write-back in procedure dispatch specifically for this surface. Three implementation lessons from the retrospective: D := TDictionary<...>.Create needs normalize_call_name in execute_assignment — not just in direct calls. Generic instance methods must hit intrinsics before empty VMT lookups

2026-06-04 原文 →