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

标签:#pascal

找到 5 篇相关文章

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 原文 →
AI 资讯

Navigating the Reorganized CrabPascal Docs | Navegando a documentação Mintlify

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Navigating the Reorganized CrabPascal Docs Phase 1 of this blog series covered fundamentals — CLI, lexer, sprints, and how to contribute. If you read Contributing to CrabPascal: Get Involved , you already know where the repo lives and how to open a PR. Phase 2 is different: we walk the Mintlify documentation site the way a new teammate would, mapping each article to the pages you actually need in daily work. The live docs live at crabpascal.mintlify.app . The source is under mintlify/ in the Bitbucket repo. Think of Mintlify as the canonical handbook; Dev.to posts are the guided tour. Why the docs were reorganized CrabPascal grew from a v1.5 experimental interpreter (October 2025) to v2.22.0 with sprint-driven releases, Horse E2E tests, and honest build-exe . Old folders like documentation/00-INICIO/ still exist in git history, but Mintlify groups content by job to be done : You want to… Start here Install and run Quickstart See current capabilities Project status Understand architecture Architecture Follow releases Changelog Historical reports from v1.5–v2.8 remain under Histórico with archive banners — useful for context, not for "what works today." The home page is your compass Open the Mintlify index . It shows v2.22.0 at a glance: real diagnostic spans, System.* RTL, Unicode strings, dual-mode run/build, and Horse HTTP parity. Four cards link to quickstart, changelog, sprint roadmap, and technical-debt backlog. Essential CLI commands are listed once: crab-pascal check programa.dpr # diagnostics with line/column crab-pascal run programa.dpr # interpreter / runtime crab-pascal build-exe programa.dpr # native binary via C toolchain Bookmark this page. When someone asks "is feature X done?", check status + changelog before diving into Rust sources. The documentation map: question-driven navigation The page essentials/documentation-map is the "I want X, go to Y" cheat sheet. It answers sc

2026-06-04 原文 →
AI 资讯

Codegen to C: Native Binaries from Pascal (v2.18.0) | Codegen para C: binários nativos a partir de Pascal (v2.18.0)

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Codegen to C: Native Binaries from Pascal (v2.18.0) Sprint 10 ( v2.18.0 ) closes the loop on CrabPascal's most ambitious feature: turning Pascal source into real native executables via C codegen — with string builtins that actually match the interpreter. The pipeline Pascal (.dpr/.pas) → AST → C source + stubs.c → gcc/clang → native binary run skips the last steps and executes in Rust. build-exe is for when you want an .exe or ELF on disk without carrying the CrabPascal runtime as a dependency. End-to-end example program NativeHello ; uses System . SysUtils ; begin WriteLn ( Trim ( ' Hello, native world! ' )); end . crab-pascal build-exe NativeHello.dpr ./NativeHello # or NativeHello.exe on Windows Expected output: Hello, native world! — no leading or trailing spaces. What Sprint 10 fixed Parser: Trim , Copy , Length , and friends are recognized as SysUtils builtins , not mistaken for type names starting with T . A denylist prevents hard-casts that produced invalid C. Codegen: Forward declarations for pascal_* helpers in generated C. WriteLn emits correct %s formats for string expressions. main returns 0 like a well-behaved C program. Tests: build_string_conformance_stdout_matches_run_when_toolchain_present runs only when gcc/clang is available — skipping cleanly in CI sandboxes without a compiler, failing loudly when a compiler is present but output diverges. cargo test --test run_build_parity stubs.c: shared runtime surface String functions implemented once in Rust for run mirror into stubs.c for native builds: // conceptual — see repo for full signatures int pascal_Length ( const char * s ); char * pascal_Trim ( const char * s ); Generated Pascal calls route through these instead of ad-hoc inline logic, keeping Sprint 5–8 string semantics intact in binaries. When build-exe is not enough yet Sprint 10 explicitly did not ship full OO, exception, or generics codegen parity — those appear

2026-06-04 原文 →
AI 资讯

