English {#english}
Delphi Compatibility: 360° Review
Is CrabPascal "compatible with Delphi"? The honest answer is partially — by design, with a plan. The Review 360° document (roadmap/review-360) audits the entire pipeline: preprocessor, lexer, parser, semantics, codegen, runtime, RTL, tests, and IDE integration. This post distills what it means for developers evaluating the compiler.
End-to-end pipeline
Confirmed modules in Rust:
preprocessor → lexer → parser/AST → semantic → runtime
↘ codegen (C)
unit_resolver + rtl/ shims feed all stages
CLI commands map to stages: preproc, check, run, build-exe. Understanding where a bug lives saves hours — a parse error is not fixed in the runtime.
Priority 0 gaps (block real projects)
System namespaces — Projects using uses System.SysUtils need resolver paths like rtl/sys/. Sprint 2+ added shims; coverage grows each release.
Classes and streams — Without TStream, TStringList, and friends, VCL-adjacent and Horse-adjacent code stalls. Sprint 3 targeted minimum surface; gaps remain in edge methods.
Exceptions — Delphi try/except/raise works in run; native codegen explicitly refuses fake stubs since v2.21.0. RTTI-heavy exception filtering is incomplete.
Priority 1 gaps (very common)
Generics API — TList<T> works via runtime monomorphization, but full Generics.Collections behavior (enumerators, method parity) trails Delphi.
Satellite units — System.Types, System.StrUtils, System.DateUtils — many routines exist as intrinsics without complete Pascal declarations.
Structural risks
String semantics — CrabPascal uses UTF-8 Rust strings internally; Delphi uses UTF-16 UnicodeString with different indexing and PChar rules. String-heavy code may diverge subtly.
Pointers and var — Address-sensitive APIs (Move, buffer passing) need ongoing runtime work.
Namespace resolver drift — If rtl/sys mapping breaks, code "compiles" partially and fails at runtime.
Phased improvement plan
Phase 1 — Delphi Base — Expand System.* and Classes shims until benchmark examples compile at higher rates.
Phase 2 — Exception semantics — Align try/finally, typed on E: Exception, and eventual native lowering.
Phase 3 — Generics and collections — Close behavioral gaps vs Delphi RTL tests.
Each phase ties to sprints with acceptance tests — not slide-deck promises.
How to use the review as a user
Before migrating a unit:
- Run
crab-pascal check YourUnit.pas - Compare dependencies against RTL inventory in the review
- Prefer
runif you use exceptions or advanced OOP - Track your blockers — many match documented Priority 0/1 items
How to use it as a contributor
Pick a gap with a minimal repro and a sprint slot. RTL work needs Pascal shim + Rust intrinsic + fixture. Parser work needs AST test in tests/.
Bottom line
CrabPascal is not a stealth Delphi clone — it is an incremental compatibility engine written in Rust. The 360° review is the scoreboard: what's green, what's red, and what ships next. Read the full doc in Mintlify and follow @crabpascal for sprint closures that move items from red to green.
Repository: bitbucket.org/alphatecnologia/crabpascal
Português {#portugus}
Compatibilidade Delphi: review 360°
CrabPascal é "compatível com Delphi"? A resposta honesta é parcialmente — de propósito, com plano. O Review 360° (roadmap/review-360) audita o pipeline inteiro: preprocessor, lexer, parser, semântica, codegen, runtime, RTL, testes e IDE. Este post resume o que isso significa para quem avalia o compilador.
Pipeline ponta a ponta
Módulos confirmados em Rust:
preprocessor → lexer → parser/AST → semantic → runtime
↘ codegen (C)
unit_resolver + shims rtl/ alimentam todas as fases
Comandos CLI mapeiam fases: preproc, check, run, build-exe. Saber onde um bug mora economiza horas — erro de parse não se corrige no runtime.
Gaps prioridade 0 (bloqueiam projetos reais)
Namespaces System — Projetos com uses System.SysUtils precisam de paths como rtl/sys/. Sprint 2+ adicionou shims; cobertura cresce a cada release.
Classes e streams — Sem TStream, TStringList etc., código perto de VCL/Horse trava. Sprint 3 mirou superfície mínima; gaps permanecem em métodos de borda.
Exceptions — try/except/raise funciona em run; codegen nativo recusa stubs falsos desde v2.21.0. Filtro tipado estilo RTTI está incompleto.
Gaps prioridade 1 (muito comuns)
API de generics — TList<T> funciona via monomorphização no runtime, mas comportamento completo de Generics.Collections (enumerators, paridade de métodos) fica atrás do Delphi.
Units satélite — System.Types, System.StrUtils, System.DateUtils — muitas rotinas existem como intrinsics sem declarações Pascal completas.
Riscos estruturais
Semântica de string — CrabPascal usa strings UTF-8 Rust internamente; Delphi usa UnicodeString UTF-16 com regras diferentes de indexação e PChar. Código pesado em string pode divergir sutilmente.
Ponteiros e var — APIs sensíveis a endereço (Move, passagem de buffer) precisam trabalho contínuo no runtime.
Drift do resolver de namespace — Se mapeamento rtl/sys quebra, código "compila" parcial e falha em runtime.
Plano de melhorias por fases
Fase 1 — Delphi Base — Expandir shims System.* e Classes até exemplos benchmark compilarem mais.
Fase 2 — Semântica de exceptions — Alinhar try/finally, on E: Exception tipado e eventual lowering nativo.
Fase 3 — Generics e collections — Fechar gaps comportamentais vs testes RTL Delphi.
Cada fase liga a sprints com testes de aceitação — não promessas de slide.
Como usuário
Antes de migrar uma unit:
- Rode
crab-pascal check SuaUnit.pas - Compare dependências com inventário RTL do review
- Prefira
runse usar exceptions ou OOP avançado - Registre blockers — muitos batem com itens Prioridade 0/1 documentados
Como contribuidor
Escolha gap com repro mínimo e slot de sprint. Trabalho RTL precisa shim Pascal + intrinsic Rust + fixture. Parser precisa teste AST em tests/.
Conclusão
CrabPascal não é clone stealth de Delphi — é motor de compatibilidade incremental em Rust. O review 360° é o placar: o que está verde, vermelho e o que shipa em seguida. Leia o doc completo no Mintlify e siga @crabpascal para fechamentos de sprint que movem itens de vermelho para verde.
Repositório: bitbucket.org/alphatecnologia/crabpascal
Published on dev.to/@crabpascal · Código em CrabPascal
Top comments (0)