Building REST APIs in Pascal with Horse | APIs REST em Pascal com Horse

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Building REST APIs in Pascal with Horse Pascal is not stuck in desktop forms. With Horse — a lightweight HTTP framework popular in the Delphi ecosystem — CrabPascal v2.22.0 runs real REST servers from .dpr files. No IIS, no Apache: just crab-pascal run and curl. Why Horse in CrabPascal? Horse provides routing, JSON bodies, and middleware-style handlers. CrabPascal ships RTL shims and a runtime HTTP stack so examples work out of the box: Example Port Endpoints examples/crud/ 9000 Full product CRUD examples/time-server/ 9001 Time/date ping examples/agenda/ 9000 Contact registry All runnable with the internal runtime — no gcc required. Minimal API program SimpleAPI ; uses Horse , System . JSON ; begin THorse . Get ( '/ping' , procedure ( Req : THorseRequest ; Res : THorseResponse ; Next : TNextProc ) var J : TJSONObject ; begin J := TJSONObject . Create ; J . AddPair ( 'message' , 'pong' ); Res . Send ( J . ToJSON ); end ); THorse . Listen ( 9000 ); end . Run and test: crab-pascal run SimpleAPI.dpr curl http://localhost:9000/ping Expected response: {"message":"pong"} . CRUD example from the repo The examples/crud/crud.dpr project demonstrates production-style routes: THorse . Get ( '/produtos' , procedure ( Req , Res , Next ) begin Res . Send < TJSONObject >( TProdutoService . ListarProdutos ); end ); THorse . Post ( '/produtos' , procedure ( Req , Res , Next ) var json : TJSONObject ; begin json := Req . Body < TJSONObject >; Res . Send ( TProdutoService . CriarProduto ( json . GetValue ( 'nome' ). Value , json . GetValue ( 'categoria' ). Value , StrToFloatDef ( json . GetValue ( 'preco' ). Value , 0 ), StrToIntDef ( json . GetValue ( 'estoque' ). Value , 0 ) )); end ); Start the server: cd examples/crud crab-pascal run crud.dpr Testing with curl List products: curl http://localhost:9000/produtos Create a product: curl -X POST http://localhost:9000/produtos \ -H "Content-Type: application/j

2026-06-04 原文 →
开源项目

Configuring CrabPascal with crabpascal.toml | Configurando com crabpascal.toml

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Configuring CrabPascal with crabpascal.toml Every serious compiler needs project-level configuration. CrabPascal v2.22.0 reads crabpascal.toml from your project root — search paths, preprocessor symbols, Delphi vs FPC mode, output format, and runtime defaults. Where the file lives The compiler searches in order: crabpascal.toml (project root) .crabpascal.toml (hidden) config/crabpascal.toml If none exist, sensible defaults apply. Add the file when your project grows beyond a single .dpr . Starter configuration [compiler] version = "2.22.0" search_paths = [ "rtl/" , "lib/" , "examples/" ] defines = [ "CRABPASCAL" , "RELEASE" , "MSWINDOWS" ] mode = "DELPHI" # or "OBJFPC" strict = false warnings = true [preprocessor] enabled = true process_includes = true symbols = [] [output] error_format = "vscode" # or "gcc", "delphi" colors = true [runtime] default_http_port = 9000 [paths] rtl_path = "rtl/" output_path = "output/" Place this beside your .dpr file. All CLI commands ( check , run , build-exe ) pick it up automatically. Common use cases Delphi vs Free Pascal mode [compiler] mode = "DELPHI" defines = [ "CRABPASCAL" , "MSWINDOWS" ] Switch to FPC compatibility: [compiler] mode = "OBJFPC" defines = [ "FPC" , "UNIX" ] Mode affects parsing rules and RTL resolution under rtl/ . Custom unit search paths Large projects split units across folders: [compiler] search_paths = [ "rtl/" , "src/units/" , "src/services/" , "third_party/" ] This replaces hardcoded -U flags in scripts. Preprocessor symbols Match Delphi conditional compilation: [preprocessor] enabled = true symbols = [ "DEBUG" , "TESTING" ] Your Pascal code can use: {$IFDEF DEBUG} WriteLn ( 'Debug build' ); {$ENDIF} Run crab-pascal preproc MyApp.dpr to inspect expanded source. CI-friendly error output [output] error_format = "gcc" colors = false show_stacktrace = false GitHub Actions parsers often prefer gcc-style lines. Local development can

2026-06-04 原文 →